I need to sync a UI update to the audio timing so that the update accurately corresponds to playback (ie: UI update should happen on beat 1 of every bar). I realize that the audio latency is determined by the audio device and settings so I am wondering if I can acquire that value from within the plugin or will I need to add a “latency offset” option in the plugin which a user will have to set manually. Thanks in advance!
There are quite a few threads, I’ll link them for reference (some you found already):
I think it’s a fair ask, but I don’t know if hosts will ever report it properly. If you consider e.g. Reaper or FinalCut, which pre-render files, there is no synchronicity at all between the processing time and the playback time.
Thanks to latency compensation, a gesture in the editor would have to be transfered in the past to render what you hear accordingly. So doing the gestures is an iterative task by nature, and the result will always fall behind.
The other remark I wanted to bring, the typical perceived update rate is 24-25 per second, lets be generous and use 30 Hz. In which case the jitter to the visual frame is 33 ms. In this time in a normal 44.1kHz signal produced 1470 samples, that’s in conservative setups 3 buffers, in more performant ones even more.
I understand, if your plugin is just before a crazy one second latency inducing plugin, it would be nice to know, but I think precise numbers is not what we should look for.
In that respect I think the device latency is neglible, but the latency compensation would be a good ask. Maybe someone knows, which plugin formats would give that information, and if they can be added to the JUCE API?
Thanks for the response Daniel! You make some great points here. I think for now I will have an option that a user can set for output latency but hopefully the JUCE team will see this and look into the possibility of accessing this information for the plugin formats that support it from the JUCE API.