allegro5
allegro5 copied to clipboard
Audio latency on macOS
Whilst setting up compilation for my game on macOS, I've noticed an increase in audio latency vs. Windows and Linux. I haven't timed it precisely, but the time between triggering a sample and hearing it play is around 1/3 or 1/4s - whereas on Windows and Linux, it's instantaneous.
I'm running macOS 10.14.6 (latest Mohave).
Just a quick note on this topic based on my experience. On my recent explorations, I'm timing audio delay from function-call-to-sound-ouput of approx 0.14 seconds on MacOS. (I'm on Montery 12.6 on an M1).
For my use cases, I'm not needing real-time responsiveness of the audio, but I have needed the audio to sync to a beat clock (as in how many beats have played per measure in real-time).
The al_set_mixer_postprocess_callback is implicitly sending buffers with a size of 2048, which on its own will result in 46.4 milliseconds (0.0464 seconds) when sampling at 44.1 kHz.
Whatever the system/hardware/os delays are, I'm needing to add delay offset of -0.14 seconds on my beat clock in order to have it line up with the actual audio in most cases. Note this is not a hard calculated number, rather, what I've come up with that appears to be the most in-sync.