Pure data

format_list_bulleted Contenido keyboard_arrow_down
ImprimirCitar
Screenshot of Pure Data.

Pure Data (or Pd) is a visual programming language developed by Miller Puckette during the 1990s for the creation of interactive computer-based music and multimedia works. Although Puckette is the main author of the software, Pd is an open source project and has a large developer base working on new extensions to the program. It is released under a license similar to the BSD license.

Pd is very similar in scope and design to Puckette's original program, Max (developed when he was at IRCAM), and is to some degree interoperable with Max/MSP, the commercial successor to the Max language. Both Pd and Max are arguable examples of 'data flow' programming languages. In this type of language, functions or "objects" are connected or "patched" with each other in a graphical environment that models the flow of control and audio. Unlike the original version of Max, however, Pd was always designed to do signal processing and control rates in the native CPU, rather than offloading synthesis and signal processing to a PDS board (such as the Ariel ISPW that was used for Max/FTS). The Pd code is the basis of David Zicarelli's MSP extensions to the Max language for doing audio processing in software.

Like Max, Pd has a modular code base with externals or objects that are used as building blocks for programs written in the software. This makes the program arbitrarily extensible via a public API, and encourages developers to add their own audio and control routines, either in the C programming language or, with the help of external ones, in Python, Javascript, Ruby, and potentially other languages as well. However, Pd is a programming language in its own right. Modular and reusable units of code, natively written in Pd, called "patches" or "abstractions", are used as standalone programs and shared freely among the Pd user community, and no other programming skills are required to use Pd but it helps.

With the addition of the external "Graphical Environment for Multimedia" (GEM), and other external ones designed to work with it (such as Pure Data Packet, PiDiP for Linux, framestein for Windows, GridFlow for n-dimensional array processing that integrates Pure Data with the Ruby programming language, etc.), it is possible to create and manipulate video, OpenGL graphics, images, etc, in real time with seemingly endless possibilities for interactivity with audio, external sensors, etc.

In addition, Pd is natively designed to enable live collaboration over networks or the Internet, allowing musicians connected via LAN, or even in different parts of the world, to make music together in real time.

The units where the code is programmed are called "patch" or abstractions, they are used as independent programs and freely shared among the community of Pd users. Patches consist of different objects interconnected with each other. In its upper part we will find the inputs, where numerical values or other types of data will be sent, and in the lower part the output of these.

Subpatch.

There is also the possibility of creating secondary patches known as subpatches. They are inside the main patch. They are created by writing the letters “pd” followed by a space and the name that you want to give to that subpatch in an object, as shown in the figure. Clicking on it opens the window where we find the code of our subpatch.

The program has two states that the user can be in. In edit mode or in run mode. To change from one state to another we will type Ctrl+E. When we are in edit mode, we can modify the content of the boxes, or the connection between them. In the execution mode we have the possibility of starting the whole patch, and modifying values during its reproduction or when it is stopped. We can send bangs, modify the value of variables within the "number" objects, or activate and deactivate sectors of the code with the [toggle] object, activated when it has a cross and deactivated when it doesn't.

Object Types

Pd objects.

Object: Its behavior will depend on the text that it has entered in itself. The program has some predefined objects, programmed by third parties in different languages such as C. The Pd recognizes the type of object and that box already behaves as such.

Numbers: Their use can be diverse, from controlling the value of the signal at different points in the patch, to initializing values that are passed to objects that control, for example, an opacity level of an image.

Messages: They are provided with information that is passed to the objects.

Symbol: This item holds a symbol until it receives a [bang] or another symbol. It is then when this symbol comes out of the object, through the bottom of the box. These objects are only offered in Pd if you have the appropriate library downloaded and correctly installed. They do not have to exist in the simple libraries, although they are usually included in the installation files.

Comment: we will use it to include clarifications within the different steps that our code follows.

Most important items

Oscillator.

The [osc~] object generates a sinusoidal signal. The oscillation frequency will depend on the value entered in the input of the object in the upper left. Whenever we place an oscillator, we also have to place a multiplier and a digital analog converter (dac~). This is done because the "osc~" by default has the maximum amplitude at 1, so we multiply it by 0.1 to reduce its amplitude and then send it to the "dac~". The “dac~” object has two inputs that refer to the two output channels of your machine's sound card.

Bang.


A [bang] has the function of activating the action that is immediately connected after it.


metro_pd.

Metro: Send series of [bang] periodically. We'll create it by writing the word “meter” into an object. This object has two inputs, the one on the left accepts [bangs]. He makes the subway start running; it also accepts messages with the text “stops”, stopping the operation of the metro. We can also send you any non-zero number to activate it. If a zero is sent to it, the meter stops sending [bangs]. In the entry on the right we introduce the number that governs the frequency of sending bangs, the unit of this value is milliseconds. Within the same [meter] box, after the word meter and followed by a space, introduce a number that the object already understands as the period.

Start


Start: Execute the patch objects that it has connected to itself. We will create the [start] object by writing the word “start” inside a message.



Stop: Stops the execution of the currently running patch. We will create it by writing the word “stop” inside a message.

Selector.

Select: It acts as a selector according to an initially given numerical condition. We create it by introducing the word “select (space)condition”. In this way, when the input value is equal to the condition, a bang will be sent through the output on the left. If they don't match, the bang will be sent out the right output. Multiple concurrent conditions can be entered separated by spaces. As many starts as conditions plus a final will be created. When the value matches one of the conditions, the bang will be sent by the output that corresponds to that value. If it doesn't match, the [bang] will always be sent by the last output, the one furthest to the right.

Moses: We will write the word “moses” inside an object in order to have it operational. It contains two inputs and two outputs. In the input on the left we connect the value that is in the process and on the right the value that we want to act as a border. If the value of the process is less than the border, it takes the input value from the output on the left. On the other hand, if the value is equal to or greater than the value that acts as the border, it will take the number from the output on the right. We could liken [moses] to a simultaneous low pass and high pass filter.

Installation in GNU possible problems and solutions

To install Pd in GNU we must unzip the package downloaded with the program and run the file with the “.deb” extension. The first possible problem that we can find is that the Ubuntu Studio distribution already has a Pure Data installed by default. Because it is recommended to use the Pd_extended version (although this is something that varies very often) we will have to uninstall Pure Data from GNU/linux Ubuntu, so that, when installing the new one, we do not have problems with folder sharing. Another very common and important factor when we install programs in GNU are the secondary library dependencies that may exist. It is necessary to install them for the proper functioning of the program. In the case of Pure Data and some external libraries (externals), some dependencies have to be installed through the package manager called Synaptic. There we can find which ones we need.

Once the correct functioning of the Pd has been tested, to optimize the program's resources, we load, at start up, the most common libraries that will be used, to avoid having to import them every time they want to be used. In this way, when you start Pd on your machine, they are automatically loaded.


Audio/MIDI test.

Linux

Quick introduction

Once we have the Pd stable on our machine, we proceed to do a first test of the program to verify that the connection with our sound card is correct. We will find this in Media> test audio and MIDI. There we can generate a test signal (a tone, pink noise,...) listening to it through our speakers, thus checking that everything works correctly.

To get to know the Pd environment, we can start by opening examples that we will find in the documentation files inside the Pd folder. There are audio and video patches that are used to familiarize yourself with the program. When we want to create our own patch, in the Pd window we go to File>New and the window opens where we will introduce our objects that we will connect between them thus creating our application.

Pdp, pidip and opencv libraries

PDP object that creates a grid that divides the image.

The PDP library is a collection of objects that is used to process a lot of data. It works on Linux and most objects also work on Mac OSX. Once downloaded, the installation in Linux is done through the terminal, compiling and executing the installation file that is attached, as follows:

./configure

sudo make

sudo make install

When the data is already represented as a packet inside Pd, it is possible to start manipulating it. The PiDiP library are video objects that complete the collection of PDP objects. The installation is identical to that of PDP, from the terminal we execute the same commands, thus being ready for use.

pdp_opencv distrains.

There is also another library referring to the OpenCV video call. It is an open library developed by Intel. This library provides a high level of image processing functions. It allows the programmer to create applications in the domain of digital vision. OpenCV is Open Source thus allowing it to work on many platforms. This library allows us to do basic operations, image processing, model recognition analysis, structural analysis, 3D reconstruction, camera calibration, motion analysis, graphic interface and acquisition, etc. It implements a wide variety of tools for image interpretation, such as feature detection or shape analysis (geometry, contour processed at that instant), among others.

Patch patterns

Example of oscillator.

A good first introduction to Pd can be the generation of a sinusoidal tone. For this we will use the [osc~] object. At the left input we will connect a message with a number inside that will act as the oscillation frequency. We will send its output to a multiplier that will convert this frequency into audible and finally we will send this to a digital analog converter [dac~] to be able to reproduce it through the speakers of our machine. Once we have created this patch, we can modify the frequency by clicking and holding down the mouse on the number message and moving the cursor up and down, thus increasing and decreasing the frequency value.


Open external device. Web camera.

To open an external device, such as a webcam, we must write the word “open” in a message followed by a space and the path where this device is located. We will connect this to the object that allows us to view the image according to our operating system, in Linux it would be pdp_v4l (video for Linux). We also connect another message to this object where we indicate the channel through which we want to send the information. Finally, we will connect a [meter] to [pdp_v4l], giving it information on the periodicity with which we want it to show us the images that the camera is capturing. To have movement continuity we will give it a standard value of 100ms. If the user likes it, we can also rotate the image horizontally so that the effect generated when viewing the image is mirror-like. To achieve this we will connect the output of [pdp_v4l] to the [pdp_flip_lr] object. With this we already have, in a separate window, the image that the camera is capturing.

Material in Spanish

  • Interactive musical systems Course documents of interactive musical systems by Sergi Jordà
  • Electronic music workshop Documents of the electronic music workshop course by Sergi Jordà
  • Introduction course to GEM (breakable link available on the Internet Archive; see history, first version and last). Introduction to GEM and live cinema by Carles Sora
Más resultados...
Tamaño del texto:
undoredo
format_boldformat_italicformat_underlinedstrikethrough_ssuperscriptsubscriptlink
save