You are here

Pure Data: An Introduction

Open Source Graphical Programming Environment By Adam Armfield
Published August 2006

Here is a MIDI patch editor constructed within Pure Data. It can be easily adapted to control the synths of your choice — right-clicking on any object lets you alter its properties (shown below) or access help files relating to it.Here is a MIDI patch editor constructed within Pure Data. It can be easily adapted to control the synths of your choice — right-clicking on any object lets you alter its properties (shown below) or access help files relating to it.

Pure Data lets you process audio and MIDI within a powerful modular environment, and lets you combine it easily with video, custom hardware controllers, light shows, and even robotics. But, best of all, it's free!

Editing properties.Editing properties.There is a wealth of free audio and MIDI utilities on-line which can be edited and customised easily. They are designed in a free, easy-to-use graphical programming environment called Pure Data and can be used to make almost any sound & MIDI tool you can imagine. As well as audio and MIDI, Pure Data includes functions (called objects, or externals) for generating 3D graphics and video, and can also control external hardware like stage lighting or robotics. In effect Pure Data can use any kind of input (audio, MIDI, video, sensors, and so on) to control any kind of output, with lots of processing in the middle. So if you yearn for an electromagnetic catapult that flings jelly at the audience every time you rattle your tambourine, or a USB incense burner which radiates progressively stronger smells as the temperature in the church hall rises, Pure Data can help you achieve this!

Connecting Hardware & Software Using Pure Data

Pure Data really shines in combination with other software. For example, I often use it in conjunction with a sequencer, randomising all the settings on my soft synths at the push of a button. I'm also into generative composition, so I like to amuse myself by building random note and rhythm generators, using these to control an external sequencer and VST instruments. Because Pure Data can transmit SysEx messages, hardware devices like drum machines can be controlled in unusual ways, for instance by sending messages to restart the pattern playing at arbitrary intervals, allowing construction of complex rhythms.

There are several free programmes which allow you to route MIDI data between applications. For windows there's MIDIyoke (for Windows 2000 and Windows XP) and Hubi's Loopback for Windows 98, while Mac OS X has this functionality built into Core MIDI. The Linux equivalent to Core Audio/MIDI is called Jack. Open Sound Control (OSC) is another MIDI-like protocol which is used by Pure Data and other computer music software like Max/MSP, Csound, and Supercollider, and also by some exotic control hardware (like the Jazz Mutant Lemur multi-input touchscreen).

Eyesweb, a gestural recognition package, also communicates with Pure Data via OSC. Eyesweb reads the input from a camera (this can be a low-cost webcam) and outputs control signals in response. Eyesweb is programmed in a graphical way like Pure Data, and is often used for art installations and by dance companies, and in other situations where a mass of stray cables would get in the way. Eyesweb is also free software, though it is only available for Windows. Another option is the Pure Data graphics library Gem, which includes basic visual recognition objects and is very robust on Mac OS X. Stage lighting can be controlled using a protocol called DMX. MIDI-to-DMX converters are available which enable Pure Data (or other MIDI software) to control a lighting rig.

