Specifications

22 Using Pure Data
sides of a
+
. When connections are made this way the behaviour is undefined,
but usually happens in the order the connections were made. The first one
works because the right (cold) inlet was connected before the left (hot) one.
In the second patch the arriving number is added to the last number received
because the hot inlet is a ddressed first. Try making these patches by connecting
the inlets to
+
in a different order. If you accidentally create errors this way
they are ha rd to debug.
Trigger objects
A trigger is an object that splits a message up into parts and sends them over
several outlets in order. It solves the evaluation order problem by making the
order explicit.
20
+
10
t f f
fig 3.3: Ordering with
trigger
The order of output is right to left, so a
trigger bang float
object outputs a float on the right outlet first, then a
bang on the left one. This can be abbreviated as
t b f
.
Proper use of triggers ensures correct operation of units
further down the connection graph. The arguments to a
trigger may be s for s ymbol, f for float, b for bang, p
for pointers and a for any. The “any” type will pass lists
and pointers too. The patch in Fig. 3.3 always works correctly, whatever order
you connect to the
+
inlets. The flo at from the right outlet of
t f f
is alway s
sent to the c old inlet of
+
first, and the left one to the hot inlet afterwards.
Making cold inlets hot
7
+
3
t b f
4
fig 3.4: Warming an
inlet
An immediate use fo r our new knowledge of triggers is to
make an arithmetic operator like
+
respond to either of
its inlets immediately. Make the patch shown in Fig. 3 .4
and try changing the number boxes. When the left one is
changed it sends a float numb e r message to the left (hot)
inlet which updates the output as usual. But now, when
you change the right number box it is split by
t b f
into
two messages, a float which is sent to the cold (right) inlet of
+
, and a bang,
which is s e nt to the hot inlet immediately afterwards. When it receives a bang
on its hot inlet
+
computes the sum of the two numbers la st seen on its inlets,
which gives the right result.
Float objects
The object
f
is very common. A shorthand for
float
, which you can also use
if you like to make things clea rer, it holds the va lue of a single floating point
number. You might like to think of it as a variable, a temp orary place to store a
number. There are two inlets on
f
, the rightmost one will set the value of the
object, and the leftmost one will both set the value and/or output it depending
on what message it receives. If it receives a bang message it will just output
whatever value is currently stored, but if the message is a float it will override