I’m currently implementing a rhythm game system in UE4 using FMOD, and I noticed a specific issue when trying to add a pause/unpause feature to the game. After calling setPaused on the event instance multiple times, the getTimelinePosition values I get start falling behind what I’m actually hearing in the song. To examine the issue more clearly, I set up this test case:
- There was a clear kick sound X seconds into the song, and I wanted to print a string in Unreal exactly at X seconds after the song started playing.
- I play the audio alongside my rhythm game system (without any pausing) and it prints the message exactly X seconds into the song. I’m using getTimelinePosition as the way to see how far we are in the song playback. My printed message also prints what getTimelinePosition is at that point, and it prints a value very close to X as expected.
- I play the audio again, but this time I pause and resume playback 10-20 times by calling setPaused on the event instance. I hear the kick sound, and after a noticeable delay (~200-300 ms), I see my message printed. My printed message says that getTimelinePosition is again X.
I saw a couple of other questions related to this subject such as dspClockTime is out of sync after event instantiation? - #2 by cameron-fmod and Off sync on position "getTimelinePosition" when using "setPaused" method. , and so I tested the same system using channelGroup->getDSPClock instead. I saved the getDSPClock value once when the song playback started, and would subtract that from the newer DSPClock value as the song played to find the current song playback position. This method didn’t work either and my song position value still ended up lagging behind the actual audio after repeated pause calls.
One last thing I tried was to create a timeline marker exactly at X seconds in FMOD Studio, and print out my message using the timeline marker callback. Without any pausing, this worked fine and my message was timed perfectly with the kick at X seconds. With repeated pausing and resuming, the same issue happened: I heard the kick first, and after a noticeable delay I saw the timeline marker callback print out my message.
I’m happy to create a small example project and send that to better demonstrate the issue. Any help would be appreciated as at this point I’m not sure if there’s a way for me to reliably track how far I am in the event being played, if I also want to support pausing and resuming playback. Thanks!