welcome to puredata.wikispaces.com

Pure Data WIKI


This page was set up by Edward Kelly to provide an introduction to Pure Data (PD).
PD was created by Miller Puckette and many others have contributed to its development over the years.
The community site is at http://puredata.info

Learning Pure Data

Pure Data was originally created as a computer music dataflow programming environment, but it has been expanded and enhanced to include objects for manipulating video and 3D graphics, neural networks and a huge variety of sound and image analysis and creation tools. You can begin learning Pure Data techniques for any object or library of objects by searching the help files and examples from the help -> browser -> Pure Data, and also for any externals you have downloaded (more on this later) but there are several online tutorials and books available. Here are some of them:
  1. http://www.pd-tutorial.com/ is an online version of the book loadbang by Johannes Kreidler. It is concerned solely with sound synthesis techniques in Pure Data, but is a good place to start learning.
  2. Floss Manuals have a good beginners tutorial for Pure Data. You can find it at http://write.flossmanuals.net/pure-data/introduction2/ and it covers audio, dataflow and GEM (3D and video) programming for beginners.
  3. The manual to Pure Data (vanilla only) can be found at Miller Puckette's website here. Miller has also written a book, Theory and Techniques of Electronic Music - a comprehensive guide to computer music theory with applications in Pure Data.
  4. Dr Raphael Hernandez has a series of tutorials for beginners on YouTube.
  5. I have a Vimeo site I am developing with video tutorials: http://vimeo.com/puredata

Getting Pure Data

You can download the latest stable releases of PD at puredata.info/downloads
Pd is extendable using libraries of externals - objects created by programmers around the world. It used to be the case that a distribution with most of the available externals, called Pd-extended was available, but this is now dead. Instead, there are two distributions, Pd-l2ork (for Linux only) and Purr Data (for all flavours of operating system) that implement most of the available externals. In fact, Purr Data has taken over from pd-l2ork now and you will find that installers are named pd-l2ork (l2ork stands for Linux Laptop Orchestra) but will run on any platform. However, the newest versions of Pure Data also have a Find Externals entry in the help menu.
findExternals.png
Clicking the Show All button brings up the names of all the externals available to download. While this is good, there are two schools of thought when you're just getting started.

Using external libraries in Pd vanilla

Up until recently, installing externals was difficult, but there is a change with the Dekken system of library installation which Pd users should know about, and patches developed with older versions of Pd that use externals need to be adapted to work with this. You must declare the library in order to use objects from it. The way to do this is shown below.
external image declare_lib.png

Path settings in Preferences

It is a good idea to get the latest version of Pd from Miller Puckette's site, or from puredata.info. At the time of writing, the latest version of Pd is Pure Data 0.48.1. When you first start Pd-0.48.1, it asks you to create a default folder for patches and externals. When you download a library of external objects, it will automatically create a link in the Path element of the Preferences.
external image Path_Pd_048.png
While it used to be the case that objects found in the Path folders could simply be loaded by typing their name, it is now necessary to load them using the declare object as shown above. This is not the case with abstractions - they are automatically loaded if the folder is in the search path, but beware! If the abstractions use external libraries, they will need to contain the declare object for those libraries as the first object created. But how to change older patches? Make declare objects for each external library used, then select all, then shift-click the declare objects, cut-and paste every selected object. This re-orders the patch so that the declare objects are the first objects in the Pd patch.

Abstractions

An abstraction is basically a Pd patch saved to disk and then loaded inside another Pd patch. You can use abstractions without specifying the path in preferences, as long as they are in the same folder as the patch containing them. If you create a library of abstractions, then you can specify the path in the preferences so that you can use them every time.
external image abstraction1.png
A simple abstraction: mix~
Pd has an excellent feature for using abstractions called graph-on-parent. Right-click (or CTRL-click if you have a one-button mouse) on empty space inside a patch, and select properties. You can then check the box for graph-on-parent, specify x and y margins and sizes, and create graphical objects within that space which is shown as an orange box within the patch with GOP (graph-on-parent). This also works for subpatches, and every time the abstraction is invoked within a Pd patch, the GUI will appear provided that the patch is either saved in the same folder as the patch from which it is invoked, or the folder location of the patch is specified in the Path preference within Pd.
external image abstraction2.png
The guts of the mix~ abstraction

Purr Data

