Playing a mixer stream in reverse

Started by nadia,

nadia

Hello  ;D

I have a question: I would like to add a few streams to a mixer stream and give the possibility to play the resulting mixer stream in reverse: is there a way to do this or any idea about its feasibility?

Kind regards  ;D

nadia

Ian @ un4seen

It won't be possible to reverse a mixer directly because it doesn't support seeking, but you could reverse the sources instead, ie. use BASS_FX_ReverseCreate on each of them.

Or if you're rendering the mix to a file, then you could reverse the file afterwards.

nadia

Hi  ;D

indeed I thought that I could create the reverse for each source stream before adding to the mixer and then set them all the BASS_ATTRIB_REVERSE_DIR attribute when I need a reverse playback but my concern is if they would effectively play in reverse when I play the mixer stream through the BASS_ChannelPlay function.

Kind regards  ;D

nadia

Ian @ un4seen

Yes, the mixer would receive reversed data from the sources.

If you will be switching between reverse/forward mid-playback, then you should lock the mixer to ensure all sources get switched at the same time in the mix:

BASS_ChannelLock(mixer, true); // lock the mixer
// set BASS_ATTRIB_REVERSE_DIR on each source here
BASS_ChannelLock(mixer, false); // unlock the mixer

nadia

Hi  ;D
reversed streams added to a mixer work, but I have a problem that makes me nut.

If I append 3 reversed streams (A, B and C) to the mixer, they effectively play in reverse but always in the order A-B-C : when reverse play is needed, is there a way to make them play in the order C-B-A without the need to render the mixer's content to a file?

Kind regards  ;D

nadia

Ian @ un4seen

If you're playing sources in sequence rather than all together, then that will indeed complicate things. You would need to add them to the mixer in reverse order, ie. C-B-A instead of A-B-C. For more complex scenarios, it may be better to pre-render the normal mix to a WAV file and then reverse that. Note you could do that all in memory by using BASS_Encode_StartPCM and a callback function that puts the WAV file in memory (and then pass it to BASS_StreamCreateFile with BASS_FILE_MEM).

nadia

Indeed I had good results in changing the order of the streams, now I can play in both directions but there seem to be a glitch.
In order to be notified when the playback of the mixer stream is completed, I've added a sync on the mixer stream (BASS_SYNC_END) and, obviously, the mixer was created using the BASS_MIXER_END flag: this works perfectly and the syncproc is called when playing in regular direction but the same doesn't happen when playing streams in reverse: am I missing something?

Kind regards

nadia

Ian @ un4seen

That seems like it should work. If you aren't already using it, please try the latest BASS_FX build:

    www.un4seen.com/stuff/bass_fx.zip

If the problem persists, do BASS_SYNC_END syncs set on the reverse stream sources get triggered?

nadia

I already have the latest bass_fx and yes, the sync is triggered when a reversed stream ends

Kind regards

nadia

nadia

Hello  ;D

now it seems to work, sorry.

Kind regards

nadia

Ian @ un4seen

Did you change something or it just started working by itself? Anyway, good to hear it's working, however it happened :)

nadia

Quote from: Ian @ un4seenDid you change something or it just started working by itself? Anyway, good to hear it's working, however it happened :)

Hello,  ;D
it was my fault, the usual "copy&paste" error.

Kind regards

nadia