Hey,
we’ve got FMOD_LOOP_BIDI working correctly when playing through, but need to be able to jump into any location in the infinitely bidirectionally looping channel and I’ve run out of ideas.
Calling Channel::setPosition past the sound’s length throws an error.
Calculating the expected position within the bounds of the sound and calling Channel::setFrequency with a negative value works for the first play through, but doesn’t change direction when it reaches the start of the channel and just bounces around position 0.epsilon.
What is the correct way to seek into a bidirectional loop or set the playback direction of the loop?
The way that setting the position works with BIDI_LOOP is that FMOD will set the playback position to the value you give it but in the current playback direction. That is, if you have a 10 second audio file, if it is playing forwards and you setPosition to the 5 second mark, it will play from 5 seconds up to 10. If it is playing in reverse, setPosition to the 5 second mark will play it from 5 seconds down to 0.
There isn’t a way to change the direction of the playback when in BIDI_LOOP mode.
Instead, I would recommend one of two things:
Use “getPosition” twice to see if the current FMOD::Sound is playing forwards or backwards. Use this to know where to setPosition to in the current play state.
Create your own bidirection loop function by checking the position of currently playing FMOD::Sound compared to how long it is. If it reaches the end, use Channel::setFrequency to be the negative of the frequency the channel is to play it in reverse (ie. get the frequency of the channel playing, then negate it). This way you can flip the direction on the fly and set the position to wherever you need it to.