Running Puredata on the Raspberry Pi
I’m thrilled to say that today I succeeded in getting Puredata running on my Raspberry Pi. Here’s how!
First, follow this guide to get your Pi set up for the first time. Make sure your Pi is connected to the internet, and now we can install Puredata. We’ll start with Vanilla, since pd-extended is not maintained for ARM (as far as I can tell). I’ll explore getting pd-extended working in a future post (hopefully very soon).
sudo apt-get update sudo apt-get install puredata
Easy. What’s not easy is getting sound working. This took me about half the day but here’s what worked:
sudo apt-get install alsa-utils sudo modprobe snd_bcm2835
Note that the modprobe line needs to be run every time the Pi is booted, so you can add it to an .rc file if you want. Now connect some speakers, turn them down for safety, and run this to make sure sound works:
sudo aplay /usr/share/sounds/alsa/Front_Center.wav
If it works, good! You can now run a Pd patch like so:
pd -nogui -noadc -alsa testPatch.pd
For convenience, here’s my test patch (testPatch.pd) that outputs an LFO’d sine wave. *Important!* Notice in the patch that the loadbang is delayed by 100ms! This is deliberate to avoid a bug in Pd regarding ALSA.
Please let me know if this worked for you. Happy hacking! Next up, I’ll be trying to build Pd-extended and then tackling the Raspberry Pi’s General Purpose I/O.
You’ll notice that the sound quality out of the 1/8″ jack is messed up in some cases (most in my experience). I’ve heard from various sources that the R-Pi does not use a “real” DAC (Digital-to-Analog-Converter) and that you should get better sound from a USB adapter or from the HDMI output. Still following up on this.