Hello,
I develop https://repetito.com, a software looper that uses Juce, and have an issue with round-trip latency.
Round-trip latency is important for a looper to be able to synchronize loops being recorded with loops being played, so I measure this latency and precisely compensate for it.
When testing Repetito with recent Juce versions, I noticed that round-trip latency suddenly increased - almost twofold!
Following is a link to an xcode 12 project that can be used to reproduce the issue. The app measures round-trip latency simply by playing a 2 second silence with a digital click in the middle, and recording the input while this audio is played. If the input picks up the audio output, the app is able to measure the round-trip latency.
https://repetito.com/RoundTripLatency/RoundTripLatency.zip
With this test app, I was able to find the commit that introduced this issue:
5ec536f13 (“CoreAudio: Forward errors to callback during device initialisation”, 2022-08-18)
Here’s the previous commit, and changing from that commit to 5ec536f13 introduces the issue:
5b355f637 (“Graph: Tidy up names”, 2022-08-12)
I’ve looked a bit at the code change but am not familiar with AudioIODeviceCombiner. Removing the ScopedErrorForwarder in AudioIODeviceCombiner fixes the issue - but that’s more of a workaround. I can’t see anything wrong in ScopedErrorForwarder so I suppose the issue is more in the interaction between ScopedErrorForwarder and AudioIODeviceCombiner.
To test: if you are using the mac’s audio device, you simply need to have a decent output volume. If you are using an external audio device, a mic must be set so it picks up the audio output (some channel config is necessary if the input channel is not the one with the mic since the app uses the first input channel).
Test Process:
- unzip the project;
- git clone Juce in the specified directory;
- git checkout 5ec536f13 or more recent, run the app and check the Real-Time Latency value (the issue is present, RTL is big);
- git checkout 5b355f637 or older, run the app and check Real-Time Latency (the issue is not present, RTL is small);
I’m testing on a M1 2020 MacBook Air running macOS 12.2.1 with the internal audio device, but I’ve also tested with other devices.
Note: the measured round-trip latency is not exactly the same when testing multiple times - but it doesn’t change much (less than a few ms with my tests).
Could someone at Juce look into this?
Thanks! -Mathieu