Raspberry pi 3 optimization for Audio / Pure Data?

I’ve read on this forum that some people use Raspberry Pi for audio. I’m trying to configure a Pi 3 version B for using it as a multi-track recorder, audio matrix and multiple midi operations.

It’s connected to an Expert Sleepers ES-8 audio interface and therefore can receive 12 audio channels and send to 16 channels.

I’ve successfully compiled and installed Purr Data for Raspbian Stretch but I have doubts regarding the audio setup.

To test the installation, I route an audio signal from the ES-8 to one of its ADAT outputs. I managed to have a fairly low latency (64 at 48000) with a few rare glitches, but this without processing the signal, and only if I run PD without gui.

sudo pd-l2ork -rt -alsa -audiodev 1 -r 48000 -audiobuf 64 -channels 12 -stderr -nogui /home/pi/Desktop/audio_test.pd

With the gui, it’s impossible to get a clean audio output, no matter which buffer size I select.

That’s why I’m wondering if there’s an specific optimization I should do on this Raspberry Pi.

Do you have any recommendation please ?


Avoid using the GUI.

Thank you. I will avoid that, yes. Some blogs mention using an RT kernel but that’s obscure… is it recommended with PD ?

It will improve latency but it shouldn’t impact CPU usage (which I suspect is your problem when using the GUI).

1 Like

Thanks for your reply. I understand. I will patch on my main computer and send the files to the Pi and avoid GUI. It was easier to use the Pi directly because I couldn’t connect the Monome to the Mac but this issue should be solved now with the latest serialosc. I hope I don’t encounter too many audio dropouts with more complex patches than ADC to DAC.

1 Like

You can totally disable the hardware you are not using like the HDMI, bluetooth and wifi. I found it helps.

If you can split your audio processing up, you can use multiple instance of pd or use pd~ to spread the load over the multiple cpu cores.


Ah great, it’s good to know I can disable some functionalities, thanks! I need Bluetooth for midi over Bluetooth and WiFi for ssh and OSC communication between pi’s etc but I could disable HDMI, does it consume some ressources even if the Pi is headless and configured to start without desktop ? I will investigate regarding the quad cores and multiple instances as you suggest, i don’t know yet how to set this up. At the moment, I simply “blacklisted” the onboard audio output, but should I completely disable it as well ? Also, should I use ALSA or something else ? A Jack server ? Sorry for all these noob questions, I’m new to Linux and Raspberry, it took me a few days to learn, set a starting script, connect midi with command lines etc, that’s also why I’m asking about audio optimization :wink:

Blacklisting should work. I think you can diasable it with the overlay dt stuff too.

There is an tecnical article about it here https://www.raspberrypi.org/documentation/configuration/device-tree.md

I don’t have any metrics on performance so I’m just going by “the vibe”.

I’m using jack server on mine so I can use netjack to route audio over the network to a windows machine. Jack sits on top of alsa. It can be a pain to work with.

1 Like

Excellent. Thanks again. I will test this audio matrix tomorrow with the Monome, without GUI and keeping in mind these optimization tricks. At the moment, the latency with a Pi3 and an Es-8 is much better than with an IPad … so It’s worth experimenting again and again until I find the correct settings :slight_smile:

1 Like

I realize this thread is 3 years old. Nordseele, if you are still in this thread, I’d love to hear about what you’ve uncovered in the intervening time.

I have an ES-8, a Raspberry Pi 3, and a 2.8" touchscreen. I was hoping to have on-screen controls. Did you wind up needing to run without gui? Have you tried a RPi4?

1 Like

I use both a RPi 3 and a RPi 3B all the time for audio work - glitch free w/processing and recording.

It requires relatively little work to make it performant. The easiest way is to just use Blokas’ Patchbox OS - Raspberry Pi OS for Audio Projects on it. This is directly derived from the standard Raspberry PI OS, with some small tweaks and the right packages. It works great out of the box, even if you don’t make use of any of it’s “modules” for audio work.

If you already have an OS on your RPi and don’t want to switch, then the most important thing you can do is set the CPU governor:

& echo performance | sudo tee /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor
# the Pi has only one governor, changing one changes them all

Another thing to check for is that your programs are running at the same sample rate as the native hardware you’re using. ALSA on Linux will offer multiple sample rates even when the hardware doesn’t – and does the sample rate conversion in software, in the kernel. This is very bad for performance.

Turns out just running X itself isn’t all that expensive. (See benchmarks I did.) What costs is what UI Pd (or other programs) might be doing. Pd isn’t really all that bad, and I’ve run with the Pd UI up for my Pd patch - on X, over VNC – and can still run audio effects, delays, etc… on 48kHz stereo with no hiccups.


Oh yeah I remember this project, I used this Monome 256 + ES-8 config for a few weeks. I still have a few notes on how to compile PdL2ork but that’s very likely out of date.

@mzero’s recommandation is surely the best you can follow here :slight_smile: install Patchbox OS, it has everything you need.

If I had to use the re-create the same kind of RPI based headless / matrix mixer setup today, I’d probably use a combination of Supercollider + OSC instead of Pure Data.

In addition to setting the CPU governor like @mzero suggests, I also have mount -o remount,size=128M /dev/shm in my current performance-hacks.sh – not sure what it does but things seem to be working fine.

The command remounting /dev/shm has only the effect of limiting the maximum amount of data that can be stored in the /dev/shm file system. Since tmpfs (the underlying file system type) only uses memory as it needs, and your system is probably using none of it (run df -h and look for the /dev/shm line to see) - this command has no effect.

1 Like

Thanks for the help folks!

I removed all my gop oscilloscope arrays and it ran much better, but I do wish I could have some oscilloscopes running while also outputting audio.

EDIT: Another question. I haven’t tried setting the governor yet. Maybe this will answer itself. Do I need to set the governor on each boot, or will echo set a preference that gets loaded every time?

You need to do it on each boot, unless you set up a script to do. Personally, I just put it in my script that launches Pd (or SuperCollider).

I just did that and am testing it now! Having trouble with the script. Trying to execute puredata && echo performance… But the second part doesn’t work. Can I do two Exec statements in an autostart .desktop file?

I realized I can’t Exec two programs. So I’m working on launching a shell script. Still no luck. Might have to come back to this.

I’ve tried a few things but nothing quite works. Here’s my script:


echo performance | sudo tee /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor && puredata -audiodev 5 -open ~/Documents/Pd/patches/XYScope-large/XYscope.pd &

I tried a few things and ended up just launching Pd from the autolaunch .desktop file. I made other changes that allowed the governor to be set to “performance”. I should have documented it better, but I think it involved setting up rc.local with systemd and using the following in /etc/rclocal. I found this thread Set CPU governor to performance in 18.04 - Ask Ubuntu which seemed to also work with Raspbian, unless it is something else I did.

sleep 120 # Give CPU startup routines time to settle.
echo performance | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor