next up previous contents
Next: my first external: helloworld Up: HOWTO write an External Previous: Contents   Contents

Subsections

definitions and prerequisites

pd refers to the graphical realtime-computermusicprogramme puredata 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++ 6.0 (vc6) on windos-plattforms, will be necessary.

classes, instances, objects

pd is written in the programming-language C. Due to its graphical nature, pd ist 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.

internals, externals und libraries

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 systemdependent naming convention:

library linux irix Win32
my_lib my_lib.pd_linux my_lib.pd_irix my_lib.dll

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 to 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.


next up previous contents
Next: my first external: helloworld Up: HOWTO write an External Previous: Contents   Contents
IOhannes m zmoelnig 2001-09-13