Next: Contents Contents

# HOWTO
write an External
for puredata

johannes m zmölnig
institute of electronic music and acoustics, graz

### Abstract:

pd is a graphical realtime-computermusicsystem 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 selfmade 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) from pd-externals-HOWTO.pdf and as pdf(German) from pd-externals-HOWTO_de.pdf

- Contents
- definitions and prerequisites
  - classes, instances, objects
  - internals, externals und libraries
    - Internal
    - External
    - Library
- my first external: `helloworld`
  - the interface to pd
  - a class and its dataspace
  - methodspace
  - generation of a new class
    - class_new
    - class_addbang
  - constructor: instantiation of an object
  - the code: `helloworld`
- a simple external: `counter`
  - object-variables
  - object-arguments
  - constructor
  - the countermethod
  - the code: `counter`
- a complex external: `counter`
  - extended dataspace
  - extension of the class
  - construction of in- and outlets
  - extended methodspace
  - the code: `counter`
- a signal-external: `pan~`
  - variables of a signalclass
  - signal-classes
  - construction of signal-inlets and -outlets
  - DSP-methods
  - perform-routine
  - the code: `pan~`
- pd's message-system
  - atoms
  - selectors
- pd-types
- important functions in ``m_pd.h''
  - functions: atoms
    - SETFLOAT
    - SETSYMBOL
    - SETPOINTER
    - atom_getfloat
    - atom_getfloatarg
    - atom_getint
    - atom_getsymbol
    - atom_gensym
    - atom_string
    - gensym
  - functions: classes
    - class_new
    - class_addmethod
    - class_addbang
    - class_addfloat
    - class_addsymbol
    - class_addpointer
    - class_addlist
    - class_addanything
    - class_addcreator
    - class_sethelpsymbol
    - pd_new
  - functions: inlets and outlets
    - inlet_new
    - floatinlet_new
    - symbolinlet_new
    - pointerinlet_new
    - outlet_new
    - outlet_bang
    - outlet_float
    - outlet_symbol
    - outlet_pointer
    - outlet_list
    - outlet_anything
  - functions: DSP
    - DSP-method
    - perform-routine
    - CLASS_MAINSIGNALIN
    - dsp_add
    - sys_getsr
  - functions: memory
    - getbytes
    - copybytes
    - freebytes
  - functions: output
    - post
    - error
- About this document ...