Latency tuning

Optimize your system for ultimate performance.

Moderators: MattKingUSA, khz

Post Reply
Dr.Axelbauer
Established Member
Posts: 5
Joined: Mon Apr 25, 2022 10:02 pm
Has thanked: 2 times

Latency tuning

Post by Dr.Axelbauer »

Hi there!
I think similar questions must have been asked dozen of times. But I am simply searching for some profound estimation on the topic.

Systemsetup:
Operating System: Ubuntu Studio 21.10
KDE Plasma Version: 5.22.5
KDE Frameworks Version: 5.86.0
Qt Version: 5.15.2
Kernel Version: 5.13.0-40-lowlatency (64-bit)
Graphics Platform: X11
Processors: 8 × Intel® Core™ i7-8565U CPU @ 1.80GHz
Memory: 15.3 GiB of RAM
Graphics Processor: Mesa Intel® UHD Graphics 620

Usb Interface:
Model: "Roland EDIROL UA-25EX (Advanced mode)"

I am running jack with Intel Boost "Off" and CPU Governor "Performance".
My Jack settings:
Backend: alsa
Sample Rate: 48000
Buffer Size: 256
Periods: 2

This setting runs smoothly without xruns and I have already recorded some metal stuff with Tonelib GFX Amp Modeller routed into Ardour. I have a LUA Script which is deactivating all the plugins when entering recording state in Ardour. All this works like a charm!

Now the question:
When I play the guitar buffer size 128 feels perfect for me. 256 feels a little bit delayed in the end. I get used to the small amount of latency but actually, my perfect feeling while recording is with 128. Problem is that I get dozens of xruns when trying to record something in ardour with 128. ardour does not even start to record but hangs. Tonelib GFx alone works with 128 but not in combination with ardour.
So is my system already exhausted with 256, or is there any chance i can get lower latency out of my box/hardware?
I have already searched around for a while, but I wanted to ask this question some folks which are known to have expertise in this field ;)

Thanks in advance!
merlyn
Established Member
Posts: 1392
Joined: Thu Oct 11, 2018 4:13 pm
Has thanked: 168 times
Been thanked: 247 times

Re: Latency tuning

Post by merlyn »

It's possible you may be able to get a lower latency. First you could check your config with this script :

https://codeberg.org/rtcqs/rtcqs

For a USB interface the received wisdom is to use 3 periods. 3 periods at 128 gives a lower latency than 2 at 256. It's also possible to shave one period off of the round trip latency by using JACK in 'server synchronous' mode. In QjackCtl there's a tick box 'Use server synchronous mode'.
haast
Established Member
Posts: 16
Joined: Sat Oct 03, 2020 3:13 pm
Has thanked: 8 times
Been thanked: 2 times

Re: Latency tuning

Post by haast »

Since kernel 5.14 latency for USB Audio devices is much better than before. I can record audio in Ardour 6.9 with a non-rt 5.15 kernel in Manjaro KDE 5.24 without xruns and playback of +5 channels with a Behringer UMC202HD interface on a i8300 4 core 16G desktop. Jackd settings: /usr/bin/jackd -S -dalsa -dhw:U192k -r48000 -p64 -n3 -Xseq -I82 -O82
Dr.Axelbauer
Established Member
Posts: 5
Joined: Mon Apr 25, 2022 10:02 pm
Has thanked: 2 times

Re: Latency tuning

Post by Dr.Axelbauer »

Thanks a lot for the hints!
I made some changes due to the scripts output and it seems, that it has changed for the better :) All paramters are met and okay within the scipt except the filesystem part.

Within smaller projects (let's say 16 tracks and only a few plugins in ardour) it is running with 0 xruns with 3 periods at 128.
Tonelib alone is never the problem i think it would also work with lower frames...

Within bigger projects (many plugins, tonelib gfx as a plugin on the DI tracks, drumgizmo for the drums,...) although the lua script is deactivating the plugins while recording 3 periods at 128 produces many xruns. 3 periods at 150 seems to be the limit (about 5 xruns wihtin 20 sec of recording). DSP is jumping heavily and I would say average at 80% sometimes at 99%.

The only changes i have not made is the tuning of my SSD. Due to the fact that the reference article on ArchLinux is 2011 I am unsure if this is the right place to play around in 2022. (https://wiki.linuxaudio.org/wiki/system ... ilesystems)
I only made the noatime change to /etc/fstab that's all.
Here is the output of the rtcqs script:

Code: Select all

Filesystems
===========
[ OK ] The following mounts can be used for audio purposes: /
[ WARNING ] The following mounts should be avoided for audio purposes: /run/user/1000/doc. See also https://wiki.linuxaudio.org/wiki/system_configuration#filesystems
Dr.Axelbauer
Established Member
Posts: 5
Joined: Mon Apr 25, 2022 10:02 pm
Has thanked: 2 times

Re: Latency tuning

Post by Dr.Axelbauer »

haast wrote: Tue Apr 26, 2022 6:53 pm Since kernel 5.14 latency for USB Audio devices is much better than before. I can record audio in Ardour 6.9 with a non-rt 5.15 kernel in Manjaro KDE 5.24 without xruns and playback of +5 channels with a Behringer UMC202HD interface on a i8300 4 core 16G desktop. Jackd settings: /usr/bin/jackd -S -dalsa -dhw:U192k -r48000 -p64 -n3 -Xseq -I82 -O82
Oha! It seems, that nice work had been done in the background by the kernel devs!

---- Upgraded to 22.04 with kernel 5.15. and truly the issues are gone! 3 periods 128 works great without flaws and xruns! Also within bigger projects and without the lua script deactivating the plugins – a nice playback is also possible! Switching on the monitor on the Edirol while listening to the output of the box (so that both signals are hearable in the headphones) gives no "delay" feeling and there is no perceivable (at least for me) "delay" between the to signals!
DSP Load has also been reduced to about 60% with plugins activated and about 30% (!!!) with plugins deactivated.

– It simply rocks! \m/ Or as James Hetfield would say: "Uhhhhhh Yeahhhhh!" Thx for the suggestions here!
merlyn
Established Member
Posts: 1392
Joined: Thu Oct 11, 2018 4:13 pm
Has thanked: 168 times
Been thanked: 247 times

Re: Latency tuning

Post by merlyn »

Dr.Axelbauer wrote: Tue Apr 26, 2022 10:19 pmHere is the output of the rtcqs script:

Code: Select all

Filesystems
===========
[ OK ] The following mounts can be used for audio purposes: /
[ WARNING ] The following mounts should be avoided for audio purposes: /run/user/1000/doc. See also https://wiki.linuxaudio.org/wiki/system_configuration#filesystems
I don't think that's a problem. It is saying / is good for audio, so you're sorted. I would think the wiki has spinning HDDs in mind when suggesting those optimisations. Ardour displays a message box when there is a problem with the disk -- something like "Your disk is too slow to keep up with Ardour". With SSDs I don't think there will be a problem.

I'm glad to hear you've now got a setup you're pleased with!
User avatar
scott.thomason
Established Member
Posts: 120
Joined: Fri Apr 01, 2022 2:54 am
Has thanked: 16 times
Been thanked: 27 times
Contact:

Re: Latency tuning

Post by scott.thomason »

Dr.Axelbauer wrote: Mon Apr 25, 2022 10:19 pm When I play the guitar buffer size 128 feels perfect for me. 256 feels a little bit delayed in the end. I get used to the small amount of latency but actually, my perfect feeling while recording is with 128. Problem is that I get dozens of xruns when trying to record something in ardour with 128. ardour does not even start to record but hangs. Tonelib GFx alone works with 128 but not in combination with ardour.
So is my system already exhausted with 256, or is there any chance i can get lower latency out of my box/hardware?
Try the Liquorix kernel, it's tuned for low-latency applications, moreso than the stock Ubuntu lowlatency kernel. Also, here's a post I made a few weeks ago that has some useful resources linked: How I reduced my Jack latency from 85ms to 2.7ms, which is actually now down to 1.3ms. When I tested with a physical loopback cable to measure the audio interface, that was around 8ms real-life.
---scott

LinkedIn
HarryR
Established Member
Posts: 30
Joined: Thu Dec 22, 2016 2:10 pm
Been thanked: 2 times

Re: Latency tuning

Post by HarryR »

Dr.Axelbauer wrote: Wed Apr 27, 2022 8:36 am ---- Upgraded to 22.04 with kernel 5.15. and truly the issues are gone! 3 periods 128 works great without flaws and xruns! Also within bigger projects and without the lua script deactivating the plugins – a nice playback is also possible! Switching on the monitor on the Edirol while listening to the output of the box (so that both signals are hearable in the headphones) gives no "delay" feeling and there is no perceivable (at least for me) "delay" between the to signals!
DSP Load has also been reduced to about 60% with plugins activated and about 30% (!!!) with plugins deactivated.

– It simply rocks! \m/ Or as James Hetfield would say: "Uhhhhhh Yeahhhhh!" Thx for the suggestions here!
Could you please publish your lua-script, so more people can benefit from it ?
greets
Harry
kirjis
Established Member
Posts: 31
Joined: Mon Sep 07, 2020 8:24 am
Has thanked: 4 times

Re: Latency tuning

Post by kirjis »

Here is one thing that really helped me with low latency: shutting down Firefox, and any other web browser, including stuff that uses Electron, such as the fat Matrix client Element. But the main culprit seems to be Firefox, which spawns high priority realtime audio threads. Please see this: https://discussion.fedoraproject.org/t/ ... ency/32221

I can use 64/48000 without any xruns for MIDI keyboard playing (with 3 periods for USB, I use Presonus and it's connected through a usb3 hub even), for guitar I feel it's still a bit too much latency so I usually play with hardware monitoring (but that means hearing only clean sound while recording).

Bandcamp: https://kum1k4k1.bandcamp.com/ | Mastodon: @kirjis@polyglot.city
Reaper - Melda plugins - EndeavourOS | Clevo NH77DBQ 17" laptop - Presonus 2|6 - Focal Alpha 80 - Quad ERA-1

Post Reply