Arguably Purr Data is way more user-friendly, and has some really great features that save time such as connecting one outlet to many objects, or e.g. 6 messages to 6 inlets of a pack object. It also has a nicer looking interface, and most if not all of the externals you would want to use come pre-installed. You can download an installer for Max, Linux, Windows and even Raspberry Pi. for more information on Purr Data and where to get it, go here!
The other idea is that if you learn how to do everything with Pd vanilla (vanilla is the name for Milller Puckette's version of Pd with no externals) then you can be sure your patch will be more likely to work in 10 years time. There used to be a version called Pd-extended maintained by Hans Cristoph-Steiner on which Purr Data is based. For a number of years there wasn't a working replacement for Pd-extended, and patches built with Pd-extended were difficult or impossible for newbies to use with Pd vanilla.

If you are familiar with compiling software and working with build systems, you can get hold of the source code for Pd, externals and pretty much everything else by following the instructions on this page although the information on Pd-extended is quite old. Purr Data sources and release versions can be downloaded from the Github site. Follow the links on this page.

GEM is a 3D graphics library, and you can also work with images and video using the pix_ objects. You can project movies, textures, color and lighting onto 3d objects, interact with particle generators, simulate elasticity (with PMPD by Cyrille Henry) and import models made in Blender, Maya and 3DSMax (wavefront .obj files - a number of other software packages support this format). GEM works on Windows, Linux and Macintosh operating systems. There is also a library for dealing with Open Computer Vision (pix_opencv) and augmented reality (pix_artoolkit). pix-artoolkit comes with Purr Data.

PD List

Pure Data is open source software, so it is developed and maintained by a global community of people. It makes sense to consult the community when you have questions or problems with your patches by joining the PD List. It is by far the quickest way to find answers and ideas about PD. All you need is an email account. I recommend you use a Gmail or Yahoo account - don't use your university account as you will lose all your emails when you leave. I have had all the PD list emails filtered into a folder on my Yahoo Mail account for seven years now, and I have found it very useful to swap ideas and ask questions of the Pd community.
There is also the Pure Data forum:
http://puredata.hurleur.com/

Workshops at Camberwell

Every year since 2007 I have delivered some workshops at Camberwell College of Arts in London. Here are the examples presented in the 2018 session:
**Camberwell-2018.zip**

Programming the Arduino Board

The Arduino can be configured to accept a wide variety of digital and analogue inputs, and the boards can drive motors, solenoids and other electronic actuators. It's programming (Arduino sketch) needs to be uploaded every time it is plugged in, but you can plug in an external 9V power supply and disconnect it from the computer and it will continue to function. Obviously this works if you are creating a stand-alone Arduino sketch, but there are also interfaces suck as the XBee that you can use to connect the Arduino to a computer using a wireless interface (WIFI).

First download the Arduino software for your machine.
To use Hans Cristoph-Steiner's PDuino interface to PD load the file named Standard Firmata, as shown below:
Standard_Firmata.png

A new sketch will pop up with the Standard Firmata code in it. If you hit the Upload button as shown below, the code will be checked and uploaded to the board (if it checks out - if it doesn't compile you will see red messages in the lower panel of the sketch).
arduinoUpload.jpg
You should see two orange LEDs on the board flash, and when they stops flashing your board is programmed. The arduino IDE will also tell you when the board is ready for use.

PDuino

The PDuino interface gives you access to all of the functions of the standard firmata firmware for arduino. You will need to install the comport library for Pd, although this is present in Purr Data and Pd-l2ork distributions.
external image arduino-test.pd.png
PDuino 0.5 interface

The latest version of PDuino, 0.6, gives you a complete tutorial on how to set up the arduino board with Pd:
external image arduino-help.png
PDuino 0.6 interface
While this is useful for testing, it makes sense to strip the interface down to its basic components once you have determined what inputs and outputs your project will need.
The [arduino] object in the center of the patch is an abstraction - a patch that sits in the same folder as the master patch, and is used as though it were an object. Click on the [arduino] object and you will see the patch:
arduino_Pd.png
Save this in your project folder.
When you look at the arduino-test.pd patch from PDuino, you will see that the graphical interfaces to the [arduino] object all output messages that are sent to [arduino]. In fact, the [arduino] object is configured entirely using messages, and outputs from the object corresponding to inputs to the board are directed to Pd objects using [route analog digital] objects followed by [route 0] [route 1] etc.
[open 0( will open the connection to the arduino if it is on COM0 or the first USB connection. You can check which connection the arduino is on from the arduino IDE, from the Tools -> Serial menu. The order of the list of ports starts from 0 and enumerates up.
Digital pins on the arduino are set to input or output using [pinMode( messages - [pinMode 5 1( sets digital pin 5 to output mode, and [pinMode 8 0( sets digital pin 8 to input mode.
Analog inputs are enabled using [analogIns $1 1( messages (with the analog input number substituted for $1).
This guide is based on PDuino 4, and the interface has changed somewhat in the more recent version. The basic principle of it is the same however, and you can always find out how the messages to [arduino] are formatted by clicking on subpatches - [pd subpatch] or right-clicking on the subpatches with graphical interfaces and selecting open.

Once you have discovered what messages you need to configure your arduino, you can simplify the patch to what you need. Here is a patch that uses four analog inputs as triggers for a random sound generator patch:

basic_arduino.png
Each analog input (i.e. IR proximity sensor) generates a constant stream of values. In this case when the value goes above 0.12 the [> 0.12] object outputs a 1. When the output of this object [change]-s from a 0 to a 1, the 1 is [select]-ed and a [bang( message is sent via [send IR_1]. Elsewhere in the patch, a [receive IR_1] will be used to trigger a sound.
Notice the [mapping/resample 100] objects. These limit the speed of data throughput to 100ms. You will need to smooth this data if you want to use it to control audio signals. Check out the Camberwell_arduino patches above to find scaling and smoothing functions for Pd.

Sensors, Devices and Projects

There are many websites that offer sensor technology for sale, and here are some of the best.
http://www.skpang.co.uk/ is a great place to buy arduino and seeeduino boards, sensors and kits.
http://www.coolcomponents.co.uk is another great online shop, selling arduino related components, kits and boards.

http://www.sparkfun.com is a US site that sells a huge range of sensors, kits and related hardware.
http://makingthings.com is a US site selling sensor technology, with the widest array of sensors.
For a comprehensive list of specific Arduino selling sites - Arduino Buy at the main site.

Remember also that Maplin.co.uk CPC and RS Components are useful for electronics generally.
The cheapest sensor other than a homemade sensor is the piezo transducer from Maplin which can be used as a contact microphone, or to detect knocks.

Resistors

Many electronic components require that you connect them with a pull-down resistor. Resistors are colour-coded to indicate their value, and the chart shown below will tell you what value the resistor is.
external image ResCode.GIF
Most often, if the device is resistive then it will be connected with an extra resistor between the analog measurement pin and the ground. The circuit diagram is shown below for a Force Sensitive Resistor (FSR) - the zig-zag lines are the resistor and the FSR.
external image fetch.php?hash=e1e382&w=184&h=334&media=http%3A%2F%2Fwww.ladyada.net%2Fimages%2Fsensors%2Ffsrpulldownsch.gif
You can change the sensitivity of the device by changing the value of the resistor that goes from the ANALOG voltage pin to ground (DGND), but don't make it too low (<2.2K) or your project won't work properly.
Using digital inputs as switches is easy. A switch is fundamentally just two pieces of metal that come into contact, so you can make switches out of any metallic objects connected to two wires. Using tinfoil and sponges it is possible to make switches, but other methods using this principle will work just as well.
switch.png
Here, the switch S1 is connected to Digital input 3 (D3) but a resistor (typically 10K) is used to ground the circuit, otherwise it will not work.

Pure Data Art

A small collection of assorted projects on the web:
Tag Magic's Visual Circus: http://www.youtube.com/watch?v=WNl9NoTD1jM
Fugue Kronostruktur: http://www.youtube.com/watch?v=nBO-G0ALA2Y
Puredata VJ Patch: http://www.youtube.com/watch?v=iZ-r95dH7uc
Vivarium Interactif: http://www.youtube.com/watch?v=6-AUl-GK9zc
Polychroma: http://www.youtube.com/watch?v=zNFhaSN5xXo
Reactable: http://www.youtube.com/watch?v=sL033Dspq8I

Miscellaneous:
http://www.youtube.com/watch?v=l28GQ9SMpNM
http://www.youtube.com/watch?v=XQTXVsCBle0
http://www.youtube.com/watch?v=ki1Jw0RtDLE
http://www.youtube.com/watch?v=LB88IHB44gU
http://www.youtube.com/watch?v=QXcYf3tS3m0
http://www.youtube.com/watch?v=i0sEGBj5tCk
http://www.youtube.com/watch?v=g_hiz-Kx0kM


Check out these Youtube Channels:
http://www.youtube.com/user/santorcuato76?blend=21&ob=5
http://www.youtube.com/user/buZztiaan?blend=22&ob=5

Also:
http://obiwannabe.co.uk/ - Andy Farnell has some great tutorials about creating sound FX in Pure Data
http://musa.poperbu.net/content/view/73/50/#mandril - Pure Data patches for video and graphics manipulation
http://www.katjaas.nl/home/home.html - Katja Vetta's homepage, with the Slice Jockey
http://www.katjaas.nl/puredata/puredata.html - A good set of links to various Pure Data projects you can download
http://www.ekran.org - Ben Bogart makes art using artificial neural networks to organize image streams
http://marcodonnarumma.com/ - Marco Donnarumma uses biometric sensors to control Pure Data performances
http://www.uni-weimar.de/medien/wiki/PDCON:Start - the most recent Pd Convention was held in Weimar / Berlin in 2011
http://tvestroy.danslchamp.org/ - TVestroy is (or was) a project that generates images and sound, where the signal creates both the image and the sound. Check out some performances and demos of this on Youtube: http://www.youtube.com/results?search_query=tvestroy WARNING: If you suffer from epilepsy do NOT visit this website.

http://estereotips.net/ is an artist-collective site run by Luca Carruba in Barcelona, with many interesting projects documented

Not Pure Data!

Here is the link to the website for my undergraduate course in processing:
http://lcc.sharktracks.co.uk/imd