Conditionals for Pure Data: Interactive tutorial 2: Using the ‘expr’ object.

This is the second interactive tutorial regarding making your own conditionals in the Pure Data open-source programming platform. This time the ‘expr’ object is used.  Click here to download. Please note that this particular object chews up more CPU than those featured in the previous tute. You will also first need to have Pure Data (Pd) installed on your computer to use this app (it’s free). The reason for emphasizing the use of conditionals in Pd here is twofold: (i) functions that exploit variables and probability form the bedrock of simple generative music programs, and (ii) unlike Max/MSP, Pure Data doesn’t come with conditionals included: you have to make them yourself or use someone else’s.

Conditionals are decision-making blocks of code: something like rules in a game. You can tell parts of your program to do something WHEN or IF specific criteria have been met, or ELSE to do something different.

When making a generative music program for the first time, there’s no need to worry too much about decisions regarding each conditional’s behaviour or where these little blocks of code fit into the overall program. What’s most important is that they’re there at all. You can have a lot a fun just taking any music programs you might already have and letting the (numerical) output of one part of the program influence the behaviour of another. In this way, you can automate small sections of a program and, bit by bit, get a feel for what conditionals can do. The more parameters and triggers that you connect, the closer you get to creating a fully-fledged generative music app.

Each of the conditionals illustrated above (and combinations thereof) can be embedded within ‘pd objects’ (or as ‘abstractions’) which are something like Pd’s equivalent functions. This will not only make your Pd patches cleaner, but you’ll see similarities with the architecture of modular synthesisers, where you can have fun plugging ‘this’ into ‘that’ to see what happens.

If you’re a John Cage type, then as long as the program flows well you’ll probably be happy with the results, regardless of the aesthetic feel. If you’re more of a Brian Eno, then you’re likely to be more selective. In the latter  case, you might like to try out different combinations of conditionals, as well as, their relationship to the various parameters being influenced, such as those belonging to: tone generators; filters; pitches; the triggering of sequences (and sequencers); (opening/closing) gates (‘spigots’ as they’re called in Pd); tempo; choosing pathways (form, challenge ‘levels,’ duration etc), or anything you can imagine! Tinker away until you find results that please you.

To get more information regarding what each discreet Pd object can do, control+click on the relevant object (Apple users). Enjoy.

The expr object is created by Shahrokh Yadegari. The downloadable interactive tutorial is (cc) 2019 Marshall Heiser (Attribution 4.0 International). This license lets you distribute, remix, tweak, and build upon my work, even commercially, as long as you credit me for the original creation. Any derivatives will also allow commercial use. Click here for more licence details.



Conditionals for Pure Data: Interactive tutorial

Computer programs need to determine how to proceed at certain points in their program flow, depending on whether certain predetermined (or variable) conditions have been met or not. Such operations are a mainstay of computing and are known as a “conditional” test. For example, when a condition has been met, a result of TRUE (“1”) is produced, otherwise a FALSE (“0”) message results: these are known as Boolean values. Conditional tests (or conditionals for short) are particularly useful in programs such as “generative” music compositions, where the “rules of the game” are predetermined, and require no further input from the programmer after the piece has started.

The conditionals provided in Pure Data (Pd) are very basic, consisting of simple relational operators (such as == [“equals”], != [“not equals”], <, <=, >,  >=) and logical operators ( && [“and”],  || [“or”]). In order to make your own conditional objects that match the complexity of what Max/MSP offers as standard, you’ll need to have a look at the 9 (interactive) examples illustrated above. By changing the values in the yellow boxes, each test will produce one of two possible outcomes.

Whereas Pd’s relational and logical operators produce Boolean values, a “Select” object is necessary in order to produce a “bang” result (which is often necessary when programming in Pd). In the examples provided, the select object has been used to produce either a bang (only if a TRUE value results) or two different bangs (one for TRUE and another for FALSE).

Click here to download the interactive tutorial. Please note, you’ll first need to have Pure Data (Pd) installed on your computer to use this app (it’s free). Once you understand how each of the provided complex conditionals work, you can then embed them in their own subpatches, making your patcher window much less cluttered (as illustrated in the orange square next to example 1. Click on the pd X==Y object to see “inside”). In order to get more information on what each discreet Pd object can do control+click (Apple users*) on the relevant object. Enjoy.

The downloadable interactive tutorial is (cc) 2016 Marshall Heiser (Attribution 4.0 International). This license lets you distribute, remix, tweak, and build upon my work, even commercially, as long as you credit me for the original creation. Any derivatives will also allow commercial use. Click here for more licence details.


Pure Data: Major Scale/Circle of 5ths App

This slideshow requires JavaScript.

Click here to download this app for free.

This is an app I designed and coded a few years ago using Pure Data (Pd). I did it as an exercise in coding the Graphic User Interface (GUI) features of the platform. It functions as an interactive music theory learning aid and visually/aurally indicates the 12 possible major scales, their note names/scale-position numbers, and their overall relationships according to the “circle of fifths.”

To use it, simply select a scale from the red “circle of fifths” panel. The virtual piano keyboard notes will indicate the notes of the chosen scale (in green) along with their scale-position numbers. Use your computer mouse to play the notes by clicking on the green keys. To remove the green keys, hit “reset.”

You will need to have Pure Data (click here) already installed on your computer to use this app*. Turn your computer audio volume down to zero (this is standard health and safety procedure when using audio applications). Open the file and click the “AUDIO ON/OFF” toggle switch so that it shows an X (this turns Pd’s audio engine on). Now, hit any virtual piano key whilst gradually turning up your computer volume to a comfortable level. You’re ready to go.

If you are new to Pd and experience any problems hearing the audio, select the “MEDIA” drop-down menu in Pd. Here you can (amongst other things) test your audio/MIDI settings (with test tones etc). Be sure not to have your computer audio output or speakers set too high during this process!

If you would like to learn how to make an interaction virtual keyboard such as the one featured click here to read a very good free online tutorial by Johannes Kreidler (translated by Mark Barden). It’s an extract from Kreidler’s book Loadbang: Programming Electronic Music in Pd (2013). Click here to buy the paperback edition of Loadbang: Programming Electronic Music in Pd through

*Once again, apologies to PC users if you experience any problems. These instructions are designed for Apple OS users, since it has become the defacto industry-standard for audio. Please note: Pure Data is however available for Windows and Linux users.

This app is (cc) 2015 Marshall Heiser. (Attribution-ShareAlike 4.0 International). This license lets you remix, tweak, and build upon my work even for commercial purposes, as long as you credit me and license your new creations under the identical terms. Any derivatives will also allow commercial use. Click here for more licence details.


Pure Data: Reference Card

If you use the Pure Data (Pd) visual data-flow programming platform, or plan to, then this downloadable pdf will be essential. It outlines the correct names and functions of the Pd “objects.” Without this chart you’ll find yourself forever stalling, as you try to find that object you need and can remember by function, but not quite by name. To create an object using this chart, simply enter “edit” mode (command-click + E)* and command-click + 1 on the “patcher” window (not the Pd window), or select “object” from the “Put” menu. Type in the object’s name and you’re done. To find out more about what each object does simply control-click the object and select “help.” This very useful reference tool was kindly created/shared by Karim Barkati and may be freely distributed (see license details below).

CLICK HERE to download the Pure Data Reference Card.

*My apologies to all the PC users out there. Since Apple computers have become the standard for the audio industry I’ve adhered to this standard for the sake of simplicity (please use your PC equivalents).

Copyright (c)  2010 Karim Barkati <>. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.