Hi Joseph!
What is the cause of the 20 ms latency issue?
I’m experiencing a similar issue with my music system, where the transitions don’t trigger correctly if I don’t manually insert some latency by either waiting for about 5 frames or waiting for 30 ms.
Here’s how my event is set up:
I have several songs in nested events, inside the main “musicController”-event.
All the songs can be accessed through the “00 Selection Loop” by switching the “Song”-parameter to their appropriate indexes (setup as integers: 01, 02, 03, etc
).
All songs can go back to the “00 Selection Loop” by switching the “Song”-parameter to 0
.
This means that in order to go from Song 02 to Song 04, FMOD would have to do like this:
Song 02 → 00 Selection Loop → Song 04
I’ve implemented this solution in Unity by doing the following in a Coroutine:
Frame 0
CurrentParameterValue == 2f
SetParameter to 0f
yield/wait 1 frame
(for Fmod to to switch to the Selection Loop)
Frame 1
CurrentParameterValue == 0f
SetParameter to 4f
CurrentParameterValue == 4f
When I print the parameter value during each stage of the process (Before switching, In-Between Switching, After Switching
), the parameter values I get back from the API are correct, and the music/audio is most times also correct.
But the bug I’m encountering is that sometimes the actual audio of the event is stuck on the first song. Ie. the switch to the “00 Selection Loop” never happens.
My workaround so far for this is to yield/wait for 5(!) frames or wait for 30 ms (as described above) between Frame 0 and Frame 1. When I do that, the music switches correctly, at least so far as my testing has proven.
But, doing that is pretty hacky.
So my question is:
Since this game is going to be released on several platforms (PS4, XBONE, Switch, PC, etc), which approach should I use?
- Waiting for an arbitrary amount of frames (which could differ on the different platforms)?
- Or should I rather wait for a set amount of time (which may or may not correspond to the same amount of frames on different devices)?
Regards,
Pablo Sorribes Bernhard
contact@pablosorribes.com
pablosorribes.com