Pure Data

Vicente González Ruiz

September 12, 2016

Contents

1 About Pure Data
2 Installation (of Pure Data Extended)
3 How to run Pd
4 On-line documentation
5 Pd in-place documentation
6 I want even more (external) libraries!
7 Patches, objects, wires, ...
8 (Some of the) Supported Inputs/Outputs
9 A MIDI music random generator
10 An amplitude (audio) modulator

1 About Pure Data

2 Installation (of Pure Data Extended)

3 How to run Pd

pd-extended &

4 On-line documentation

5 Pd in-place documentation

6 I want even more (external) libraries!

  1. Projects In Category Libraries And Externals.
  2. Pd Patches.

7 Patches, objects, wires, ...

  1. A patch is a collection of Pd elements (usually stored in a .pd file).
  2. Elements of a patch are objects that have been already placed in a patch (at least have size and position in the canvas).
  3. Wires transport messages between objects.

8 (Some of the) Supported Inputs/Outputs

  1. PCM audio.
    cat > ADC-DAC.pd << EOF  
    #N canvas 596 824 450 300 10;  
    #X obj 117 84 adc~;  
    #X obj 118 113 dac~;  
    #X text 43 98 Left channel;  
    #X text 147 99 Right channel;  
    #X text 149 84 Read audio from the Analog-to-Digital Converter;  
    #X text 149 113 Write audio to the Digital-to-Analog Converter;  
    #X connect 0 0 1 0;  
    #X connect 0 1 1 1;  
    EOF  
     
    pd-extended ADC-DAC.pd &  
     
    # Remember to activate DSP in the Pd main window!

    PIC PIC PIC PIC

  2. MIDI. Run qjacktcl, vmpk, amsynth and connect in the ALSA Connections facility “VMPK Output” with “Pure Data” and“Pure Data” with “amSynth”.
    cat > MIDI-IO.pd << EOF  
    #N canvas 962 48 956 1131 10;  
    #X obj 33 23 notein;  
    #X obj 27 107 noteout;  
    #X text 72 85 <- MIDI channel number;  
    #X text 37 51 <------- Note number;  
    #X text 54 68 <---- Velocity;  
    #X text 82 23 Read note;  
    #X text 81 107 Write note;  
    #X connect 0 0 1 0;  
    #X connect 0 1 1 1;  
    #X connect 0 2 1 2;  
    EOF  
     
    pd-extended MIDI-IO.pd &  
     
    % Remember to select "jack" and "ALSA-MIDI" in Pd!

    PIC PIC PIC PIC PIC PIC

  3. Video.
    cat > webcam.pd << EOF  
    #N canvas 92 850 450 300 10;  
    #X obj 117 91 gemhead;  
    #X msg 149 117 device 0;  
    #X obj 124 147 pix_video;  
    #X obj 230 157 gemwin;  
    #X obj 124 169 pix_texture;  
    #X obj 124 191 rectangle 6 4;  
    #X msg 231 134 dimen 640 480 \, create \, 1;  
    #X connect 0 0 2 0;  
    #X connect 1 0 2 0;  
    #X connect 2 0 4 0;  
    #X connect 4 0 5 0;  
    #X connect 6 0 3 0;  
    EOF  
     
    pd-extended webcam.pd &  
     
    % A window named GEN should be created with the video captured by the webcam.

    PIC

  4. Keyboard.
    cat > keyboard.pd << EOF  
    #N canvas 80 659 450 300 10;  
    #X obj 59 28 key;  
    #X floatatom 59 51 5 0 0 0 - - -;  
    #X connect 0 0 1 0;  
    EOF  
     
    pd-extended keyboard.pd &  
     
    % After selecting the window, push any key.

    PIC

  5. Mouse.
    cat > mouse.pd << EOF  
    #N canvas 82 473 450 300 10;  
    #X obj 135 72 cursor;  
    #X obj 135 54 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 1  
    1;  
    #X obj 135 93 route motion;  
    #X obj 135 115 route x y;  
    #X floatatom 119 143 5 0 0 0 - - -;  
    #X floatatom 173 142 5 0 0 0 - - -;  
    #X obj 135 169 osc~;  
    #X obj 167 169 osc~;  
    #X obj 145 196 dac~;  
    #X text 152 141 x;  
    #X text 208 139 y;  
    #X connect 0 0 2 0;  
    #X connect 1 0 0 0;  
    #X connect 2 0 3 0;  
    #X connect 3 0 4 0;  
    #X connect 3 1 5 0;  
    #X connect 4 0 6 0;  
    #X connect 5 0 7 0;  
    #X connect 6 0 8 0;  
    #X connect 7 0 8 1;  
    EOF  
     
    pd-extended mouse.pd &  
     
    # Activate the patch and the DSP, and move the mouse!

    PIC PIC PIC

  6. USB HID.
    # Before running pd, plug the device!  
     
    cat > hid.pd << EOF  
    #N canvas 1396 119 176 115 10;  
    #X msg 90 15 print;  
    #X obj 51 43 hid;  
    #X obj 51 72 print;  
    #X obj 19 16 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 1 1  
    ;  
    #X msg 40 15 open 8;  
    #X connect 0 0 1 0;  
    #X connect 1 0 2 0;  
    #X connect 3 0 1 0;  
    #X connect 4 0 1 0;  
    EOF  
     
    pd-extended hid.pd &  
     
    # Don’t forget to: (1)  toggle on the patch, (2) send the "print" message  
    # to the "hid" object, (3) send the right "open" to the right device.

    PIC PIC

