write an External
for Pure Data

IOhannes m zmölnig

institute of electronic music and acoustics

March 25, 2014


Pd is a graphical real-time computer-music system that follows the tradition of IRCAMs ISPW-max.

Although plenty of functions are built into Pd, it is sometimes a pain or simply impossible to create a patch with a certain functionality out of the given primitives and combinations of these.

Therefore, Pd can be extended with self made primitives (“objects”) that are written in complex programming-languages, like C/C++.

This document aims to explain how to write such primitives in C, the popular language that was used to realize Pd.

You can download this HOWTO as pdf (English).

1 definitions and prerequisites
 1.1 classes, instances, objects
 1.2 internals, externals und libraries
2 my first external: helloworld
 2.1 the interface to Pd
 2.2 a class and its data space
 2.3 method space
 2.4 generation of a new class
 2.5 constructor: instantiation of an object
 2.6 the code: helloworld
3 a simple external: counter
 3.1 object-variables
 3.2 object-arguments
 3.3 constructor
 3.4 the counter method
 3.5 the code: counter
4 a complex external: counter
 4.1 extended data space
 4.2 extension of the class
 4.3 construction of in- and outlets
 4.4 extended method space
 4.5 the code: counter
5 a signal-external: pan~
 5.1 variables of a signal class
 5.2 signal-classes
 5.3 construction of signal-inlets and -outlets
 5.4 DSP-methods
 5.5 perform-routine
 5.6 destructor
 5.7 the code: pan~
A Pd’s message-system
 A.1 atoms
 A.2 selectors
B Pd-types
C important functions in “m_pd.h”
 C.1 functions: atoms
 C.2 functions: classes
 C.3 functions: inlets and outlets
 C.4 functions: DSP
 C.5 functions: memory
 C.6 functions: output