Running Pd on a “headless” Raspberry Pi

The cheap and tiny Raspberry Pi seems suited for projects requiring a tiny “headless” computer. Headless means without a screen, and thus implies that one or more applications have to start automatically on start-up. Linux is embeded extensively in many devices, and can be configured to do a job in auto-pilot mode.

This is all very cool, but until recently I had no idea how to go about using the Raspberry Pi as a headless device. Fortunately, I came accross this free book by William E. Shotts, Jr., and I learned a few helpful things. Below is short tutorial that’ll help you run a Pd patch on a headless Raspberry Pi running Raspbian (we’re assuming that your patch can output audio without your input, that it’s called “nicorette.pd”, and that it’s in your Desktop folder. You can change this of course).

1) Start your RPi, enter your login and password (pi and raspberry if you haven’t changed them), and DON’T type “startx”. We’ll do everything with the command line.

2) Create a /bin folder in your home/pi folder by typing this :

mkdir ./bin (hit enter)

3) Move to this folder by typing :

cd ./bin

4) Create a file in this folder named “script_pd” (or whatever you want to call this) :

sudo nano script_pd (this opens a blank text file in the nano editor)

5) In the nano editor, type this script :

# This script will start Pd in nogui
# mode and will open the patch
# named "nicorette.pd"
echo "Starting Pd..."
pd -nogui /home/pi/Desktop/nicorette.pd &

6) Save your script by pressing Ctrl+X, hitting y, and Enter.
7) This script is still nothing but a text file. We need to make it executable by typing this :

sudo chmod 755 script_pd

(7-bis) You can check that your script is working by typing “/home/pi/bin/script_pd” and pressing Enter. You should see “Starting Ps…” and your patch should start. You’ll need to reboot your RPi to turn Pd off)

8) Now we need to tell the RPi to launch our script at start-up. To do this we have to edit a file called “rc.local”. Open it in the nano editor with :

sudo nano /etc/rc.local

9) Add the following line after the first comments (comments start with a #) :


10) Save and quit nano (Ctrl+X, y, Enter). Anything that’s in this rc.local file is executed at start-up. We’ve simply asked to run our script to launch Pd when we start our Raspberry Pi.

11) You can reboot your RPi, and if all went well, it should work. Note that you can still type commands while Pd is running (for instance, you can kill pd by typing “sudo killall pd” and hitting Enter).

This entry was posted in Software and tagged , , . Bookmark the permalink.

12 Responses to Running Pd on a “headless” Raspberry Pi

  1. Pingback: Setting up the Raspberry Pi for PD (1) – allocate more RAM to CPU | Guitar Extended

  2. luis :) says:

    for what is the “&” in the command pd -nogui /home/pi/Desktop/nicorette.pd &?

    • Hi,

      The ampersand (&) is there to excecute Pd as a background process (look it up on the internet). In particular it is there to let you use the terminal (i.e. type another command) after Pd has started. You can try typing “pd” in a terminal (this should launch Pd, but you can’t do anything in the terminal until Pd stops), and then “pd &” (Pd should start like before, but you should now be able to type another command in the terminal).

  3. Gigin says:

    Hi ,
    I’m trying this headless but i have some problem with it, it seems that it not load the pd program after raspberry pi restated. it seem error because not loading gui, can you give me some clue to overcome this problem. Right now trying follow your way to make a guitar effect,

    • Hi,

      It is very difficult to know what’s going wrong without more information. Are you sure your patch is working on the Pi with the GUI in the first place ? Are you also sure you can make pd work on your headless Pi (with a simple script) ?

      • Gigin says:

        Yes with gui pd is working fine(i tested with your patch), When applying script the “starting pd” is appear but after that nothing happen.

  4. Jean-Paul Carmona says:

    Hi, and first off all, Thanks for your tutorials !

    my scripts starts on command line with (or without) -nogui option, but I still need to check the checkbox to set the DSP media “on” on may main window to ear something. How to check on the DSP media by script ? on bash command line or on the patch or on pd preferences maybe ?

    • You need this in your patch :
      [del 1000]
      [pd dsp 1(

      This send a bang to the message (pd dsp 1) that turn the audio on. There is a delay between the bang send when the patch loads and the message because there is (was ?) a bug when Pd is running headless.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s