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.
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.
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
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
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.
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.
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:
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