Best way to auto-start/integrate PD?

I’m using Pure Data (Pd-L2Ork to be exact) on a MODEP system that has a Raspbian desktop installed; I’m using it to convert the motion of a USB joystick to MIDI data, among other things.

I’m wondering how I can best auto-start this PD patch upon boot - I’ve been searching the forums and suspect it would be best to hook into the existing systemd sequence, in a way that the MIDI connections are set up properly, perhaps also using qjackctl.

Could anyone please give me some idea on how I would go about this? Is there a typical systemd editor / file to be edited for instance, in which I can isolate a relevant location/step to launch PD?


Here’s what I’ve come up with so far.

In /usr/lib/systemd/system, there are a number of relevant .service files. One of them is jack.service, which reads (I’m using gedit):

Description=JACK Server

ExecStart=/usr/bin/jackd -v -t 2000 -P 75 -d alsa -d hw:pisound -r 48000 -p 128 -n 2 -X seq -s -S


I want to start pd-l2ork before jack is started, so that the MIDI connection from PD to touchosc is automatically made; in qjackctl that looks like this:


What I’ve tried so far, based on info I found on how things are done with systemd, is make a file called puredata.service in /usr/lib/systemd/system with this content:

    Description=Pure Data service

    ExecStart=/usr/bin/pd-l2ork -rt -audiobuf 20 -inchannels 2 -outchannels 2 -alsamidi -mididev 0 %U


Note that I’ve taken over the from jack.service, and in that file changed it to After=puredata.service, so that the Puredata starts before jack does and Puredata’s MIDI output should be available in Jack.

After this, I’ve done:
sudo systemctl start puredata
sudo systemctl enable puredata
sudo systemctl stop puredata

which to my knowledge should make it available at boot.

It’s not working yet though… no PD at boot. Maybe I’m missing something?

Also, in a fresh boot, when I stop the jack service, then manually start puredata, then start the jack service again, the Puredata MIDI output is available in the ALSA MIDI Connection window, but I can’t get it to auto-connect to the touchosc input; even if I make a default patchbay for that connection and tick Activate Patchbay Persistence in qjackctl’s Setup - Options page.

Perhaps there is a different/better method of approaching all of this? Again, what I’m looking for is auto-starting a PD patch and have the PD MIDI output connected to the touchosc MIDI input.

This enables launching on boot, the ‘start’ and ‘stop’ launch the service and kill it respectively on current session. ‘disable’ would stop running the service on boot.

The %U seems suspicious, what is it? Also this starts PD as root user, likely when there’s still no GUI environment available, you probably have to add a ‘-nogui’ argument.

Check sudo journalctl -u puredata -f and sudo systemctl status puredata to see some useful output on how starting of PD went.

1 Like

Here’s a script that makes aconnect connections, you may find it useful: Midi connection manager

1 Like

Thanks Giedrius! Turns out that in the above case pd-l2ork wasn’t starting because the GTK+ visual framework wasn’t loaded yet. Starting with -nogui -alsamidi -mididev 0 does launch pd-l2ork succesfully at boot, and its MIDI ports are visible in qjackctl.

I don’t know what the &U parameter is for; this entire argument string I simply copied from the Properties for the PD-L2Ork entry in the Raspbian start menu. Also, I think you may be interpreting the -rt argument as root: it’s for engaging real-time mode.

Now for actually making the MIDI connection: I guess I could make another .service file for that which runs a .sh script that makes aconnect calls; could I also modify an existing script somewhere that makes the touchosc2midi <-> RtMidi connections?

These happen within touchosc2midi software itself, in particular the RtMidi library, so I don’t think it’ll be useful to you.

I think you may create another .service file which would get started after pure data and touchosc2midi, or find some other way to delay the launch of the script, then do the aconnect or try_aconnect commands as in the linked script in previous post.

1 Like

Yay, got it working. Here’s what I did:

In /usr/lib/systemd/system, make two new files: puredata.service and MIDIconnect.service

puredata.service contains:

Description=Pure Data service

ExecStart=/usr/bin/pd-l2ork -nogui -alsamidi -mididev 0


and is enabled for boot by running sudo systemctl enable puredata. I still have to add the PD file I want to run in the ExecStart statement

MIDIconnect.service contains:

Description=MIDI Connection Service

ExecStart=/bin/bash /usr/local/modep/


and is enabled for boot by running sudo systemctl enable MIDIconnect

In jack.service in the same directory, is replaced by After=puredata.service contains:


sleep 2

try_aconnect() {
	aconnect "$1" "$2" 2>/dev/null && echo connected $1 '-->' $2 || true

try_aconnect 'Pure Data':1 'touchosc':0