Specifications

2.3 Message data and GUI boxes 17
Lists
A list is an ordered collection of any things, floats, symbols or pointers that
are treated as one. Lists of floats might be used for building melody sequences
or setting the time values for an envelope generator. Lists of symbols can be
used to represent text data from a file or keyboard input. Most of the time
we will be interested in lists of numbers. A list like {2 127 3.14159 12 } has
four elements, the first element is 2.0 and the last is 12.0. Internally, Pure Data
recognises a list beca use it has a list selector at the start, so it tre ats all following
parts of the message as ordered list elements. When a list is sent as a message
all its elements are sent at once. A list selector is attached to the beginning
of the message to determine its type. The selector is the word “list”, which
has a special meaning to Pd. Lists may be of mixed types like {5 6 pick up
sticks }, which has two floats and three symbols. When a list mes sage contains
only one item which is a float it is automatically changed (cast) back to a float.
Lists can be created in several ways, by using a message box, or by using
pack
,
which we will meet later, to pa ck data elements into a list.
Pointers
As in other programming languages, a pointer is the address of some other
piece of data. We can use them to build more complex datastructures, such as
a pointer to a lis t of pointers to lists of floats and symbols. Spec ial objects exist
for creating and dereferencing pointers, but since they are an advance d topic we
will not explore them further in this book .
Tables, arrays and graphs
A table is sometimes used interchangeably with an array to mean a two di-
mensional data structure. An array is one of the few invisible o bjects. Once
declared it just exists in memory. To see it, a separa te graph like that shown in
Fig. 2 .11 allows us to view its contents.
array1
fig 2.11: An array.
Graphs have the wonderful property that they are
also GUI elements. You can draw data directly into a
graph using the mouse and it will modify the array it is
attached to. You can see a graph of array1 in Fig. 2.11
that has bee n drawn by hand. Similarly, if the data in
an array changes and it’s attached to a visible graph
then the graph will show the data as it updates. This
is perfect for drawing detailed envelopes or making an
oscilloscope display of rapidly changing signals.