Specifications

30 Using Pure Data
List distribution
An object with 2 or more message inlets will distribute a list of parameters to
all inlets us ing only the first inlet.
2
9 7
-
fig 3.20: Dis-
tribution
The number of elements in the list must match the number of
inlets and their types must be compatible. In Fig. 3.20 a message
box co ntains a list of two numbers , 9 and 7 . When a pair of
values like this are sent to
-
with its right inlet unconnected
they are spread over the two inlets, in the order they appear,
thus 9 − 7 = 2.
More advanced list operations
To concatenate two lists together we use
list append
. It takes two lists and creates
a new one with the second list attached to the end of the first. If given an
argument it will append this to every list it receives. It may be worth knowing
that
list
is an alias for
list append
. You can choose to type in either in or der to
make it clear e r what you are doing. Ve ry similar is
list prepend
which does almost
the same, but returns a new list with the argument or list at the second inlet
concatenated to the beginning. For disassembling lists we can use
list split
.
This takes a list on its left inlet and a number on the right inlet (or as an
argument) which indicates the position to s plit the list. It produces two new
lists, one containing e lements below the split point appears on the left outlet,
and the remainder of the list appears on the right. If the supplied list is s horter
than the split number then the entire list is passed unchanged to the right outlet.
The
list trim
object strips off any selector at the start leaving the raw elements.
SECTION 3.5
Input and output
There are plenty of objects in Pd for reading keyboards, mice, system timers,
serial ports and USB. There’s not enough room in this book to do much more
than summarise them, so please refer to the Pd online documenta tion for your
platform. Ma ny of these are ava ilable only as external objects, but several are
built into Pd core. Some depend on the platform used, for example
comport
and
key
are only available on Linux and MacOS. One of the most useful externals
available is
hid
which is the “human interface device”. With this you can
connect joysticks, game controllers, dance mats, steering wheels, graphics tablets
and all kinds of fun things. File IO is available using
textfile
and
qlist
objects,
objects are availa ble to make database transactions to MySQL, and of course
audio file IO is simple using a range of objects like
writesf~
and
readsf~
. MIDI files
can be imported and written with similar objects. Network access is available
through
netsend
and
netreceive
which offer UDP or TCP services. Open Sound
Control is available using the e xternal OSC library by Martin Peach or
dumpOSC
and
sendOSC
objects. You can even generate or open compressed audio streams
using
mp3cast~
and s imilar externals , and you can run code from other languages
like python and lua. A popular hardware peripheral for use in combination with