08-05-2018, 01:14 AM | #1 |
Human being with feelings
Join Date: Aug 2018
Posts: 20
|
ALSA Underrun Recovery
I am using Reaper 5.94 with RME Babyface Pro and the following settings.
Audio system: ALSA Input channels: 12 Output channels: 2 Sample rate: 48000 Blocksize: 16 Bit depth: 24 Periods: 2 RT priority: 40 Auto-suspend PulseAudio: checked Disable power management if supported: checked If I open a project with a couple of tracks (ReaSynth and Helm) and press Play the current position indicator progresses at a rate of about 0.001 or 0.002 every second for a long time before playing back normally. During this time I hear 2 clicks per second with the channel meters going up and down for each click. If I press Stop, click on the audio statistics bar at the top right of the window, press OK and press Play it returns to normal immediately. Could the ALSA handling be improved so that current position doesn't progress at a snails pace with 2 clicks noises per second and take a long time to recover when there is underrun? Thanks. |
08-05-2018, 02:08 AM | #2 |
Human being with feelings
Join Date: Mar 2012
Posts: 610
|
Your blocksize is incredibly low, that is the latency, try 128 or 256.
Your sound device is USB, sometimes 'periods 3' can work better. You need to experiment a bit. I would start with periods 3 and work the blocksize up till you get no x-runs.
__________________
----------> Debian Linux Distribution = Computing Joy & Freedom <---------- |
08-05-2018, 03:39 AM | #3 |
Human being with feelings
Join Date: Feb 2008
Location: Finland
Posts: 160
|
I've found this interesting - not sure how true the "multiple of 1ms" thing is with Linux USB, but at least I think I have had better results using these. And it would explain the recommendation (which has been around for years) to use 3 periods when using a usb audio device in Linux. I assume it is no different when using Jack or Alsa directly.
https://wiki.linuxaudio.org/wiki/lis..._usb_interface |
08-05-2018, 01:31 PM | #4 | |
Human being with feelings
Join Date: Jul 2006
Posts: 20,859
|
Quote:
__________________
It's time to take a stand against the synthesizer. |
|
08-06-2018, 12:20 AM | #5 |
Human being with feelings
Join Date: Feb 2008
Location: Finland
Posts: 160
|
And another note related to these frame/period settings - just as qjackctl will allow you to type in your own entry (not just the dropdown 128/256/512, etc.), you can type these in in Reper's Alsa settings. For instance, I use ( 192 / 48000 ) * 2 = 8 with my Zoom R16 when using it in Linux.
|
08-06-2018, 03:20 AM | #6 |
Human being with feelings
Join Date: Aug 2018
Posts: 20
|
I find with USB audio on Linux that the round trip latency is a lot more than the block size and Reaper seems to indicate.
For example with 48000 Hz, 24-bit, periods 2 measuring with analog loopback cable. Block size of 48 gives around 240 samples of round trip latency (240 / 48000 = 5 ms). Block size of 16 gives around 110 samples of round trip latency (110 / 48000 = 2.3 ms). I am measuring by going to Preferences > Audio > Recording > Uncheck "Use audio driver reported latency". Then I add a track with a sine wave, remove fade-in at start of clip, loop it back using audio cable to my input and record it on second track. Then I set time units to Samples and measure the number of samples offset between the original and the recorded. That is a lot more latency than I would get if I used ASIO on Windows with 48 samples ASIO buffer size. Perhaps the USB audio stack on Linux could use some improvement for low latency? Last edited by net147; 08-06-2018 at 04:24 AM. |
08-06-2018, 05:03 AM | #7 | |
Human being with feelings
Join Date: Jul 2008
Posts: 43
|
Quote:
ALSA are drivers from ALSA (Linux audio drivers), not written by the manufacturers. So to make a serious comparison, you would only have to use the Windows drivers. Audio optimizations (which ones?) did you do? And hopefully uninstall everything Linux would make as comfortable as Win/MacOs?
__________________
GNU/LINUX@AUDIO ~ /Wiki $ Howto.Info && GNU/Linux Debian installing >> Linux Audio Workstation LAW Last edited by khz; 08-06-2018 at 05:37 AM. |
|
08-06-2018, 05:38 AM | #8 | |
Human being with feelings
Join Date: Aug 2018
Posts: 20
|
Quote:
It seems Linux has around double the round trip latency compared to Windows 10 and macOS High Sierra. Can you suggest any optimizations to reduce the USB audio latency on Linux? Here are my test results comparing Linux, macOS and Windows. All tested with sample rate 48000 Hz, 24-bit. Linux 4.17.11-zen x86_64 (measured in Reaper with loopback cable): Block size, periods, round trip latency 16, 2, 2.1667 16, 3, 3 32, 2, 3.25 32, 3, 4.6875 64, 2, 6.1875 64, 3, 9.0417 128, 2, 12.6667 128, 3, 18.2083 256, 2, 24.25 256, 3, 29.5625 512, 2, 34.75 512, 3, 45.2917 1024, 2, 56.5417 1024, 3, 77.75 2048, 2, 99 2048, 3, 141.6458 macOS High Sierra 10.13.3 CoreAudio, reported from RME driver: Buffer size, round trip latency 32, 3.25 64, 3.92 128, 6.58 256, 11.9 512, 22.6 Windows 10 1803 64-bit, RME ASIO Driver 1.164, measured using Oblique Audio RTL Utility 0.4.1 with loopback cable: Buffer size, round trip latency 48, 3.334 64, 4 96, 5.334 128, 6.667 256, 12 512, 22.667 1024, 44 2048, 86.667 Last edited by net147; 08-11-2018 at 04:31 AM. |
|
08-06-2018, 07:55 AM | #9 | ||
Human being with feelings
Join Date: Jul 2008
Posts: 43
|
RT-Kernel, limits.conf, generally QuickScan, rtirq.
Further optimizations see signature. Quote:
Quote:
__________________
GNU/LINUX@AUDIO ~ /Wiki $ Howto.Info && GNU/Linux Debian installing >> Linux Audio Workstation LAW Last edited by khz; 08-06-2018 at 08:07 AM. |
||
08-10-2018, 03:33 AM | #10 |
Human being with feelings
Join Date: Aug 2007
Location: Luxembourg/Spain
Posts: 1,922
|
I have no clear idea about what you are doing, but alsa underruns normally indicate that you need to use a bigger block size, also try a higher number of periods.
__________________
Reaper for Linux Documentation (WIP). Software: Archlinux/KDE, Fabfilter FX, Komplete 8, Nebula, Schwa/Stillwell, T-racks Max/Amplitube/SVX, etc. Gear: i7-2600k/4700HQ/16GB, RME Multiface/Babyface, Behringer X32, Genelec 8040, etc. :) |
08-10-2018, 07:30 AM | #11 | |
Human being with feelings
Join Date: Aug 2018
Posts: 20
|
Quote:
I am also using Arch. Was thinking of digging into the Linux USB audio driver code to try to reduce USB audio latency. |
|
08-10-2018, 09:21 AM | #12 |
Human being with feelings
Join Date: Aug 2007
Location: Luxembourg/Spain
Posts: 1,922
|
Depends on what I'm doing. Mostly I'm at 1024/2 with my rme multiface. The multiface adds very little extra latency. So the loopback latency comes out at 2 x 1024 + 95 samples. Sometimes I'm at 64/2 which comes out at about 5ms roundtrip
A good utility for testing this is actually reainsert. You can also configure reaper to compensate for the additional hardware latency. Latency with USB is a different story though... As there are no drivers made for Linux we are mostly stuck with usb class 2.0 audio, which kind of sucks.. There is quite a lot of extra latency and it seems to vary a few samples each time you restart and test again. Don't think anything can be done to fix this, but if you can do so, you'll be one of my heroes...! I don't have any values at hand, but if I find some time I could run a few loopback tests.
__________________
Reaper for Linux Documentation (WIP). Software: Archlinux/KDE, Fabfilter FX, Komplete 8, Nebula, Schwa/Stillwell, T-racks Max/Amplitube/SVX, etc. Gear: i7-2600k/4700HQ/16GB, RME Multiface/Babyface, Behringer X32, Genelec 8040, etc. :) |
08-10-2018, 02:58 PM | #13 |
Human being with feelings
Join Date: Aug 2007
Location: Luxembourg/Spain
Posts: 1,922
|
A quick loopback test with my babyface at 44k1.
32/2 64 + 156 ~ 5.0ms 32/3 96 + 199 ~ 6.7ms 64/2 128 + 256 ~ 8.7ms 64/3 192 + 384 ~13.1ms 128/2 256 + 456 ~16.1ms 128/3 384 + 632 ~23.0ms 256/2 512 + 637 ~26.0ms 256/3 768 + 637 ~31.8ms 1024/2 2048 + 663 ~61.5ms 1024/3 3072 + 663 ~84.7ms Kinda sucks..
__________________
Reaper for Linux Documentation (WIP). Software: Archlinux/KDE, Fabfilter FX, Komplete 8, Nebula, Schwa/Stillwell, T-racks Max/Amplitube/SVX, etc. Gear: i7-2600k/4700HQ/16GB, RME Multiface/Babyface, Behringer X32, Genelec 8040, etc. :) |
08-10-2018, 11:34 PM | #14 | |
Human being with feelings
Join Date: Jul 2006
Posts: 20,859
|
Quote:
__________________
It's time to take a stand against the synthesizer. |
|
08-10-2018, 11:54 PM | #15 |
Human being with feelings
Join Date: Aug 2007
Location: Luxembourg/Spain
Posts: 1,922
|
With my RME multiface & PCI controller the roundtrip latency is the one given by buffersize*periods + 95 samples no matter the buffersize.
64/2 - 128 + 95 ~ 5.0ms 1024/2 2048 + 95 ~ 48.6ms AFAIK, firewire is also much lower latency than usb class 2.0 audio.
__________________
Reaper for Linux Documentation (WIP). Software: Archlinux/KDE, Fabfilter FX, Komplete 8, Nebula, Schwa/Stillwell, T-racks Max/Amplitube/SVX, etc. Gear: i7-2600k/4700HQ/16GB, RME Multiface/Babyface, Behringer X32, Genelec 8040, etc. :) |
08-11-2018, 07:22 AM | #16 | |
Human being with feelings
Join Date: Aug 2018
Posts: 20
|
Quote:
I have modified the Linux snd-usb-audio driver to reduce the latency and created an AUR DKMS package: https://aur.archlinux.org/packages/s...wlatency-dkms/ Here are my test results using Reaper v5.941 with ReaInsert (48000 Hz, 24-bit) on my RME Babyface Pro: Before (Linux 4.17.14-zen1-1-zen): 16/2 32 + 80 ~ 2.333 ms 16/3 48 + 109 ~ 3.271 ms 32/2 64 + 129 ~ 4.021 ms 32/3 96 + 166 ~ 5.458 ms 64/2 128 + 205 ~ 6.938 ms 64/3 192 + 242 ~ 9.042 ms 128/2 256 + 352 ~ 12.667 ms 128/3 384 + 496 ~ 18.334 ms 256/2 512 + 650 ~ 24.208 ms 256/3 768 + 650 ~ 29.542 ms 512/2 1024 + 634 ~ 34.542 ms 512/3 1536 + 634 ~ 45.208 ms 1024/2 2048 + 650 ~ 56.208 ms 1024/3 3072 + 650 ~ 77.542 ms 2048/2 4096 + 633 ~ 98.521 ms 2048/3 6144 + 633 ~ 141.188 ms After (Linux 4.17.14-zen1-1-zen with snd-usb-audio-lowlatency-dkms): 16/2 32 + 92 ~ 2.584 ms 16/3 48 + 103 ~ 3.146 ms 32/2 64 + 129 ~ 4.021 ms 32/3 96 + 129 ~ 4.688 ms 64/2 128 + 128 ~ 5.334 ms 64/3 192 + 128 ~ 6.667 ms 128/2 256 + 130 ~ 8.042 ms 128/3 384 + 130 ~ 10.708 ms 256/2 512 + 128 ~ 13.334 ms 256/3 768 + 121 ~ 18.521 ms 512/2 1024 + 130 ~ 24.042 ms 512/3 1536 + 124 ~ 34.584 ms 1024/2 2048 + 127 ~ 45.313 ms 1024/3 3072 + 127 ~ 66.646 ms 2048/2 4096 + 129 ~ 88.021 ms 2048/3 6144 + 129 ~ 130.688 ms Last edited by net147; 08-11-2018 at 07:23 AM. Reason: Add hardware interface name |
|
08-11-2018, 08:03 AM | #17 |
Human being with feelings
Join Date: Aug 2007
Location: Luxembourg/Spain
Posts: 1,922
|
Awesome! That's a really impressive latency reuction!
What was the problem/improvement? I have to try that out when I find some time (vacation).
__________________
Reaper for Linux Documentation (WIP). Software: Archlinux/KDE, Fabfilter FX, Komplete 8, Nebula, Schwa/Stillwell, T-racks Max/Amplitube/SVX, etc. Gear: i7-2600k/4700HQ/16GB, RME Multiface/Babyface, Behringer X32, Genelec 8040, etc. :) |
08-11-2018, 08:24 AM | #18 | |
Human being with feelings
Join Date: Aug 2018
Posts: 20
|
Quote:
ALSA in general seems to be adding some additional buffering for USB audio: http://jack-audio.10948.n7.nabble.co...es-td9071.html So I did something similar to setting nrpacks=1 but since that option doesn't exist anymore I have to modify the code. |
|
08-11-2018, 09:18 AM | #19 |
Human being with feelings
Join Date: Aug 2018
Posts: 20
|
I did some more tweaking. Here are the results.
After (Linux 4.17.14-zen1-1-zen with snd-usb-audio-lowlatency-dkms r2): 16/2 32 + 64 ~ 2.000 ms 16/3 48 + 64 ~ 2.334 ms 32/2 64 + 65 ~ 2.688 ms 32/3 96 + 66 ~ 3.375 ms 64/2 128 + 63 ~ 3.979 ms 64/3 192 + 45 ~ 4.938 ms 128/2 256 + 60 ~ 6.583 ms 128/3 384 + 59 ~ 9.229 ms 256/2 512 + 57 ~ 11.854 ms 256/3 768 + 57 ~ 17.188 ms 512/2 1024 + 60 ~ 22.583 ms 512/3 1536 + 60 ~ 33.250 ms 1024/2 2048 + 63 ~ 43.979 ms 1024/3 3072 + 63 ~ 65.313 ms 2048/2 4096 + 66 ~ 86.708 ms 2048/3 6144 + 65 ~ 129.354 ms |
08-11-2018, 09:29 AM | #20 |
Human being with feelings
Join Date: Aug 2018
Posts: 20
|
Here are also the Windows 10 RME Driver 1.099 measurements for comparison:
48/2 96 + 63 ~ 3.313 ms 64/2 128 + 63 ~ 3.979 ms 96/2 192 + 63 ~ 5.313 ms 128/2 256 + 63 ~ 6.646 ms 256/2 512 + 63 ~ 11.979 ms 512/2 1024 + 63 ~ 22.646 ms 1024/2 2048 + 63 ~ 43.979 ms 2048/2 4096 + 63 ~ 86.646 ms Besides the additional delay jitter in the Linux results, they are pretty close. |
08-11-2018, 11:28 AM | #21 |
Human being with feelings
Join Date: Jul 2006
Posts: 20,859
|
Very cool net147.
Any specifics on the jitter?
__________________
It's time to take a stand against the synthesizer. |
08-12-2018, 05:42 AM | #22 |
Human being with feelings
Join Date: Aug 2018
Posts: 20
|
Don't have any idea about the jitter yet. Here are the results on macOS High Sierra 10.13.6.
Class Compliant Mode (Apple Driver): 16/2 32 + 205 ~ 4.938 ms 32/2 64 + 205 ~ 5.604 ms 64/2 128 + 205 ~ 6.938 ms 128/2 256 + 205 ~ 9.604 ms 256/2 512 + 205 ~ 14.938 ms 512/2 1024 + 205 ~ 25.604 ms 1024/2 2048 + 205 ~ 46.938 ms 2048/2 4096 + 205 ~ 89.604 ms PC Mode (RME Driver v3.08): 16/2 32 + 59 ~ 1.896 ms 32/2 64 + 59 ~ 2.563 ms 64/2 128 + 59 ~ 3.896 ms 128/2 256 + 59 ~ 6.563 ms 256/2 512 + 59 ~ 11.596 ms 512/2 1024 + 59 ~ 22.563 ms 1024/2 2048 + 59 ~ 43.896 ms 2048/2 4096 + 59 ~ 86.563 ms |
08-12-2018, 10:38 AM | #23 |
Human being with feelings
Join Date: Aug 2007
Location: Luxembourg/Spain
Posts: 1,922
|
FWIW, I build a kernel patched with: https://aur.archlinux.org/cgit/aur.g...owlatency-dkms
I just got xruns with the babyface, but will most certainly try it again. Unfortunately no time right now, spent the last few days moving our studio/practice room. :S But happily the new place is looking good too, much smaller but still cozy! Carpets fitted perfectly in with the couch and the tables, good feng shui
__________________
Reaper for Linux Documentation (WIP). Software: Archlinux/KDE, Fabfilter FX, Komplete 8, Nebula, Schwa/Stillwell, T-racks Max/Amplitube/SVX, etc. Gear: i7-2600k/4700HQ/16GB, RME Multiface/Babyface, Behringer X32, Genelec 8040, etc. :) |
08-12-2018, 11:15 AM | #24 |
Human being with feelings
Join Date: Nov 2013
Posts: 2,799
|
Re-installing the 'everything here, Linux next..
Anyway.. just a little something for switching to headphones and speakers if anyone did not know, heck I did not. https://www.forum.rme-audio.de/viewtopic.php?id=24447
__________________
|
08-12-2018, 11:26 AM | #25 | |
Human being with feelings
Join Date: Jul 2006
Posts: 20,859
|
Quote:
It would be great to have under 5 ms usable roundtrip latency for a usb interface. Once upon a time I had that in xp and even lower with a pci card.
__________________
It's time to take a stand against the synthesizer. |
|
08-12-2018, 04:22 PM | #26 | |
Human being with feelings
Join Date: Mar 2017
Posts: 861
|
Quote:
defying the snows of December and January. Hope the new setup rocks the house, and makes the neighbors take dance classes! Cheers |
|
08-13-2018, 12:57 AM | #27 |
Human being with feelings
Join Date: Aug 2007
Location: Luxembourg/Spain
Posts: 1,922
|
Thanks! No neighbours at all..!
__________________
Reaper for Linux Documentation (WIP). Software: Archlinux/KDE, Fabfilter FX, Komplete 8, Nebula, Schwa/Stillwell, T-racks Max/Amplitube/SVX, etc. Gear: i7-2600k/4700HQ/16GB, RME Multiface/Babyface, Behringer X32, Genelec 8040, etc. :) |
08-13-2018, 08:16 AM | #28 | |
Human being with feelings
Join Date: Aug 2018
Posts: 20
|
Quote:
Setting SYNC_URBS to 1 in r2 caused some instability for me so I have increased MAX_URBS/SYNC_URBS to 2 for r3. It increased the additional latency a little (about 8 samples). If you have audio glitches you can increase it to a higher value and test again. SYNC_URBS must be <= MAX_URBS. If you want to build the AUR package for a different kernel version: 1. Replace the kernel version numbers in the PKGBUILD with the version you are using 2. updpkgsums 3. makepkg -Cis I find it quicker to use DKMS than to rebuild the entire kernel. Last edited by net147; 08-14-2018 at 04:29 AM. |
|
08-13-2018, 10:05 AM | #29 |
Human being with feelings
Join Date: Aug 2007
Location: Luxembourg/Spain
Posts: 1,922
|
Undoubtedly
__________________
Reaper for Linux Documentation (WIP). Software: Archlinux/KDE, Fabfilter FX, Komplete 8, Nebula, Schwa/Stillwell, T-racks Max/Amplitube/SVX, etc. Gear: i7-2600k/4700HQ/16GB, RME Multiface/Babyface, Behringer X32, Genelec 8040, etc. :) |
08-13-2018, 02:14 PM | #30 | |
Human being with feelings
Join Date: Nov 2011
Posts: 973
|
Quote:
|
|
08-14-2018, 08:29 AM | #31 |
Human being with feelings
Join Date: Jul 2006
Posts: 20,859
|
Thanks Jack and net147. ^ Gives me some stuff to read up on.
__________________
It's time to take a stand against the synthesizer. |
Thread Tools | |
Display Modes | |
|
|