Author Topic: The channel isn't synced when it's added to a mixer  (Read 134 times)

jsuamar

  • Guest
Hello, I'm trying to remove a channel from a mixer and add another one in the same position the rest have. The problem is that setting the new channel in the same position of the rest, it doesn't sounds synced. The streams sources are URLs.


The way I'm trying to do that is the following (when the buffer of the new channel has finished):
Code: [Select]
BASS.BASS_ChannelLock(mixer, true);

long currentBytesPosition = BASSmix.BASS_Mixer_ChannelGetPosition(oldChannel, BASS.BASS_POS_BYTE);
double currentSecondsPosition = BASS.BASS_ChannelBytes2Seconds(oldChannel, currentBytesPosition);
long newChannelBytesPos = BASS.BASS_ChannelSeconds2Bytes(newChannel, currentSecondsPosition);

BASSmix.BASS_Mixer_ChannelRemove(oldChannel);

BASSmix.BASS_Mixer_StreamAddChannel(mixer, newChannel, 0);

BASSmix.BASS_Mixer_ChannelSetPosition(newChannel, newChannelBytesPos, BASS.BASS_POS_BYTE);

BASS.BASS_ChannelLock(mixer, false);

I have noticed if I set the position to 0 to all the streams, they are synced. What should I do? Am I doing something wrong?

Thank you for your help!

Ian @ un4seen

  • Administrator
  • Posts: 20400
Re: The channel isn't synced when it's added to a mixer
« Reply #1 on: 1 Jun '17 - 14:04 »
The first thing to check is whether the BASS_Mixer_ChannelSetPosition call is succeeding (returning TRUE). As it's an internet stream, it's possible the requested position isn't available (downloaded) yet.

The other thing to consider is that the new stream won't be heard immediately due to buffering, ie. there is buffered mixer output that needs to be heard first. So you would need to account for that in the BASS_Mixer_ChannelSetPosition call. Try replacing the BASS_Mixer_ChannelGetPosition call with BASS_ChannelGetPosition, which will give the decoder position rather than what's currently heard from the mixer.

Code: [Select]
long currentBytesPosition = BASS.BASS_ChannelGetPosition(oldChannel, BASS.BASS_POS_BYTE);