Author Topic: Offset channels in mixer  (Read 213 times)

gicci

  • Posts: 82
Offset channels in mixer
« on: 19 Jan '22 - 23:14 »
Hi,

I have a mixer where I plug a MIDI channel and file stream (WAV). I was wondering what could be the best and easiest solution to offset in time the WAV file playback from the MIDI file for a configurable amount of milliseconds (to re-sync them in time).

Thank you for your help.

Ian @ un4seen

  • Administrator
  • Posts: 24330
Re: Offset channels in mixer
« Reply #1 on: 20 Jan '22 - 12:55 »
You can use BASS_Mixer_StreamAddChannelEx to delay the start of a mixer source. For example, if you have a delay in milliseconds, you could do something like this:

Code: [Select]
BASS_Mixer_StreamAddChannelEx(mixer, source, flags, BASS_ChannelSeconds2Bytes(mixer, delayms / 1000.0), 0);

Please see the BASS_Mixer_StreamAddChannelEx documentation for details.

gicci

  • Posts: 82
Re: Offset channels in mixer
« Reply #2 on: 21 Jan '22 - 21:56 »
As this seem to work in relation with the output I guess it works both for the WAV and MIDI channels, right?

Could you please clarify the statement
Quote
If the mixer is restarted with BASS_ChannelPlay (restart = TRUE) or BASS_ChannelSetPosition (pos = 0), the start delay will not be reset at the same time; the delay will be whatever was remaining before the mixer restarted
Does this mean that in those cases to re-apply the delay I need to remove the channel and add it again?
What about a set position not to 0? Will the delay still be applied?

Thank you.

Ian @ un4seen

  • Administrator
  • Posts: 24330
Re: Offset channels in mixer
« Reply #3 on: 25 Jan '22 - 14:41 »
As this seem to work in relation with the output I guess it works both for the WAV and MIDI channels, right?

Yes, you can use BASS_Mixer_StreamAddChannelEx to delay any mixer source.

Does this mean that in those cases to re-apply the delay I need to remove the channel and add it again?

When you say "re-apply the delay" do you mean change the delay, and do you want to do that mid-playback? If so, and if the change is fairly small, it may be better to adjust the speed of the source slightly via its BASS_ATTRIB_FREQ setting to gradually get the delay that you want, eg. raise the BASS_ATTRIB_FREQ setting to reduce the delay, and lower it to increase the delay, and set it back to normal when you have the wanted delay. Doing it this way will avoid any breaks in sound.

What about a set position not to 0? Will the delay still be applied?

Do you mean calling BASS_ChannelSetPosition before BASS_Mixer_StreamAddChannelEx? If so, any delay set in the BASS_Mixer_StreamAddChannelEx call would still apply.