Using the Pd repertory patches

Miller Puckette

This page describes how to use a collection of Pd repertory patches under development at UCSD. They are included as part of the courseware for Music 271 at UCSD, but are also intended to serve as performable implementations of some of the pieces considered. (Others, particularly tape pieces, are included as examples but are only demonstrations, not performable.)

CONTENTS

  1. The control panel
  2. Using scores and qlists
  3. detailed example: Risset, Sketch for Piano
  4. Ring Modulation: Mantra
  5. Sampling: the Tenney and Reich patches
  6. Frequency Modulation: Stria
  7. (not written yet:) Sinusoidal analysis/synthesis: Mortuos Plango, Vivos Voco
  8. A complex example: Pluton
  9. (not written yet:) installing and using the patches in Windows

The control panel

All the patches in the series use the same overall control strategy. Each patch has one or more "qlists" which are sequences of messages. The messages can control audio or MIDI processes or even the sequencing itself.

Some, but not all, of the pieces use score following to synchronize the sequences automatically with a live instrument. The score follower can use MIDI input (from a piano, for example) or can use the acoustic input from a solo instrument, which must be analyzed using a pitch tracker.

The pitch tracker, the score follower, and the sequencer control the rest of the patch as shown here:

In this picture, the sequencer is controlled by the score follower. The score follower can take input either from incoming MIDI or the pitch tracker, or just from the computer mouse. The audio processing portion of the patch is controlled by the sequencer and can make use of incoming audio and MIDI as well.

For each section of the piece, a "score" and a "qlist" are needed, to be used by the score follower and sequencer, respectively.

Each of the Pd patches has an area on the main window for controlling the score follower, sequencer, and master audio settings:

Sequencer controls

In the upper left are the sequencer controls, which start, stop and "step" the sequence:

