Getting Started with Linux audio and Pd

adapted from notes by Jose Rio–Pareja

A. Before using any CCRMA computer you will need to have a CCRMA login account and password: if you haven't set one up, follow these instructions: register. Login to a CCRMA workstation.

B. There are two ways to run a program in Linux. You can go to the Applications menu then Sound & Video and seek for the name of the program or the recommended way: just type the name of the program in a terminal. To open a terminal you can right click anywhere on the screen, then select "New Terminal".

C. (ONLY need to DO THIS ONCE; skip to step C.1 if you already did this):
Create a working directory for storing your Pd files. In the terminal, type the UNIX command
mkdir pd-lab
. . . or some other name you prefer for your pd file directory.

C.1 Then, set that to be the working directory with the command
cd pd-lab

Note: if you have already created the "pd-lab" directory, then START WITH step C.1 "cd pd-lab" every time.

D. Run the JACK audio server with the command
qjackctl &

the JACK Audio Connection Kit window will appear:


next click the Setup button . . .

the JACK Setup window will appear:

1) set the Interface to hw:0
2) set the Sample Rate to 48000
3) click the OK button

the JACK Audio Connection Kit window will re-appear:


click the JACK Start button.

E. Now start Pd, a real time graphical programming environment for audio and graphical processing, by typing in the terminal:

pd –jack –rt &

this is what you will see if Pd is working:

IMPORTANT: Default audio settings in Pd need to be configured, which you will do only once, the first time you work in Pd from your CCRMA account.

In Pd:

1) go to the Pd Media menu – Audio settings

2) make sure input and output boxes are checked/red
3) set channels to 2 (not 0)
4) sample rate should match JACK's (48000)
5) click Apply button, then click OK button

6) go to the Pd Media menu – look to see that "jack" is now checked/red

7) go to the Pd File menu – Startup; a new window will appear:

click the "Save all settings" button.

TROUBLESHOOTING TIP#1:
After doing this for the first time, QUIT Pd, QUIT JACK, and start over at Step D.

The basics of Pd

First, make a new patch (File – New, or ctrl+ n):

Now we can begin to create in the patch window some basic sound like a white noise or noise generator. For that we will need to create an object (Put – Object, or ctrl+ 1).

To hear the sound, a digital–to–analog converter is needed. Put another object named dac~ just following the previous steps.

By dragging the mouse, connect the bottom–left corner of noise~ (which is the output of the object) to the top–left of dac~ (the input to the left channel of the dac~ object). Notice that the cursor turns into a small circle when placed on the "nodes".

Turn on the audio (click Compute audio or go to Media – Audio – On, or ctrl+ / ), and check the noise coming from left channel. (To turn off click again on Compute audio or go to Media – Audio – Off, or ctrl+ . ) If you want the same noise coming from both channels, make another connection from the noise~ object to the top–right of dac~.

Saving your work is simple. Menu command File – Save will prompt for a new file name. Once it is saved, get it back with File – Open and it reappears.

IMPORTANT: Pd must be switched between Edit Mode and Run Mode. After saving your patch, notice that it will re-open with Edit Mode turned off. If further editing is desired, turn on Edit Mode with Edit – Edit Mode or the equivalent keyboard command, ctrl+ e (this "toggles" the mode on or off).

Now, instead of a noise generator we will create a periodic sine wave or sinusoidal oscillator. Create an object typing inside osc~ and again connect the bottom left of the object to the two inputs of the dac~ object.

Notice that there is no sound coming from your speakers since the osc~ object needs a number to determine the frequency of your oscillator. The object defaults to 0 Hz. frequency, so at this point even though it is sending a signal to your audio output, you won't hear the sound of an oscillating wave. Like many objects that require parameter specifications you can add an argument to change its behavior. Use osc~'s initial frequency argument to bring it into the hearing range. Type in 440 to hear the pitch corresponding to the A above middle–C. Save this patch forever. . . it's useful for testing audio output and tuning instruments.

For more information about the input parameters that control an object, see its "Help patch" by right–clicking on the object and choosing "Help". Reading the information that appears in the one for osc~, you will know that the left input is for frequency and the right one for phase. We can take advantage of these inputs for real–time changes when running the patch in "Performance Mode" (as opposed to Edit Mode).

Your tuner patch might want to allow different frequencies to be selected. Send numbers to it with message objects (Put – Message, or ctrl+ 2) and type the number of the frequency you want inside these boxes. Remember that creating an object or rewiring things you will have to return to the Edit Mode. Make the changes that you see here and, if you want a frequency an octave lower than the previous one, type 220 in the message object. To hear it, get out of Edit Mode and click over the message box. By clicking over the message, the osc~ object receives the new frequency number. Now you should hear it an octave lower.

For continuous control use a number box object (Put – Number, or ctrl+ 3) and connect it to the left input of the osc~ object. We need now to change the value of the number. To achieve that you will have to get out of the Edit Mode and drag–n–drop the mouse over the number box scrolling it for a Theremin–like glissando.

(or type in an exact number – this is allowed in "Performance Mode" in this case, whereas the previous message object method only allowed that in Edit Mode).

Again, to get more information about the different objects see "Help" by right–clicking on the object and choosing "Help". A complete on–line manual about Pd can be found at www.crca.ucsd.edu/~msp/Pd_documentation/index.htm