You are on page 1of 5

puredata (pd) worksheet 1 Introduction On opening pd, the command window appears.

This acts mainly as a place for errors to appear, and has a useful button for compute audio. If your pd patch ever refuses to work, make sure that this button is ticked before looking for errors.

To create a patch in pd, use File | New. In the first demonstration, we introduced two types of boxes. A box is the name pd gives to anything placed in the patch. All types of boxes can be found on the Put menu, which also has useful keyboard shortcuts for each kind of box once you get advanced in your pd use.

This is an object box, or object for short. It has inputs at the top and an output at the bottom. Inputs are always at the top, and outputs at the bottom.

This is a number box, or number for short. You can click on it, hold down the mouse button, and move it, to enter a series of numbers in the box. Try it. You can also click on the box and type a number, and it will appear in the box. If instead the box moves around, this is because you are in edit mode. Your mouse pointer will be shaped like a hand. Press Command-E to swap into playback mode. When you move the mouse pointer, it will turn into an arrow. Command-E swaps back into edit mode when necessary.

osc~ is an oscillator, and produces a cosine wave at a given frequency.

It needs a frequency input, and the outputs need connecting to a dac~ object, which outputs the sound to the sound card. Here is a simple patch:

You wont hear anything until you increase the frequency. Try 100Hz or higher. You can also specify the frequency like this:

You can still change the frequency with a number input. It will just start out playing 440Hz, and continue doing so if you dont connect a number input. Note that there are two types of connecting wires in the simple patch above. The thin one is a control rate data stream. Number boxes produce control rate data. The thick lines are audio rate data. Most objects have fixed types of input and output (control or audio data), and if you try to connect the wrong one, an error will appear in the console window but if you cant see that window, you might miss the error. Some objects can be either an audio or control rate object. Any object with a ~ will produce audio rate data, and any object without a ~ wont. Some useful objects that can be either audio rate or control rate are mathematical functions. You can add or subtract numbers, and multiply or divide them:

The multiplication object is shown twice, in both its control and audio rate versions. As they look very alike, you have to be careful to choose the right one. Its also very important to connect up the left and right inputs the correct way round. For example, in this simple patch weve seen before:

the dac~ object has two inputs. As our output is stereo, the left input to dac~ goes to the left channel, and the right input to the right channel. Here is another useful kind of box. This is a Vslider, or vertical slider. It is connected up to a number box so that you can see what its value is, but the number is not necessary in normal use but you may find it helps you work out what is going on in the patch to use lots of number boxes at first. They help in what in programming terms is called debugging.

To move the slider and change the number, change into playback mode, click on the black bar, and move it up and down. There is also a horizontal version of this called the Hslider:

Sliders default to a range of 0 to 127. If this isnt a useful range, you can adjust it and many other properties of a slider by right-clicking on the slider and selecting Properties, which will bring up this menu:

Much of this concerns the visual appearance of the slider feel free to play with it. Avoid the lin button for now it changes the range to be logarithmic (log), and well return to send and receive symbols in the future. The output range is useful.

Exercises If in doubt or curious about anything, ask your classroom assistants or lecturer. Exercise 1 Can you hear what it is yet? 1. Replicate the simple patch shown twice in this introduction 2. Use a multiply object to change the volume from another number a. HINT: will you need a ~ multiply object or not? 3. Connect a Vslider to your control your volume control a. HINT: the default range may give unexpected results b. You could change the range by adding a multiply or divide object Exercise 2 Create a simple Ondes Martenot 1. The object below creates a triangle wave. Replace your osc~ with this and listen to the difference.

2. The object below gets a MIDI note input. Its three numeric outputs are: the MIDI note number (60 is middle C), the MIDI channel (1-16, will normally be the same for one input medium) and the key velocity (0 to 127).

Connect up the three outputs to three number boxes and work out which is which. If you dont get any outputs, check your MIDI setup, and ask for help if you get stuck. 3. We can use the MIDI input to control the frequency of our simple patch. First, we need to convert the MIDI note data to frequencies in Hertz. There is a simple object to do that:

Connect the MIDI input to the mtof input, and the mtof output to the phasor~ or osc~ input. 4. The object below gets MIDI controller data in. The slider and MOD wheel on the keyboards are both MIDI controllers. Connect up the three outputs to number boxes and see if you can work out what they are.

Again, ask for help if you cant work it out. 5. See if you can use MIDI controller data to change the volume of your patch. The Ondes Martenot is an instrument similar to the Theremin. The monophonic sounds can be controlled by a keyboard for discrete pitches and scales, or a wire for continuous pitch change like a violin. The volume is controlled by a separate control. Look it up on the internet and compare it with your patch can you get similar sounds? Try