Here there is only one section, number 100. (In patches that implement real pieces there will also be one or more "real" sections numbered starting at one.)( Section number 100 provides a simple example of how to use the patch. When you develop your own examples you'll load them into section 100. Each section consists of some number of "steps" or "events". The steps are numbered starting from 0 (which is the beginning of the section.) When you click on the "step" button you'll see the step number increase by one. Most qlists will have an event at the end that resets everything to zero so you can see when you're done. The number boxes show you the current section and "event". Also, if you are using score following, the "note" number box shows you the numerical index of the most recent note matched by the score follower.

Meters

The meters in the main control panel are useful primarily for debugging score following. (Some patches will have other VU meters in more easily readable format to show you the separate input and output levels by channel.) The meters look as shown here:

At the top is a toggle switch to turn them on and off. When you're not looking at them it's best to leave them off (in some situations graphics compete with the rest of the patch for CPU time.) The input level is in dB with 100 meaning "full blast and clipping". Only the channel one input is shown; this is used for pitch tracking.

The "tuning" meter should give the pitch of the acoustic input, or zero if none. The "rest" meter (actually a toggle) is on when the instrument is not playing (i.e. the amplitude drops below 50 db and stays there for 1/2 second; you can customize these values if you want.) You can use "rest" as a pitch for the score follower if you want an event to be set off at some point after the instrument stops playing.

Score following controls Three toggle switches control whether the pitch tracker is turned on, and whether to follow teh score based on the pitch tracker or incoming MIDI:

These can be controlled from the qlist; by default the pitch tracker is on, but score following is taken from MIDI input. The qlist messages to change this are:


    pitch-track-on 1;	    -- to start pitch tracking
    pitch-track-on 0;	    -- to stop it
    
    follow-pitch 1; 	    -- follow pitch tracking
    follow-pitch 0; 	    -- don't

    follow-midi 1;  	    -- follow MIDI
    follow-midi 0;  	    -- don't

Master input and output gain

Master input and output gain are in dB with 100 set to unity. The controls appear as shown:

You can drag the values up and down; values over 100 are permitted, but be warned that each 10 dB gives a large boost in amplitude... don't put the output control to 200 because you don't hear anything; when you get sound output working you might be blown out of the room.

The "mute" control toggles the master output gain to and from zero.

Scores and qlists

You can click on the "pd score" box in the sequencer control panel to open a window with controls for editing the score and qlist for "section 100" (This section is for demos and is not part of any of the repertory pieces:)

For either qlists or scores you can:
Open a file and read it into Pd's qlist or score follower;
Save the current qlist or following score to a file;
Print the current qlist or following score to the "terminal";
Edit the current qlist or following score in a text window.

The "edit" feature only works under Linux, not Windows. When you select "edit" Pd will save your qlist or following score to a file and call a text editor on it. (NOTE: Pd will freeze until you exit the text editor!) When you're done editing the new score or qlist is automatically read into Pd. You can then "save" it to your own file.

In case you forget to save the score or qlist to a file before exiting Pd, Pd always puts a copy of the most recently edited score and/or qlist in the files, "last-score.txt" and "last-qlists.txt" which you can then rename using Unix commands -- and should rename before another editing session overwrites the file.

For the following score, not the qlist, you also have controls to record a score from the piano. When you hit "stop" Pd starts an editor with the score as if you had hit "edit".

The following score will need to be annotated with markers to show where the "events" are. This is shown by example in the next section.

Example: Risset, Sketch for Piano

The simplest patch in the series is one to do MIDI transpositions and reflections, inspired by Risset's second sketch. You can start the patch and try out the transformations, play the "section 100" sketch provided, or make your own sketch.

In addition to the score following and sequencing control panel, the patch has controls as shown:

The first group carries out reflections. There are three controls, named "reflect-on," "reflect-point," and "reflect-delay". Reflect-on is a toggle; if nonzero the reflection mechanism is running. The reflection point is a MIDI pitch such as 60 (middle C) or a quarter-tone such as 59.5 (the crack between B and C). Finally, you specify a delay in milliseconds. (If you're using a disclavier, there will be an additional delay from the disclavier mechanism; this isn't included in the "delay" value. The delay is in milliseconds; so for instance "500" means half a second.

The transposition group is almost the same. The controls are named "transpose-on". "transpose-interval" and "transpose-delay." Here the transposition is in semitones, should be an integer, and can be positive or negative.

Section 100 contains a following score as follows:

1000 48

1000 55

1000 60 1

1000 60 2
0 64
0 67

1000 48

1000 55

1000 60 3

1000 60 4
0 63
0 67

1000 48

1000 55

1000 60 5

1000 60 6
0 64
0 67

The score has one line per note; each line has two or three numbers. The first number is a duration in milliseconds, the second is a MIDI pitch, and the third, if present, is an event number. The score above starts with a C, G, abd C each one second apart; the second C is event 1. Then there is a C major chord which is event 2. (Actually the first note of the chord is marked with the event.) The same thing is repeated three times with minor variations; the events are numbered one through six. (Event numbers should be sequential, but they don't have to be consecutive as long as the qlist agrees.)

Here is the corresponding qlist:

0 0 # --------------- STARTUP  ----------------- ;
# nothing to do here... ;
# (comments start with "#" and end with a semicolon like this:) ;

0 1 # --------------- EVENT 1 ------------------- ;
# after 1/10 sec, turn on reflection at 63.5;
100 reflect-on 1;
reflect-point 63.5;
reflect-delay 500;

0 2 # --------------- EVENT 2 ------------------- ;
# after 1.5 sec, turn it off again;
1500 reflect-on 0;

0 3 # --------------- EVENT 3 ------------------- ;
# on again;
100 reflect-on 1;

0 4 # --------------- EVENT 4 ------------------- ;
# off again;
1500 reflect-on 0;

0 5 # --------------- EVENT 5 ------------------- ;
# now a transposition down 7 semitones;
100 transpose-on 1;
transpose-interval -7;
transpose-delay 500;

0 6 # --------------- EVENT 6 ------------------- ;
# after 2 sec, turn it off;
2000 transpose-on 0;
# ... and set section number to zero to show that we're done;
section-number 0;

There are six events, not counting "startup." (Startup would be the appropriate place to set up transformations that should be in effect before the piano part starts.) Each event starts with a line like:

0 1 # --------------- EVENT 1 ------------------- ;

... in which the "0 1" means, "time delay 0, event 1". The "1" must be replaced with the current event number. The remainder of the line, starting from "#", is a comment. Comments, and all other messages, must end in semicolons; it's easy to forget them and if you do the succeeding message will simply appear as more stuff at the end of the previous one (which will usually be ignored and you will wonder why nothing happened.) Forgotten semicolons are by far the most common errors in qlists.

The first event, then, after another comment, gets on to the three lines:

100 reflect-on 1;
reflect-point 63.5;
reflect-delay 500;

There are three messages, the first one with a delay of 100 milliseconds, and the others having no delay and so happening immediately after the first. The three messages turn on the reflection transformation. The delay of 100 is so that the note that sets the event itself off won't get transformed; the intent is that only the following chord be reflected.

The chord itself turns the reflection off after a suitable delay in event number 2. This is repeated three times, the last time with a variation, and finally, event 6 stops the piece by continuing to "section 0."

Stockhausen, Mantra (ring modulation)

This patch does ring modulation on two pianos, whose signals come in on channels one and two of the computer. There are two corresponding outputs. In the actual piece (which isn't yet integrated into this patch) there are MIDI inputs from two slider boxes which allow the pianists to control "their" respective modulators. In the patch provided here, MIDI input isn't used at all.

(this is too bad, isn't it? next year I should extend the patch to allow the MIDI keyboards to control the modulation frequency.)

Strictly speaking the patch implements single sideband modulation instead of ring modulation. Each partial of the piano sound is shifted up and/or down in frequency by a chosen modulation frequency.

The controls are "ring1-pitch," "ring1-plus", and "ring1-minus," plus the corresponding controls for "ring2". "Ring1" refers to the first modulator which acts on input 1 and "ring2," correspondingly for input 2. The "ring1-pitch" control specifies the modulation frequency in units of MIDI pitch (i.e., "69" gives 440 Hz), with microtones allowed as in "69.5" and so on. The "ring1-plus" and "ring1-minus" controls specify the amplitudes (the gains, really) of the positive and negative sidebands. They are both in decibels, with "100" corresponding to unity gain.

In the qlist, these parameters can be given as single numbers as in the first event:

     ring1-pitch 43;
     ring1-minus 100;
or as pairs of numbers like:
     ring1-pitch 74 2000;
If a single number is given, the "pitch" updates instantly and the two gains change smoothly over a period of 30 milliseconds (about 1/33 second). If you give a second number this is a time in milliseconds to override this; for instance, the example above makes a 2000-millisecond glissando to pitch 74 (from whatever the pitch was before) and similarly for the amplitudes which can be faded in or out either more quickly or more slowly than the default.

to be written...

Tenney and Reich examples (sampling)

The patches are inspired by James Tenney's Collage #1 and Steve Reich's Piano Phase. They do essentially the same thing (and some year I'll combine them into one.)

Each patch gets a bank of nine samples. The basic operations you get are to record and play back the samples. You can also play back loops as shown in the "Reich" patch...

Chowning, Stria (Frequency Modulation)

Among other ways, Stria can be heard as a study on a musical scale and a spectrum which work together in a way very different from the usual Western 12-tone scale and the 1:2:3:4:... partial ralationship of "harmonic" instruments like strings, winds, and the voice. In Stria, the scale has nine equal divisions of an "octave" which is set to the Golden ratio, about 1.618 to one, which is between a Western minor sixth and a major one. The partials are in the ratios

    1:(1+1.618):(1 + 2 x 1.618):...
     :(1-1.618):(1 - 2 x 1.618):...
and are synthesized using FM with a 1:1.618 carrier to modulator ratio.

The patch plays six voices of FM. There are four controls which are global, i.e., shared by all six voices. These are seen in the first event of the qlist:

base-freq 1000;
octave 1.618;
steps-per-octave 9;
fm-ratio 1.618;

The "base frequency" is the frequency in Hertz of the "reference pitch" in the scale; in the usual Western scale this is 440 corresponding to A above middle C but in Chowning's it is set to 1000. "Octave" specifies the ratio of two notes an octave apart (usually 2; 1.618 in this piece); "steps-per-octave" is normally 12 and is 9 here; and "fm-ratio" is the modulator-to-carrier-frequency ratio, which you can set to one, for instance, for a "harmonic" sound and which Chowning sets to 1.618 again.

The six voices have controllable amplitudes, carrier frequencies, indices of modulation, and depth and speed of "beats" in the modulating oscillator. The first event after startup in the qlist, for example, sets these five for voice one out of the six:

amp1 80 5000;
index1 20;
pitch1 18;
depth1 22;
speed1 4;

Here "amp" is the amplitude in dB (with 100 being the maximum amplitude); as in the Stockhausen patch you may specify a fadein time, which is 5 seconds in this example. "Index1" gives the modulation index in hundredths; "pitch1" gives the pitch in steps above or below the reference frequency (in this example it is two octaves, 18 half steps, above; negative numbers specify steps below.) You may specify decimal fractions of steps if you like.

The "depth1" and "speed1" are the depth of beating in percent and the beat speed in tenths of a Hertz. Tbe beating actually causes the modulation index to rise and fall periodically.

Appendix: installing the patches in Windows

to be written...