JUCE and Latency on Windows; WASAPI

Hello.

I am trying to create a real-time audio Windows application (32-bit) using Qt. I am using JUCE(5.4.5) libraries in my Qt project to get audio out. I am very new to Juce but I’ve managed to get audio out by looking at a couple of examples. I made my own AudioAppComponent class but without the GUI Component. Using Juce to get audio out has been a smooth process.

However, I am having issues with latency. I seem to be experiencing a delay of 40ms (!) between a “note” going in and audio coming out of the speakers. I set up the audio device with a bufferSize of 256 (5.8 ms) and sampleRate of 44100 Hz. I am using WASAPI. I tried using ASIO but it seems a Windows 10 update has stopped ASIO4ALL from working at all.
So my question is, what is a good way to decrease latency on Windows 10 (1903) with WASAPI? Or does 40ms indicate that I am using JUCE wrong somehow?

I would appreciate any help I can get. Thanks in advance!

PS: Does JUCE support WASAPI’s AudioClient3?

The buffer size you request in samples does not necessarily 100% correlate with the actual latency you are going to get. (Even with ASIO when using actual ASIO compatible hardware.) The hardware or its drivers may add additional latency.

Juce mostly attempts to support what is common to all the platforms it runs on. So for example, if AudioClient3 has some extra features that don’t make sense on other platforms, it likely isn’t going to be supported in Juce. (Looking quickly through the Juce WASAPI implementation, it appears to be using the oldest IAudioClient thing.)

1 Like

Thank you for your reply. Yes, the drivers will add a delay in addition to the delay due to bufferSize. But I didn’t think the additional delay would be around 34ms. That seems to be a bit too high for me.
I am using the Realtek ALC1150 audio chipset that came with the motherboard, which supports WaveRT protocol. Hopefully, I am not facing any bottlenecks there.
I’ve been reading this post which says using IAudioClient3 in JUCE can be done with a few tweaks. So I am going to try that and see if it improves performance. Will update if/when performance improves.
Cheers!

So I managed to add IAudioClient3 to JUCE’s WASAPI audio interface. Learned a lot! In order to fully utilise IAudioClient3, I had to use Microsoft’s High Definition Audio Driver for my Realtek ALC1150 IC instead of Realtek’s own driver. Realtek only allows a bufferSize of 448 (@44100 Hz). But with MS’s HD Audio Driver, I was able to bring the bufferSize down to 128. Now I get a latency of 20ms(!). Literally half the latency I previously had. I really want to bring down the latency even lower, like around 10ms. Will appreciate any tips, anyone can throw my way. Cheers!

Got ASIO working. Now getting sub 10ms latencies. WASAPI is just not as good as ASIO when it comes to latencies.

1 Like

Hello,SidKA, I am currently experiencing delays.I’m new Juce, I am using Juce 5.4.3 libraries in my audioDemo project to get audio out, and using ASIO type , using ASIO4ALL driver , but it sounds delay. would you can send me your Demo (xuj08127@gmail.com) ? I’ll very appreciate , Thanks in advance !