Author Topic: Channel linking problems  (Read 131 times)

srylain

  • Posts: 18
Channel linking problems
« on: 20 Oct '17 - 01:41 »
I have upwards of 12 channels that all need to be played at once, so I'm linking them together and playing/pausing/resuming them all from the first channel handle.

My problem seems to come from trying to restart the channels after they've stopped because they ended. Normally the restarting works, but only when the channels are currently playing. This is how I'm seeking:

Code: [Select]

    public void SeekToPosition(float position)
    {
        if (!isSongLoaded)
            return;

        for (int i = 0; i < stemChannels.Length; i++)
        {
            if (stemChannels[i] == 0)
                continue;

            long lengthBytes = Bass.BASS_ChannelGetLength(stemChannels[i]);
            long posBytes = Bass.BASS_ChannelSeconds2Bytes(stemChannels[i], position);

            if (posBytes >= lengthBytes)
            {
                //lengthBytes - 1 because if a channel's position is at the end it restarts from the beginning, which I don't want
                Bass.BASS_ChannelSetPosition(stemChannels[i], lengthBytes - 1);
                continue;
            }

            Bass.BASS_ChannelSetPosition(stemChannels[i], position);
        }
    }

And right after I call SeekToPosition(), I call Play() which basically all it does is play the channel that all the other channels are linked to. As I said earlier, if the channels are currently playing everything seems to work but if they've already ended their positions do get set properly and only one channel plays (the one that the others are linked to).

EDIT: Actually, I think I may have figured this out. What's really weird is this was working correctly before, I think, but now it seems that if I call BASS_ChannelPause() before setting the position it seems to work. Can someone confirm if this is the case and how it should be done?
« Last Edit: 20 Oct '17 - 01:53 by srylain »

Ian @ un4seen

  • Administrator
  • Posts: 20426
Re: Channel linking problems
« Reply #1 on: 20 Oct '17 - 17:09 »
Yes, it would be best to pause/stop the channels before seeking, and then resume them afterwards, so that they all start at the new position together.