Mads Kjeldgaard

June 29, 2021

These notes are for setting up a new audio system on Arch Linux. It is assumed that you have an AUR helper like yay or paru installed (I use the latter here but exchange with yay if you use that). This isn’t a tutorial but just a collection of notes to help myself and perhaps others setup a high performance audio system in Arch Linux. The Arch Linux maintainers have done an amazing job in making it a good operating system for this kind of work by allowing users to easily setup the system with the right privileges and install the needed software.

Install audio tools

This will install all the audio tools I need on any system:

paru -S reaper-bin sws supercollider sc3-plugins jack2 mpv sox qjackctl pulseaudio-bluetooth pulseaudio-jack pulseaudio njconnect flac cadence alsa-firmware alsa-plugins alsa-utils realtimeconfigquickscan-git

And then to install all SuperCollider plugins on the AUR: paru -S supercollider-plugins

System checking tools

I use the script realTimeAudioConfigQuickScan to check how well I’m doing. By running it you can quickly see what needs to be optimized.

install from AUR:

paru -S realtimeconfigquickscan-git

If you want to go even deeper, there is a script called realtime-suggestions, also available on the AUR but I’ve not detected any performance differences when messing with the suggestions from that one.

Realtime privileges

Arch has a nice package will allow users in the realtime group to have realtime privileges, including unlocking memory and setting realtime priorities very high.

It’s easily setup:

sudo pacman -S realtime-privileges
sudo groupadd realtime
sudo usermod -a -G realtime $USER

Reduce swappiness

Add vm.swappiness=10 to /etc/sysctl.conf

sudo echo "vm.swappiness=10" >> /etc/sysctl.conf

CPU governor

This is by far the audio system improvement that makes the biggest difference on my systems. By setting your CPU governors to “performance” (instead of “powersave”) the performance stability (and energy usage) of your CPU increases. In practice, this often doubles the performance of my machines so it’s definately worth doing. The Arch wiki has a whole page dedicated to this, but I prefer using this approach using tuned.

paru -S tuned
systemctl enable --now tuned.service
tuned-adm profile latency-performance

You can setup a udev rule to automatically switch between power save mode and performance when plugging power into your laptop.

Create the file /etc/udev/rules.d/99-powerprofile_switch.rules and add this (thanks Kenneth Flak):

# Rule for when switching to battery
ACTION=="change", SUBSYSTEM=="power_supply", ATTR{type}=="Mains", ATTR{online}=="0" RUN+="/usr/bin/tuned-adm profile laptop-battery-powersave"
# Rule for when switching to AC
ACTION=="change", SUBSYSTEM=="power_supply", ATTR{type}=="Mains", ATTR{online}=="1" RUN+="/usr/bin/tuned-adm profile latency-performance"

Niklas Adam also recommends these aliases if you want to switch between the performance profiles dynamically. Add them to your .zshrc or whatever:

alias cpu-max='tuned-adm profile latency-performance'
alias cpu-balanced='tuned-adm profile balanced'
alias cpu-min='tuned-adm profile laptop-battery-powersave'

Windows VST Plugins

I use a lot of Windows VST plugins in my audio workflow. I use wine and yabridge to bridge them in Linux.

First install Wine. I use Wine TKG which has some performance patches: Installation instructions here. After installing that, you can run paru -S yabridge to install the vst bridge itself (more info here).

Realtime kernel

The default kernel on Arch is pretty good for audio performance. But you might be able to squeeze a bit more performance out of your system by installing realtime kernels.

To install prebuilt realtime kernels easily you can add this section:

[dvzrv]
Server = https://pkgbuild.com/~dvzrv/repo/$arch

to your pacman configuration: /etc/pacman.conf

Then run

paru -Syyu linux-rt linux-rt-headers

And update your grub bootloader to include the new kernel when booting. Next time you reboot your computer you are able to choose it from the list of kernels in grub: sudo grub-mkconfig -o /boot/grub/grub.cfg

Tags: