Pd refers to the graphical real-time computer-music environment Pure Data by Miller S. Puckette.
To fully understand this document, it is necessary to be acquainted with Pd and to have a general understanding of programming techniques especially in C.
To write externals yourself, a C-compiler that supports the ANSI-C-Standard, like the Gnu C-compiler (gcc) on linux-systems or Visual-C++ on windos-plattforms, will be necessary.
Pd is written in the programming-language C. Due to its graphical nature, Pd is a object-oriented system. Unfortunately C does not support very well the use of classes. Thus the resulting source-code is not as elegant as C++-code would be, for instance.
In this document, the expression class refers to the realisation of a concept combining data and manipulators on this data.
Concrete instances of a class are called objects.
To avoid confusion of ideas, the expressions internal, external and library should be explained here.
Internal An internal is a class that is built into Pd. Plenty of primitives, such as “+”, “pack” or “sig~” are internals.
External An external is a class that is not built into Pd but is loaded at runtime. Once loaded into Pd’s memory, externals cannot be distinguished from internals any more.
Library A library is a collection of externals that are compiled into a single binary-file.
Library-files have to follow a system dependent naming convention:
The simplest form of a library includes exactly one external bearing the same name as the library.
Unlike externals, libraries can be imported by Pd with special operations. After a library has been imported, all included externals have been loaded into memory and are available as objects.
Pd supports two modes to import libraries:
The first method loads a library when Pd is started. This method is preferably used for libraries that contain several externals.
The other method should be used for libraries that contain exactly one external bearing the same name. Pd checks first, whether a class named “my_lib” is already loaded. If this is not the case1, all paths are searched for a file called “my_lib.pd_linux”2. If such file is found, all included externals are loaded into memory by calling a routine my_lib_setup(). After loading, a class “my_lib” is (again) looked for as a (newly loaded) external. If so, an instance of this class is created, else the instantiation fails and an error is printed. Anyhow, all external-classes declared in the library are loaded by now.
1If a class “my_lib” is already existent, an object “my_lib” will be instantiated and the procedure is done. Thus, no library has been loaded. Therefore no library that is named like an already used class-name like, say, “abs”, can be loaded.
2or another system-dependent filename-extensions (s.a.)