-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optimize FlexASIO latency #8
Comments
(One thing to note is that, AFAICT, the Windows audio engine uses 20 ms buffer sizes internally - or at least I've never seen it use any other buffer size. It might be that, for "shared" backends like WASAPI Shared and DirectSound, just telling PortAudio to use a 20 ms buffer size might be enough to make the latency optimal, since the ASIO buffers and the Windows audio buffers would then be aligned. We should experiment with that.) |
Excellent news: after examining the PortAudio WASAPI backend code, I was able to find out how to nudge it into "low latency" mode, where it uses the smallest possible buffers and switches to event mode (instead of pull mode). With that, I was able to achieve extremely low latencies, on the order of 10 ms(!). The way to do that is trivial: just set |
Leaving this issue open to continue the investigation into latency with other settings and backends other than WASAPI. |
Some notes from my investigation. In all tests, ResultsMMEReported latency is fairly similar to suggested latency. However, it will happily report a latency of 1 ms, which MME clearly shouldn't be capable of. That's evidence that the reported latency is a lie. DirectSoundReported latency is fairly similar to suggested latency. However, reported latency bottoms out at 2 ms, which DirectSound clearly shouldn't be capable of. That's evidence that the reported latency is a lie. WASAPI SharedReported latency is fairly similar to suggested latency. Reported latency bottoms out at 20 ms, which is consistent with what we would expect (the internal buffer size of the Windows audio engine is 20 ms). WASAPI ExclusiveThis is the only backend I've seen which interprets a suggested latency of With a suggested latency of With a suggested latency of With a suggested latency of WDM-KSAppears to follow specified buffer size and suggested latency to the letter - what you see is what you get (at least as far as reported latency is concerned). Reported latency bottoms out at 10 ms, which seems plausible. Action items
|
This has been observed to be the value that makes the most sense, no matter the use case. Most likely this is because PortAudio knows the overall buffer size anyway, and that's enough to deduce what the intended latency is. See #8.
Am I doing something wrong with FlexASIO? I see output latency: 85ms. 1024 samples. However, no pops or clicks for now. I have set WASAPI Exclusive and latency at 0 by default. |
What buffer size are you using? With WASAPI Exclusive and |
The current limitations around latency are described in the README:
The way buffer sizes and latency are handled in FlexASIO is very naive, as it was not designed to optimize for latency. That said, there might be some low-hanging fruit there. For example, if we're smarter about the buffer sizes we suggest to the ASIO host application, we might avoid certain situations where PortAudio has to do additional buffering.
Looking at the current code, the main issue is that we're calling
Pa_OpenStream()
with a specificframesPerBuffer
value (the one set in ASIO), which is not great, as the PortAudio documentation explains:The text was updated successfully, but these errors were encountered: