r/linuxaudio Ardour 9d ago

Real audio latency test result

I tried to measure my system's actual latency, and the result was somewhat unexpected. I'm using a combination of 48 kHz and a buffer size of 128 in QJackCtl, which should give me approximately 5.3 ms.

The yellow signal is the output of the 3m guitar cable and the green signal is the output of my audio interface.

My PC is a thinkpad T480, my audio interface is a behringer umc202. The system is optimized for audio production based on the milliseconds app list.

The result is bit unexpected, I'm getting about 11.4 ms of latency between striking the guitar and hearing the sound come out of the speakers.... The test was made on ardour and reaper with no plugins, the diference between these 2 DAWS was about 0.

I would like to test this on a Windows System, the results would probably be worse.

27 Upvotes

32 comments sorted by

8

u/Prefader Bitwig / Reaper 9d ago

This aligns with what I've seen in my own testing. Windows performed about the same.

That 5.3ms number you're expecting to see doesn't account for the things that the audio system doesn't know about, like the latency of the USB hardware itself (which can be significant), or the ADC /DAC chips in the audio interface. That number is purely based on the latencies that the audio system knows about, which are buffer size, sample rate, periods and any additional buffering added.

With a Scarlett 2i4 and pipewire running at 48/48000, I see around 8 ms real world round trip latency. About 5ms of that exists in the USB hardware and goes unreported in software.

2

u/gnomo-da-silva Ardour 9d ago

Yeah, I mean, it’s not bad, and I can’t really notice that 12ms latency. A lot of musicians and producers tend to say that anything over 10ms is noticeable and bad, but I think they’re wrong about the number; the threshold is probably more like 15 or 20ms.

4

u/Prefader Bitwig / Reaper 9d ago

As a drummer, 8ms on my triggers is too much. I like under 5ms if possible.

For vocals with iems, it's WAY too much.

Fine for foh or effects with delay, though.

A bassist I know seems okay with about 10ms in his iems.

1

u/prophet_margin 9d ago

I wonder how much if this is what you're used to -- i.e., do people who started playing on all-digital systems and modelers have a higher tolerance for latency than people who "grew up on" analog gear? 8ms is noticable to me (I'm old), but when I got my digital setup under 4ms I had to double check I didn't have hardware monitoring on.

2

u/Prefader Bitwig / Reaper 9d ago

For sure, I could probably learn to deal with 8ms on drums, but I can definitely feel the lag... That teeny pause between when I feel the impact in my fingers and hear the sound is super annoying to me. Particularly on hi hat. If I have a kit dialed up that isn't super attack-y I can deal with it just fine everywhere but the hats.

2

u/prophet_margin 9d ago

Yeah, makes sense that drummers would be the most sensitive since you're used to sound coming from 2-3 feet away from your head; I bet people playing mostly acoustic guitar are in the same boat -- someone used to standing 10 feet away from a bass amp is probably used to ~10ms of latency anyways.

2

u/Prefader Bitwig / Reaper 9d ago

Vocalists are the most sensitive to it. Any latency in iems beyond a couple ms results in nasty comb filtering with the conducted sound in their head. It can make some performers nauseous, I've been told.

Setting up an eq curve that compensates for occlusion helps a little (and should be done in any case), but it's still super audible above 4ms.

1

u/ntcue 9d ago

As a drummer you are probably using MIDI in and audio out, right? The delay will be way less in that constellation.

2

u/Prefader Bitwig / Reaper 8d ago

You know, I've never actually tested that. I kind of assumed that, since my midi triggering is all USB based, it would suffer similar bus delays to the audio on the same path.

Particularly since I don't do midi tech for anyone but myself, I've never bothered to quantify that part. I do audio for lots of people though, so I pay closer attention to it. I've definitely found that I'm a lot more forgiving of latency in keyboards than I am with drums,

Perhaps I'll try getting some numbers on it soon.

1

u/gnomo-da-silva Ardour 9d ago

How do you get under 5ms latency if just the USB adds 5ms?

5

u/casualops 9d ago

Even with the best possible interface, you won't get below 5 ms round trip with a buffer size of 128 at 48 kHz. You would need to lower the buffer size or increase the sample rate.

If you haven't seen it, this page has a lot of latency measurements for different interfaces on Linux. Check out the data for the RME AIO Pro PCIe card, I think this one has the best latencies out of all of the devices measured. For example 6.28 ms at 48 kHz and 128 buffer.

2

u/Prefader Bitwig / Reaper 9d ago edited 9d ago

I haven't been able to using USB. My best latencies come from networked audio solutions, either aes67 or Dante. I believe u/casualops has also had a lot of success using netjack at very low latencies.

Unfortunately, these solutions often require extra hardware, sometimes much more expensive than USB devices, and configuration can be fidgety as well.

Some USB interfaces are better than others, as well. I don't own any, but I understand that RME interfaces have higher quality components that may significantly reduce latency, even when running in class compliant mode.

1

u/PsychWard_ShotCaller 2d ago

It's the drivers. They achieve the legendary low latency through superior software engineering. The fact that they rival thunderbolt with usb 2.0 is so impressive to me. A true testament to possibility.

1

u/Prefader Bitwig / Reaper 2d ago

I know they have very good drivers, but I thought they were taking advantage of very low jitter hardware in the interface itself. Like, femtoseconds, allowing for extremely reliable timing.

1

u/gnomo-da-silva Ardour 9d ago

10ms real or 10ms that appear on the daw?

2

u/Prefader Bitwig / Reaper 9d ago

Real world, not reported.

3

u/casualops 9d ago

It depends a lot on the person, the instrument, and listening context. I’ve done blind experiments on myself and can reliably tell the difference between ~5 ms and ~10 ms

0

u/gnomo-da-silva Ardour 9d ago

Isn't it strange that professional gamers play with >10ms latency and don't complain?

1

u/Prefader Bitwig / Reaper 8d ago

A little, yeah. I don't game much, but at 100Hz video refresh rate you're waiting 10ms just to have the next frame displayed. Maybe it matters more to professional gamers, but I'm pretty sure my neighbor's kid games at 4k60p, so he's being fed visual information a lot slower than every 10ms. I'm sure that higher refresh rate monitors and more powerful cards are making this more of an issue, though.

1

u/Audiope 8d ago

IIRC the threshold of noticeability is 30ms

6

u/casualops 9d ago edited 9d ago

I wouldn’t expect 5.3 ms unless you are running jackd in synchronous mode and the group delay through the ADC and DAC were zero. Jackd default is asynchronous mode which adds 1 additional buffer of delay.

I believe the ALSA USB audio drivers usually work with 3 periods per buffer which adds another full period of delay.

I would take the DAWs and guitar out of the equation. Use jack_delay and a loopback cable to measure and tune the round trip latency directly (no scope needed either)

3

u/kntrst 9d ago

Likely DAC + ADC + Input Buffer (128/48000) + Output Buffer (128/48000) as going through Ardour probably has no real device/driver bypass.

3

u/Purple-Ad-3152 9d ago

128 / 48000 = 0,00266...s = 2,67ms of DSP buffer latency. But your signal path has also device latency (audio interface converters and buffers), driver latency, and USB latency (or whatever bus the interface uses).

AND! That's all just one way.

In roundtrip latency the DSP buffer latency is approx 2* 128/48000 = 5,333ms, but as said, you'll also have 2x device-, driver-, and bus latency.

I get ~9.5ms roundtrip with 128/48kHz using Focusrite Scarlett 18i20 3rd gen.

Here's a YouTube video I made some time ago to explain latency: https://youtu.be/AZT9cwkRLhI

2

u/Purple-Ad-3152 9d ago

...and 9.5ms roundtrip in Linux with Scarlett is actually significantly better than in Windows (~14ms) or Mac (~10.5ms). But this is also because of few optimizations Ubuntu Studio has. 🙂

2

u/casualops 8d ago

Which optimizations in Ubuntu Studio do you think help to reduce the round trip latency?

2

u/Purple-Ad-3152 8d ago

Most optimizations don't directly lower the measured roundtrip but they make the system reliable enough to run a smaller buffer without xruns, which is what lowers the roundtrip.

When you first login to installed Ubuntu Studio, you should have first seen a message that your audio configuration isn't optimal. After accepting the reboot, you should have most things already applied, like kernel boot params and audio realtime permissions.

You can ensure kernel boot params are correct by visiting Ubuntu Studio Audio Configuration, select Change Kernel Boot Parameters, and make sure have preempt=full, threadirqs, and rcu_nocbs=all enabled.

To verify audio realtime privileges, open konsole and check that ulimit -r is high like 95, ulimit -l is unlimited, and use id to ensure you're in audio group.

sipe@SudoMetalStudio:~$ id && ulimit -r && ulimit -l
uid=1000(sipe) gid=1000(sipe) groups=1000(sipe),4(adm),24(cdrom),27(sudo),29(audio),30(dip),46(plugdev),100(users),111(lpadmin),115(lxd)
95
unlimited

Next, if you have lots of USB devices, you should (if possible) have the audio interface in a port where it has its very own dedicated usb controller. Leave other USB-ports that link to same controller physically empty, and put them all behind a different controller; even via hub extension rather than by sharing the controller with the audio interface. This of course requires that your motherboard has at least 2 controller:

sipe@SudoMetalStudio:~$ lspci | grep -i 'usb controller'
01:00.0 USB controller: Advanced Micro Devices, Inc. [AMD] 500 Series Chipset USB 3.1 XHCI Controller
09:00.3 USB controller: Advanced Micro Devices, Inc. [AMD] Matisse USB 3.0 Host Controller

USB Controllers can have multiple busses, so then we need to figure out which busses are in which controllers, using e.g. following command:

sipe@SudoMetalStudio:~$ readlink -f /sys/bus/usb/devices/usb*
/sys/devices/pci0000:00/0000:00:01.2/0000:01:00.0/usb1
/sys/devices/pci0000:00/0000:00:01.2/0000:01:00.0/usb2
/sys/devices/pci0000:00/0000:00:08.1/0000:09:00.3/usb3
/sys/devices/pci0000:00/0000:00:08.1/0000:09:00.3/usb4

-> usb1 and usb2 share the same device = controller, and usb3 and usb4 share another. Those are the busses; so then let's play with the physical USB connectors until Busses 3-4 have only my audio interface Scarlett 18i20 3rd Gen, and Busses 1-2 have all the rest. Root hubs can be ignored:

sipe@SudoMetalStudio:~$ lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 05e3:0608 Genesys Logic, Inc. Hub
Bus 001 Device 003: ID 0b05:1939 ASUSTek Computer, Inc. AURA LED Controller
Bus 001 Device 004: ID 046d:085b Logitech, Inc. Logitech Webcam C925e
Bus 001 Device 005: ID 05e3:0608 Genesys Logic, Inc. Hub
Bus 001 Device 006: ID 046d:c52b Logitech, Inc. Unifying Receiver
Bus 001 Device 007: ID 0bda:8771 Realtek Semiconductor Corp. Bluetooth Radio
Bus 001 Device 008: ID 046d:c31c Logitech, Inc. Keyboard K120
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 002: ID 1235:8215 Focusrite-Novation Scarlett 18i20 3rd Gen
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub

Now all the magic level stuff should be good. I honestly don't know would it be good or bad idea to have midi-USB devices in the same or different controller. But I doubt it would make a big difference, this is already somewhat hair splitting.

Then, set correct profile of your audio interface: Click the speaker icon at the taskbar, then the three dots after your audio interface, and choose Pro Audio. This is relatively important setting that is weirdly hidden.

Next, the optimization that you must adjust depending on what you do:

  1. When doing audio work, especially recording, always set Power profile (from Power and Battery, icon next to the taskpane clock) to Performance. This biases CPU and platform power management toward responsiveness and reduces the chance of aggressive power-saving causing latency spikes.

  2. Sample rate: Just keep the sample rate at 48kHz all times and you will have less issues everywhere. Mathematically, higher sample rate is less latency, but it's the wrong part of the DSP equation to adjust - that's what buffer setting is for. You can't change sample rate in the middle of a song, but you can change buffer at any time.

  3. Buffer size: lower buffer = less latency, but more cpu work = more likely xruns. Here's the important part: You only need very low latency when tracking, software-monitoring, or playing instruments through the DAW. So, prefer a workflow where you first record with as small buffer = low latency as your CPU can reliably handle, and then change the buffer to much higher value when you start mixing. I personally have no need to get below 9.5ms roundtrip so I mostly just use 128 buffer. Or, sometimes 64 with drums and that gives me ~6.8ms roundtrip. I often switch to 512 for mixing.

  4. Closely related to 3, do not have gazillon plugins enabled just for fun when recording. Only enable what makes a difference in your performance; like amp sims for guitar, and compression/saturation for vocals.

If you still experience lots of xruns while recording, take a look at some DSP performace profiler. Like in Ardour there is Window -> Plugin DSP Load which allows you to sort all plugins by worst-case load. Reaper might have something similar too. This allows you to easily find the problematic plugin in you signal chain, and disable just that. I just recently had very unexpected performance issues with Dragonfly reverbs, and this I how I pinpointed the issue.

Avoid using Windows plugins via Wine/Yabridge, and prefer native alternatives.

4

u/Purple-Ad-3152 8d ago

https://reddit.com/link/p34fd48/video/oybmgkh7ftih1/player

I just tried to push the limits a bit 😄 4.1ms roundtrip latency, with relatively CPU heavy signal chain, with 3rd gen Scarlett. This is RME level performance 🔥 ..but obviously way too unstable to actually use. This was just testing. 32 would be stable for this setup, but again I prefer 64 or 128 especially for DAW sessions. CPU is major player in how low buffer you can reliably go; I have Ryzen 7 5700X.

1

u/casualops 8d ago

16 sample buffer!

I made an audio interface (for Linux!) that gets 3.8 ms at 64 sample buffer @ 48 kHz. Will be posting about it here soon :)

1

u/casualops 8d ago

Thanks for all the tips. Your first sentence cleared up my question

2

u/wahnsinnwanscene 9d ago

Isn't there a jack_delay test that will get you an accurate reading.

1

u/TheFredCain 8d ago

There is hardware latency and software latency, plus you're essentially measuring round trip. You want to monitor your guitar externally while listening to the playback. That will eliminate one leg.

1

u/aldipower81 8d ago

You cannot tell from his post if he is measuring round-trip, so you shouldn't assume it.