Hello there,
I’m working on audio for a fast paced platformer in UE, so keeping the latency low is key. I’m wondering what the best practice is in order to achieve as little latency between the trigger and the sound being played.
In particular I’m talking about sounds which have a start, loop and end phase. From past projects I’ve learned that transition regions might introduce more latency than a keyOff. Is this still correct?
Also I’m a bit worried about the scenario where the keyOff command is triggered before the playhead has reached the sustain point. What happens in that case? Will the event be stuck then?
Is it better to link the sustain point to a parameter in order to avoid the keyOff command altogether or does this also come with some trade offs?
Thanks for your help!
Also, how is using a transition region with the event condition “is stopping” to go into the “end sound” different. From testing, I feel like this is a bit slower than using sustain points?
I ran a quick test timing the difference between setParameter
/stop
/keyOff
calls and a marker being crossed over with FMOD_STUDIO_EVENT_CALLBACK_TIMELINE_MARKER
with both transition regions and sustain points. On average, transition regions are exited more quickly than sustain points, but not by a significant amount:
|
Sustain point |
Transition region |
keyOff |
32ms |
n/a |
stop |
32ms |
25ms |
setParameter |
32ms |
25ms |
No it will not. If the key off is fired before the sustain point is hit the sustain point will be disabled / keyed off by the time the playhead crosses over it.
Generally speaking, best practice is to design your events in the way that makes the most sense to you, and use the FMOD Profiler and time the API calls as I have done to decide if anything needs to be optimized in your case.
The 7ms difference between sustain points and transition regions is unlikely to be the source of any noticeable latency. The best latency reductions you can get are by setting a smaller buffer size with System::setDSPBufferSize
- be aware however that the lower the buffer size is the more likely it is that you will overwork the user’s CPU, leading to stuttering and other such performance issues.
1 Like