Author Topic: better way to crossfade  (Read 138 times)

mkllc

  • Posts: 42
better way to crossfade
« on: 26 May '21 - 16:32 »
Hi, I'm trying to implement a way to cross-fade between a couple of files (tweeaking start, length, fadein time...) at this moment I use a couple of streams chans and set a sync_pos on the first to start doing a slide and play the next file but I have to deal constantly with a couple of streams and inserting them into a mixer (to reeconde the output). Taking care about "chan A" and "chan B" to load the next one and set sync on the proper channel etc.

There is a way to leave all this management to Bass? Some function I'm missing, some flag that allows to add the next file or something like? I want to use all of this in a class and just call "play_file" and "set_next" and now I have to do all the logic by hand. Of course, it's not a problem, I just want to know about the best or the proper way to cross-fade. Thanks

Ian @ un4seen

  • Administrator
  • Posts: 23743
Re: better way to crossfade
« Reply #1 on: 26 May '21 - 17:21 »
I'm afraid there aren't currently any automatic crossfading options, so you would need to set that up yourself, eg. using BASS_Mixer_ChannelSetEnvelope or the BASS_FX_VOLUME effect. You could perhaps implement that in your class's "play_file" and "set_next" methods :)

mkllc

  • Posts: 42
Re: better way to crossfade
« Reply #2 on: 26 May '21 - 17:41 »
Thanks! then I will do this way. But using two Stream Channels is the way also, isn't it? I did not see any way to deal with two files at the same time without it.

Btw, sliders will work inside a mixer? (in realtime, not decoding mixer or channels) I think they're more intuitive than envelopes

Ian @ un4seen

  • Administrator
  • Posts: 23743
Re: better way to crossfade
« Reply #3 on: 27 May '21 - 16:38 »
But using two Stream Channels is the way also, isn't it? I did not see any way to deal with two files at the same time without it.

Yes, each file will need its own stream, eg. BASS_StreamCreateFile call.

Btw, sliders will work inside a mixer? (in realtime, not decoding mixer or channels) I think they're more intuitive than envelopes

Do you mean BASS_ChannelSlideAttribute on the stream's BASS_ATTRIB_VOL value? If so, yes, that will work. One thing to note when doing that on a mixer source is that the mixer's update period will determine how often the source's BASS_ATTRIB_VOL value is refreshed, so how smooth the slide will be in the mixer output. That won't be an issue if the mixer has playback buffering disabled (BASS_ATTRIB_BUFFER=0) but otherwise the update period is determined by the BASS_CONFIG_UPDATEPERIOD setting, which is 100ms by default.

BASS_Mixer_ChannelSetEnvelope and the BASS_FX_VOLUME effect will produce smoother fades, but if the fade is reasonably long then the difference probably won't be noticeable.