Next: pd-types Up: HOWTO write an External Previous: a signal-external: pan~ Contents
Subsections

- atoms
- selectors

# pd's message-system

Non-audio-data are distributed via a message-system. Each message consists of a ``selector'' and a list of atoms.

## atoms

There are three kinds of atoms:

- A_FLOAT: a numerical value (floatingpoint)
- A_SYMBOL: a symbolic value (string)
- A_POINTER: a pointer

Numerical values are always floatingpoint-values (`t_float`), even if they could be displayed as integer values.

Each symbol is stored in a lookup-table for reasons of performance. The command `gensym` looks up a string in the lookup-table and returns the address of the symbol. If the string is not yet to be found in the table, a new symbol is added.

Atoms of type A_POINTER are not very important (for simple externals).

The type of an atom `a` is stored in the structure-element `a.a_type`.

## selectors

The selector is a symbol that defines the type of a message. There are five predefined selectors:

- ```bang`'' labels a triggerevent. A ``bang''-message consists only of the selector and contains no lists of atoms.
- ```float`'' labels a numerical value. The list of a ``float''-Message contains one single atom of type A_FLOAT
- ```symbol`'' labels a symbolic value. The list of a ``symbol''-Message contains one single atom of type A_SYMBOL
- ```pointer`'' labels a pointer value. The list of a ``pointer''-Message contains one single atom of type A_POINTER
- ```list`'' labels a list of one or more atoms of arbitrary type.

Since the symbols for these selectors are used quite often, their address in the lookup-table can be queried directly, without having to use `gensym`:

selector | lookup-routine | lookup-address
`bang` | `gensym("bang")` | `&s_bang`
`float` | `gensym("float")` | `&s_float`
`symbol` | `gensym("symbol")` | `&s_symbol`
`pointer` | `gensym("pointer")` | `&s_pointer`
`list` | `gensym("list")` | `&s_list`
-- (signal) | `gensym("signal")` | `&s_symbol`

Other selectors can be used as well. The receiving class has to provide a method for a specifique selector or for ``anything'', which is any arbitrary selector.

Messages that have no explicit selector and start with a numerical value, are recognized automatically either as ``float''-message (only one atom) or as ``list''-message (several atoms).

For example, messages ```12.429`'' and ```float 12.429`'' are identical. Likewise, the messages ```list 1 for you`'' is identical to ```1 for you`''.

Next: pd-types Up: HOWTO write an External Previous: a signal-external: pan~ Contents