-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Supporting WASAPI's new AudioClient3 (Windows 10) mode: Real Time Low-Latency Audio #560
Comments
Okay I have done more research and edited the first post. What I have read so far seems to confirm that JUCE will need to use the AudioClient3 subclass, query the supported shared mode periods (aka latencies), then request IAudioClient3::InitializeSharedAudioStream to get a low-latency shared stream. Furthermore, the low-latency shared mode is only supported if the audio drivers support WaveRT, but it seems most devices released for at least half a decade should support it now since it was introduced in Windows Vista and is the default audio driver protocol in Windows. Lastly, when running in "realtime audio" shared mode, we can expect latencies of 2-3ms BUT the Microsoft docs (see end of previous post) say that applications DO NOT and CANNOT request specific buffer sizes; instead, they request a specific "period" (latency) and then it is up to the application to fill that variable-length buffer. It would be a huge leap for JUCE to support this since it provides shared-mode audio with latencies about as low as ASIO, with no special drivers All modern machines have WASAPI drivers. Few have ASIO drivers! |
Found a good Microsoft FAQ: https://docs.microsoft.com/en-us/windows-hardware/drivers/audio/low-latency-audio#faq
|
Any progress on this? Is it as easy as just dropping in the |
How do you plan to deal with thread scheduling? Threads work on a time frame of a few ms, and the buffer size will be smaller than 10ms. How to ensure that there's no glitches? I was looking at the docs and perhaps needs a real-time work queue api for the callbacks to operate on such a resolution? (Checking support should be simple with MSCOM, using audioclient* and cast to audioclient3* and get the interface, if fails fallback to audioclient*, if succeeds, mark it as have support) |
This has been added to the |
I was looking at the WASAPI driver:
https://github.com/WeAreROLI/JUCE/blob/master/modules/juce_audio_devices/native/juce_win32_WASAPI.cpp
It uses AudioClient1 (IAudioClient), the original WASAPI format. It allows low latency in exclusive mode, but is stuck at a minimum of 10ms latency in shared mode.
As of Windows 10, Microsoft introduced IAudioClient3 for "real time audio" which allows as little as 2.67ms of latency at 48 kHz even in SHARED DEVICE MODE. That's incredible. Having low latency in "shared mode" (so that multiple applications can output audio at the same time) is the holy grail!
IAudioClient3 is a subclass of IAudioClient2 is a subclass of IAudioClient. So in theory, all you will have to do is use IAudioClient3 with your existing code to take advantage of it, possibly with some new flags, as well as some OS checks to only use IAudioClient3 if the user is on Windows 10.
I've collected some links:
NOTE:
To get ultra low latency, the audio driver MUST support the "WaveRT" protocol. Here are the descriptions of all audio driver protocols, taken from the Virtual Audio Cable (VAC) manual (which supports all 3). I have copied chunks of text from all over the VAC manual, so this is a bit jumbled, but generally provides a great overview of the differences between the audio driver protocols:
And here are Microsoft resources describing WaveRT:
It seems like WASAPI may automatically select WaveRT mode if available, but some research needs to be done in the JUCE project:
The text was updated successfully, but these errors were encountered: