View Single Post
Old 07-15-2017, 12:28 PM   #39
Jack Winter
Human being with feelings
 
Jack Winter's Avatar
 
Join Date: Aug 2007
Location: Luxembourg/Spain
Posts: 1,922
Default

Quote:
Originally Posted by MusicMan74 View Post
Is installing a low-latency kernel and configuring an audio group 'required' as described by Ted Felix here? http://tedfelix.com/linux/linux-midi...latency-kernel
AFAIK, nothing of that is required for reaper to run, but one can take a few steps to get lower latency without audio dropouts.

I'll try to explain in a simplified manner, but I'll probably ramble and get long winded. I might edit this post again later to make it more comprehensible

Linux low latency audio is based on POSIX real time threads. A thread of a higher priority will preempt threads of lower priority and will run until it's finished. The idea is to order the priority of the threads, so that the soundcard IRQ has the highest, then the audio threads, and below that the threads dealing with hardware like the screen, disk io, etc, and lowest of all the other programs running on the computer.

Kernels:

Kernels can be of several different types types of scheduling models, the ones we are interested in are capable of preempting a running thread to run one of a higher priority. If the kernel can't do this, you can still run reaper but you will have to use bigger buffers and you risk dropouts.

The kernels of interest are referred to as lowlatency and realtime. A lowlatency kernel can preempt threads. The realtime kernel in addition tries to maximize the surface of the kernel itself that can be preempted, so it can achieve a lower kernel scheduling latency (the maximum time it takes the kernel to start running a thread).

If you have a deadline of 1.4ms, and it takes the kernel 10ms to schedule your audio, you get a dropout.

The only relevant difference is that the realtime kernel can achieve a lower scheduling latency than the lowlatency kernel.

To see what kernel you have, if the output of "uname -a" contains "PREEMPT" then it's a lowlatency kernel, and if it contains "PREEMPT RT" then it's a realtime kernel.

Computer hardware can cause problems in scheduling, as can software drivers. Things like NMI/SMI hardware interrupts or wifi, bt, video, or other software drivers.

User privileges:

To be able to schedule threads real time, the user running reaper (or a group he belongs to) has to be able to use "rtprio". The max value is 99, but there are some kernel threads running there, so I'd suggest setting rtprio to 98.

It would also be bad for low latency if the system discarded or swapped RAM containing reaper/plugin code/data to disk, thus the reason to give the user the capability to set "memlock". My suggestion is to set it to unlimited, but you can set a smaller size if you want to.

Normally there are very few programs using memlock on linux, basically only your audio programs, so it seems wise to make sure that it all stays in RAM, but if you go too far you can swap out the entire OS (user space) and might have to do a hard reset.

To check what your user capabilities are run "ulimit -a".

Soundcard IRQ priorities:

The realtime kernel exports most of the interrupt handlers to run as threads in user space, as does the lowlatency kernel when booted with the "threadirq" boot flag.

The IRQ handlers will run at priority 50, with some kernel house keeping threads at 99 and some software timers at 1.

Setting the thread handling the soundcard or the usb hub IRQ to a high priority will make sure that it runs before most of the other interrupt handlers.

Reccomended priorities:

99 kernel threads
95 sound card interrupt handler
80 jackd/or reaper (ALSA)
50 hardware interrupt handlers
1 software timers
0 most threads

This pretty much covers the configuration of low latency audio on Linux. Hope it's useful and that I didn't ramble too much
__________________
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. :)

Last edited by Jack Winter; 07-15-2017 at 12:53 PM.
Jack Winter is offline   Reply With Quote