9 A MIDI music random generator

cat > MIDI-random-generator.pd << EOF  
#N canvas 2 48 476 1131 10;  
#X obj 35 114 drunk 10;  
#X floatatom 35 169 5 0 0 0 - - -;  
#X obj 35 35 metro 300;  
#X obj 35 12 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1  
;  
#X floatatom 57 63 5 0 0 0 - - -;  
#X floatatom 80 87 5 0 0 0 - - -;  
#X floatatom 86 15 5 0 0 0 - - -;  
#X obj 35 140 + 21;  
#X text 114 84 Step size;  
#X text 90 61 Upper bound;  
#X obj 38 191 hsl 128 15 21 108 0 0 empty empty empty -2 -8 0 10 -262144  
-1 -1 2628 1;  
#X obj 377 42 ctlout 1;  
#X floatatom 377 17 0 0 0 0 - - -;  
#X obj 35 254 makenote;  
#X floatatom 57 215 5 0 0 0 - - -;  
#X floatatom 80 234 5 0 0 0 - - -;  
#X obj 118 293 noteout 1;  
#X obj 187 116 drunk 10;  
#X floatatom 187 171 5 0 0 0 - - -;  
#X obj 187 37 metro 300;  
#X obj 187 14 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1  
;  
#X floatatom 209 65 5 0 0 0 - - -;  
#X floatatom 232 89 5 0 0 0 - - -;  
#X floatatom 238 17 5 0 0 0 - - -;  
#X obj 187 142 + 21;  
#X text 266 86 Step size;  
#X text 242 63 Upper bound;  
#X obj 190 193 hsl 128 15 21 108 0 0 empty empty empty -2 -8 0 10 -262144  
-1 -1 292 1;  
#X obj 187 256 makenote;  
#X floatatom 209 217 5 0 0 0 - - -;  
#X floatatom 232 236 5 0 0 0 - - -;  
#X text 122 16 Period;  
#X text 273 18 Period;  
#X text 218 141 MIDI notes start at 21;  
#X text 242 218 Velocity;  
#X text 266 237 Duration (ms);  
#X connect 0 0 7 0;  
#X connect 1 0 10 0;  
#X connect 2 0 0 0;  
#X connect 3 0 2 0;  
#X connect 4 0 0 1;  
#X connect 5 0 0 2;  
#X connect 6 0 2 1;  
#X connect 7 0 1 0;  
#X connect 10 0 13 0;  
#X connect 12 0 11 0;  
#X connect 13 0 16 0;  
#X connect 13 1 16 1;  
#X connect 14 0 13 1;  
#X connect 15 0 13 2;  
#X connect 17 0 24 0;  
#X connect 18 0 27 0;  
#X connect 19 0 17 0;  
#X connect 20 0 19 0;  
#X connect 21 0 17 1;  
#X connect 22 0 17 2;  
#X connect 23 0 19 1;  
#X connect 24 0 18 0;  
#X connect 27 0 28 0;  
#X connect 28 0 16 0;  
#X connect 28 1 16 1;  
#X connect 29 0 28 1;  
#X connect 30 0 28 2;  
EOF  
 
pd-extended MIDI-random-generator.pd &  
 
# Ensure that "jack" and "ALSA-MIDI" have been selected in the "Media" menu.

PIC PIC PIC

10 An amplitude (audio) modulator