There are even Pure Data objects which can perform network communication, and this means that Pure Data can communicate with any other software with networking capabilities. One example of this is the NetPd project, which enables people to collaborate over a network or via the Internet, each playing the same patch, transmitting control data to the other 'band members' so that each hears the same thing at (roughly) the same time. Pdradio is another interesting application, an on-line radio station which uses Pure Data to play audio files — the Pdradio web site (http://pdradio.iem.at) gives instructions on how to build your own Internet radio station on a Linux web server.

Getting Started With Pure Data

Pure Data runs on Windows, Linux, and Mac OS X. It also runs on iPods, PDAs, and other exotic platforms such as Silicon Graphics machines. The system requirements are very relaxed, but older systems will be slower — if your machine isn't fast enough for real-time work, you can still use it as a MIDI synth editor and for other tasks which don't depend on accurate timing.

Pure Data is mainly developed on Linux, so this version is usually the best. Readers with older Windows PCs can use a bootable Linux CD like Dyne:bolic to run the Linux version of Pure Data on their machine without affecting their Windows installation, creating audio files in Linux before transferring them into their sequencer of choice for editing. Dyne:bolic loads Linux straight from the CD drive without installing it, leaving the data on the hard drive untouched. (Just thought I'd repeat that!) Dyne:bolic will run on Pentium computers with 64MB RAM. If you have any old PCs knocking about, these can be pressed into service as stand-alone synths or noise-generating devices.

When it comes to learning about Pure Data, it's worth realising that it's functionally very close to Cycling 74's Max/MSP. In fact, the two programs are so similar that tutorials for one can give you a good working knowledge of the other! However, Pure Data itself includes many example files (available from the Help menu) which can be edited, butchered, and generally stolen from to help construct your own patches.

When a file is first loaded, Pure Data is in Run mode, which means that the patch can be played rather than edited — the sliders and other graphical user interface (GUI) elements work. To edit a patch, you need to select Edit mode from the Edit menu, whereupon the cursor turns into a little hand. Objects and GUI elements are the basic building blocks of a patch, and they are connected together with patch cords. Data flows from the outlets at the bottom of an object, down the patch cords, and into the inlet at the top of the next object. Instead of selecting objects by name from a list, as is the way in Max, Pure Data prefers that you use the Put menu to place a blank object on screen, then type the name of the specific object you want to create inside it.

Example: MIDI Patch Editor & Randomiser

To give a better idea of the way Pure Data works, and what it can do, I've created a couple of Pure Data demonstration patches, the first of which is a MIDI synth editor. (You can download this from SynthEditor.zip.) It can be used to edit VST instruments as well as hardware instruments, and would come in handy for controlling a rackmount synth with a somewhat minimal front panel. Because of Pure Data 's totally open-ended nature, you can build a custom editor for your setup. For instance, if you typically patch your VST synth through a number of effects, Pure Data allows you to edit all the synth and effects parameters at once — just place some sliders on screen and configure them to send parameters on the MIDI channels/ports of your choice.

More interestingly, you can create relationships between parameters. You might want to limit the level of resonance on a filter (to avoid damaging your speakers), or to only limit the resonance when the cut-off is above a certain level. Or how about setting the rate of one LFO to remain exactly half the rate of another? All this can be done with basic maths in Pure Data.

In my example I have set up the editor to control a free VST instrument called Cheeze Machine. I've decided that I want the attack and release values to be the same, so I have created one slider that controls both parameters at once. I have also created a button to instantly randomise all parameters, but I have chosen to limit the range of this randomisation on certain parameters in order to control the results a little — totally random settings can sometimes produce disappointing results, for instance when the envelope's attack setting ends up so long that notes don't sound properly.

MIDI changes can easily be triggered from an audio signal, and there's a simple example of this in my patch — a mic input which will trigger parameter randomisation whenever the audio signal reaches above a certain threshold level. However, there's lots more scope for more complex creative control, especially because of Pure Data 's nifty pitch-detection object.

Creating Custom Hardware Controllers Using Pure Data

Several companies sell pre-built circuitry which can form the core of a custom MIDI controller — often all the user needs to do is add whichever knobs, buttons, and sensors they want to the circuit and mount it in a suitable box. Another approach to building custom devices is to adapt USB game controllers like joysticks, pedals, and dance mats, adding one's own controls to the circuit in place of the existing ones. These devices have become incredibly cheap in recent years. Many artists who used to build hardware from scratch now work with game controllers exclusively, because they are so cheap, and much of the complicated work is already done. A Pure Data object called Hid communicates with these gadgets and lets you incorporate them into your music system.

Example: Wavetable Synthesizer

The following patch gives an idea of what you can do with some of Pure Data 's audio capabilities. (It's available for download at Package icon wavetablesequencer0806.zip.) This patch is a wavetable synthesizer with a built-in 16-step sequencer. What makes this example interesting is that the oscillator shapes can be altered by clicking and dragging over them with the mouse. The oscillator waveforms are stored in Arrays (the three boxes along the top of the screen in my example), and samples in a variety of formats can be stored within Pure Data in this way.

This wavetable synthesizer shows something of what Pure Data can do when it comes to audio processing, and it also includes a built-in step sequencer. The sequence can be edited with a MIDI keyboard, while wavetables can be drawn on with a mouse.This wavetable synthesizer shows something of what Pure Data can do when it comes to audio processing, and it also includes a built-in step sequencer. The sequence can be edited with a MIDI keyboard, while wavetables can be drawn on with a mouse.

The sequencer section of my example is at the bottom right-hand side of the picture. A clock object called Metro (short for metronome, though this software was originally written in Paris!) drives a counter, which cycles from one to 16 repeatedly. The counter tells an object called Tabread which step of the sequence it should read. The tabread object outputs a MIDI note number at each step, and this number determines the pitch of the wavetable oscillator. The sequence can be edited using a MIDI keyboard (via the Notein and Tabwrite objects), or by drawing directly on the graph at the bottom right of the screen.

If you wanted to, you could adapt this patch so that the oscillator waveform could be drawn using a knob or slider, or by running your fingers up and down a MIDI keyboard (or just up for more of a sawtooth wave). An input device like a Korg Kaoss Pad or joystick could also be used for this purpose.

The Future Of Pure Data

Pure Data is being actively developed, you're free to suggest changes, and each new revision generally brings notable improvements. However, there's no need to wait for someone else to implement any improvements you're after, because Pure Data is totally open source, which means that you are free to adapt it and to get involved in it's development, although you do have to be able to program in the language C to do it.

Hopefully this article has given you a taste of what Pure Data can do. It offers a vast range of possibilities for producing sonic and visual arts, and combines media in exciting ways. And given that it's free, there's little reason not to try it out for size! 

Hear What Pure Data Can Do

To try to give some idea of the range of sounds available to you through Pure Data's processing and synthesis capabilities, I've created some audio demonstration files which can be downloaded from the links below:

An eight-voice additive synthesis patch.

Quarter-note segments of a Casio drum loop played in random order.

Here the same Casio drum loop is subjected to granular alterations using Pd-extended.

A vocal sample altered with a granular synthesis patch from Pd-extended. Note the wide variety of sounds that can be achieved with just this patch.

This is the wavetable synth patch featured in the article. As the sequence plays, the oscillator waveshape is altered by drawing on it.

This is the output from a simple frequency-modulation synthesis patch. The frequency of the modulating oscillator is swept to produce rich timbres.

Positive and negative sawtooth waves multiplied by each other.

An analogue-style melodic sample-and-hold patch.

Randomising the settings on a software Roland TB303 emulation. Another application is being used as a VST host (and to play the sequence), whilst Pure Data is used to alter the settings. The patch used here is very similar to the MIDI patch editor featured in the article.

Here one wavetable is modulating the pitch of another which provides the oscillator waveform. Both wavetables can be drawn on with the mouse to alter their waveshapes and the pitch of the sequence.

Web Resources

The main Pure Data site. You can download the program from here, and I'd recommend going for the package called Pd-extended, because this includes lots of additional processing objects. The Community area offers loads of patch examples to help you get going.

Pure Data: An IntroductionPure Data: An IntroductionPure Data: An Introduction Here you can find the Pmpd collection of objects for Pure Data, which offer a variety of physical modelling processes that can be applied to audio processing.

A selection of useful little Pure Data patches from Jason Plumbs.

Useful Pure Data-related links page.

The home of the Jamma looping sampler, created using Pure Data.

Pure Data ported to run on Apple's iPod!

This CD-based Linux package includes Pure Data and will run on old PCs from Pentium models onwards.

Cycling 74 sell several sensor-to-MIDI systems and other hardware controllers, along with their own graphical programming environment Max/MSP.

This is the home of I-Cube X, a pre-assembled sensor-to-MIDI conversion system which is particularly easy to use. However, it is also more expensive than other more DIY options.

Here you can get a fairly low-cost sensor-to-MIDI system, but you need to know some electronics to wire things up.

Doepfer also sell pre-assembled circuits for making custom MIDI controllers.

Various sensors, circuit modules, and robotics gear which can be hooked up and used with Pure Data.

Open Sound Control is a newer MIDI-type protocol which allows Pure Data to communicate directly with applications such as Max/MSP, Csound, and Supercollider. It also interfaces with the powerful Jazz Mutant Lemur touchscreen hardware controller.

This free Windows-only visual recognition software which can communicate with Pure Data using Open Sound Control.

The home page of the Netpd project, which encourages musicians to jam on-line in real time using Pure Data.

Instructions for setting up an on-line radio station on a Linux web server running Pure Data.