This is a short step-by-step Pure Data tutorial for complete beginners.
After this tutorial, you will understand the basics of Pure Data and build a simple music sequencer using it.
Pure Data (or Pd) is a real-time visual programming language designed for musicians, visual artists, and performers to create software without writing lines of code. Pure Data is commonly used for live music performance, VJing, sound design, 2D/3D graphics processing, composition, audio analysis, interfacing with sensors, and cross-platform app and web development. Pure Data runs on macOS, Windows, Linux, Raspberry Pi, iOS, Android, and web browsers.
Programming with Pure Data is a unique interaction that is much closer to the experience of manipulating things in the physical world. The most basic unit of functionality is a box, and the program is formed by connecting these boxes together into diagrams that both represent the flow of data while actually performing the operations mapped out in the diagram. Because the programming is done visually, many artists find it a more intuitive tool than traditional text-oriented programming languages.
The real advantage of Pure Data is that it works in "real-time". This means that changes can be made in the program even as it is running, and the user can see or hear the results immediately. This makes it a powerful tool for artists who would like to make sound or video in a live performance situation.
Pure Data has been used as the basis of a number of projects, as a prototyping language and a sound engine.
Here are some projects that used Pure Data
Visit https://puredata.info/downloads/pure-data and click one of the download links depending on your platform.
If you are using Windows, open the downloaded installer file and follow the default instructions.
If you are using macOS, unzip the downloaded file and move it to the Applications folder.
In case the app doesn't open because of the verification issue, open the app while holding down the Ctrl key.
If you are using Linux, run the following terminal commands to install and open Pure Data:
sudo apt-get update -y
sudo apt-get install -y puredata
puredata
If you open Pure Data, you will see a console window that looks like this:
The console window is mainly used to see information about the patch you are working on, as well as for debugging (correcting errors in your patch). So keep this window in a place where you can find it on your screen.
Under the "File" menu in the console window, select "New" to create a patch:
You will see a patch window that looks like this:
Under the "Put" menu in the patch window, select "Object" to place an object box in your patch.
Click on the patch to drop the object box in its place. Type "print" inside the box and click again outside the box, you will create a [print] object.
Under the "Put" menu in the patch window, select "Message" and type "Hello World" inside the box.
You should notice that both the object and the message boxes have small rectangles at the corners.
If these are at the top of the object, they are called "inlets", and at the bottom, they are called "outlets".
The inlets and outlets are used to receive and send data between objects while they are connected.
Click the outlet of [Hello World(, then drag the cable to the inlet of [print] to make a connection like this:
There are types of objects that you can interact with your mouse. A message box is one of them.
To make the message box clickable, we need to change out of "Edit Mode" and into "Play Mode".
You can do this by clicking on the "Edit Mode" item in the "Edit" menu, or by using the shortcut Ctrl+E. (Cmd+E on macOS)
When you enter into "Play Mode", you will see that the pointing finger cursor changes into an arrow cursor.
This change signifies that the mouse will interact differently with the elements within the patch.
Now, if you click on the [Hello World( message box, you will see the message printed to the console window like this:
In "Edit Mode", click on a cable to select it, then hit the Backspace key to delete the cable.
Now, if you click on the [Hello World( message box again in "Play Mode", you will no longer see the message printed to the console window since they are disconnected.
In "Edit Mode", clicking on the patch and dragging will select multiple objects to move, copy, duplicate, or delete.
You can edit the selected objects by clicking on one of the items in the "Edit" menu or by using the shortcuts.
Try duplicating and deleting the selected objects using the shortcuts.
- Duplicate: Ctrl+D (Cmd+D on macOS)
- Delete: Backspace
To get help associated with a specific object, you can right-click it then select "Help" from the drop-down menu.
You will see a help patch that explains what the object does and also shows several examples of its use.
Now let's create a simple step sequencer. A step sequencer is a tool that allows us to store musical data (e.g. note, velocity) into individual steps to create musical patterns. In this tutorial, we are going to create a simple 4-step sequencer that stores 4 note values that are played in a loop.
In an empty patch window, under the "Put" menu, select "Bang" to create a bang button.
Create an object box using Ctrl+1 (Cmd+1 on macOS) and type "float" inside it to create a [float] object.
Under the "Put" menu, select "Number" to create a number box, duplicate it and make connections like the following:
In "Play Mode", try dragging the upper number box up or down to change its value.
If you click on the bang button, the [float] object will output its stored value.
As you can see, the [float] object stores a number through its right inlet, and outputs the value when it receives a message named "bang" through its left inlet. "bang" is a special message, which many objects interpret as "do an action right now!".
Create a [+ 1] object above the upper number box and make connections like the following:
In "Play Mode", if you click on the bang button, the output number will be increased by 1.
This is because the output number + 1 is stored in the [float] object whenever it outputs a value.
Note: The number boxes are being used in this example as a visual aid and it will work identically without going through them.
Create a [mod 4] object which outputs the remainder when the input number is divided by 4.
And then create another number box below it and make connections like the following:
In "Play Mode", if you click on the bang button, the output number will be wrapped between 0 and 3.
Create a [select 0 1 2 3] object which receives a number and distributes the "bang" messages to the corresponding outlets.
Place it at the bottom and make a connection like the following:
Create four bang buttons that will be used as a visual aid.
Place them at the bottom and make connections like the following:
In "Play Mode", if you click on the bang button at the top, the below 4 bang buttons will flash according to the output number.
Instead of you clicking the bang button to output a "bang" message, we can automate this using a [metro] object.
A [metro] object outputs "bang" messages periodically given the time interval between them.
Under the "Put" menu, select "Toggle" to create a toggle button and also create a [metro 300] object below it.
Place them at the top and make connections like the following:
In "Play Mode", if you click on the toggle button to enable it, the [metro 300] object will start and output "bang" messages at 300-millisecond intervals.
You can stop the [metro 300] object by clicking on the toggle button again to disable it.
Now, create and connect the four [float] objects to each bang button at the bottom like the following:
Under the "Put" menu, select "Vslider" to create a vertical slider.
Create four vertical sliders and four number boxes and make connections like the following:
Create a number box at the bottom and make connections like the following:
In "Play Mode", enable the toggle button and try changing values of sliders by dragging them up or down.
You will see the bottom number box outputs the slider values according to the step.
This output number will be used as a MIDI note number in our sequencer to change the pitch (or the frequency of a sound wave).
To do this, create a [mtof] (midi to frequency) object at the bottom which converts the incoming midi numbers to frequency.
Also, create an [osc~] (oscillator) object which outputs a pure sine wave audio, given the input frequency.
Make connections like the following:
Create a [dac~] (digital-to-analog converter) object at the bottom and make connections like the following:
Warning: Be sure to set the audio volume on your computer fairly low since it can be pretty loud.
In the console window, click on the DSP toggle button to turn the audio on.
Try moving the sliders to create musical patterns.
You can change the slider's output range by right-clicking on a slider and selecting Properties from the drop-down menu.
Change each slider's output range to between 36 and 84. (C2 ~ C6)
You can also change other properties such as size and colors.
Under the "File" menu in the patch window, select "Save" to save the patch.
Congratulations! You have now created a functioning sequencer in Pure Data.
We have chosen the above methods to build a sequencer however there are many other ways to build one, including using a table.
You will discover these as you delve deeper into the world of Pure Data.
If you are interested in learning more about Pure Data, there are plenty of resources and communities to help you.
-
Video tutorials:
-
Text tutorials:
-
Books:
-
Communities: