The Open (Guitar) Audio Effects Processor
Install the alarm version for raspberrypi4 on your Rpi4 and then follow the instructions below.
You will need to install the following packages:
base-devel
git
sudo
htop
jack2
rtirq
realtime-privileges
stress
tmux
Add the alarm
user to the wheel group. Also change the root
user's password to something of your liking.
We need to apply two patches to the stock linux-raspberrypi4 kernel:
- RT-PREEMPT (full)
- Low-Latency USB
We have prepared a PKGBUILD that has the required patches. It's found in the src/linux-raspberrypi4
folder. It should be fairly easy to build this kernel with makepkg
. Read up on the makepkg documentation if you run into trouble, but in principle it should be a three step process to install and boot into this kernel:
makepkg -s
sudo pacman -U linux-raspberrypi4-4.19.69-2-armv7h.pkg.tar.xz
sudo reboot
While the makepkg
command is running it will ask you for newly added configuration settings. Make sure to set the kernel's preemption model to RT-PREEMPT (full)
.
Once rebooted checkout the output of e.g. htop
(install it if necessary). Hit F6
, select PRIORITY
and you should now see some threads called irq/53-PCIe PME
, and similar. These are the kernel IRQ handler threads which we want from our RT-PREEMPT system and which we will tune a little in the next step. But before that create a file calle /etc/modprobe.d/00-snd-usb.conf
with the following content:
options snd-usb-audio max_packs=4 max_packs_hs=4 max_urbs=12 sync_urbs=4 max_queue=18
This tunes the parameters introduced by the Low-Latency USB patch. Either unload and reload the snd-usb-audio module (using rmmod
and modprobe
or just reboot once more..
Edit /etc/rtirq.conf
to look like this:
RTIRQ_NAME_LIST="usb i8042" RTIRQ_PRIO_HIGH=90 RTIRQ_PRIO_DECR=5 RTIRQ_PRIO_LOW=51 RTIRQ_RESET_ALL=0 RTIRQ_NON_THREADED="rtc snd"
And enable the service with
sudo systemctl enable rtirq
and either reboot or start the service now (with systemctl start
). Check with htop
whether the irq/54-xhci_hcd
kernel thread has priority -91
. If so rtirq
is doing its thing correctly.
We want to disable all CPU frequency scaling to make the system behave more predictably. Edit the file /etc/rc.local
and add into it:
for n in 0 1 2 3; do echo performance > /sys/devices/system/cpu/cpu"$n"/cpufreq/scaling_governor; done
Make sure it has a #!/bin/bash
shebang at the top of the file and that it is executable. Then enable the rc-local
service:
sudo systemctl enable rc-local
and either reboot or start it with systemctl start...
.
Add the alarm
user to the realtime
group using
sudo gpasswd -a alarm realtime
And relogin that user.
Now it's time to plugin your USB audio class 2.0 device (for example the Focusrite 2i2 2nd gen, or Tascam 2x2, etc). It should appear in /proc/asound/cards
$ cat /proc/asound/cards 0 [USB ]: USB-Audio - Scarlett 2i2 USB Focusrite Scarlett 2i2 USB at usb-0000:01:00.0-1.2, high speed
Run
jackd -R -P 80 -S -d alsa -d hw:USB -p 64 -n 2
It should startup fine (some warnings about libFFADO are to be ignored, they do not matter). Now open another terminal on the Rpi4 and run
stress -c 4
Open yet another terminal and run
sudo watch /opt/vc/bin/vcgencmd measure_temp
Now leave this running for a couple of hours. Make sure that in the jackd
terminal no XRUNs are reported. Also check the terminal running vcgencmd
from time to time to check whether your Rpi4 has adequate cooling. Ideally you don't want the temperature maxing out around 60 degrees to have some headroom for really hot summer days (at 80 degrees the cpu gets throttled ruining our RT-performance).
Once you are sufficiently satisfied that the system is stable, kill all three processes.
We want our effects processor to start up once the device is powered. And we also want to run everything as the alarm
user. To start long running services and processes we can make use of systemd
's user service handling. To enable user services started independent of logging in manually we have to enable lingering
:
sudo loginctl enable-linger alarm
Some versions of systemd
shipped with Alarm are buggy and you have to run the following command manually:
sudo mkdir -p /var/lib/systemd/linger sudo touch /var/lib/systemd/linger/alarm
- Start
jackd
as lingering user service once the USB soundcard connects - Start
mod-host
- Start
jack-led-peak
instances - Configure
wifi0
in AP/managed combined mode so one can use smartphone to connec to... - Start web service to control
mod-host