Raspberry Pi Revivification, Part 2 

random notes while compiling stuff to use a MobilePre USB soundcard with Jack2 and Pure Data 

August 24th, 2015

the problem is that we need to compile a version of jack that doesn’t require dbus messaging, which due to a bug requires an x-windows session, otherwise it fails miserably. This is important, because when I'm performing, I'm running Pure Data with -nogui, and I'd rather not have an useless X-windows session sucking up CPU cycles.

now compiling alsa-lib (which does not hav a package on apt-get) http://www.alsa-project.org/main/index.php/Download “alsa-lib contains the user space library that developers compile ALSA applications against.” Makes sense, eh?


./waf configure --alsa=yes ./waf -j4 build sudo ./waf install

let’s figure out all the crap about audio devices now.

jackd --verbose --driver=alsa --realtime --device=hw:1 --period=128 --rate=44100 --shorts

i feel that there may be issues with having alsa-base installed through apt-get and alsa-lib installed elsewhere... so let’s uninstall alsa-base:

sudo apt-get remove alsa-base

alright, look. I think maybe the issue is that i tried to install pure data from the repo, and it installed all sorts of jack dependencies. removing those all now...

apt-get remove libasound2-dev libasound2 pd

recompile alsa-lib from source recompile jack2 from source sudo ldconfig sudo reboot

no more segfaults!

jackd -R -dalsa -dhw:1,0 -p128 -n3 -r44100 -S seems to work, even with usb at full speed

but let’s now move on to pure data

git clone git://git.code.sf.net/p/pure-data/pure-data

“Quick compilation instructions for Gnu/linux or Mac OSX, or Windows if you have installed gygwin: make sure "automake" is installed as well as the usual C compiler chain. Then in this directory, run the following commands: ./autogen.sh ./configure make

If you need jack support, add the corresponding flag to "configure":

./configure --enable-jack “

GREAT. Disregarding the ambiguity of "…the usual C compiler chain", let’s install automake from the raspbian repos: sudo apt-get install automake


now in /pure-data:


gives me some sort of error about m4 and legit macros... googling suggests that i install libtool

sudo apt-get install libtool

try again.

seems to have worked! gtfo.

./configure --enable-jack make -j4

fails with what seems to be a bash call to “/bin/bash: msgfmt: command not found” so let’s see if i can install that... it’s a part of “gettext”

sudo apt-get install gettext

continuing with make ...

seems fine. install seems fine

pd still doesn’t really start, giving “sh: 1: wish: not found” and x11 not triggering, with the “watchdog” thing.

so googling around, “wish” seems to be part of tcl/tk (a gui thing?) so i’m installing that...

sudo apt-get install tk

cool, now I get: “Application initialization failed: no display name and no $DISPLAY environment variable”

I think I tracked this down to the fact that xquartz needs to be reinstalled after an upgrade to Yosemite. Doing that...

okay... DISPLAY is still not getting set. More research indicates that I need to install xauth.

sudo apt-get install xauth

Great. I had futzed with the sshd_config file according to some suggestions on the net, but I restored it to the default Raspbian settings:

sudo nano /etc/ssh/sshd_config

make sure the only x11 settings are X11Forwarding yes X11DisplayOffset 10

And be sure to log in from your client machine using something like ssh -Y pi@

The -Y switch will cause xauth to create a .Xauthority file in your home folder with a MAGIC COOKIE in it.

There is one last detail which must be attended to before one can successfully start jackd. My device, the M-Audio MobilePre, and many other USB audio devices, require USB1.1 to work properly. On the Raspberry Pi, you can do this by adding


to the end of /boot/cmdline.txt and rebooting. Unfortunately, this has the effect of slowing down ALL your USB devices, including ethernet. If you have to compile a lot of things that require massive downloads, or are backing up your system, you probably want to temporarily deactivate this option.

Now on my old system, Pure Data used to try to automatically start jackd, and fail if a jack server was already running. Now, for whatever reason, it does not automatically try to start jackd, and jackd must be already running before you start pure data. Here’s how I do it:

jackd -R -dalsa -dhw:1 -p128 -n3 -r44100 -S

In longhand, this is jackd --realtime --driver alsa --device hw:1 --period 128 --nperiods 3 --rate 44100 --shorts

This gives a nice, low latency and works smoothly with my pure data apps. I do performances where my microphone runs through my USB device, through Pure Data, and back out to the house, and the delay is negligible.

Speaking of Pure Data, do pd -rt -jack

You may have to wait a bit for your X11 app to open on your desktop machine. When it does, Pure Data should open its gui in it. SUCK_LESS, SUCK_SESS. (Well, you should try making a simple patch first to see that it actually makes sound.)