Specifications

26 Using Pure Data
route vcf vco vca
20 0 5
vcf 20
vca 5
fig 3.10: Routing val-
ues
So,
route badger mushroom snake
will send 20.0 to its third outlet
when it receives the message {snake 20 }. Non match-
ing lists are passed unchanged to the rightmost outlet.
Arguments can be numbers or symbols, but we tend to
use symbols because a combination of
route
with lists is
a great way to give parameters names so we don’t for-
get what they a re for. We have a few named values in
Fig. 3.10 for synthesiser controls. Each message box contains a two element
list, a name-value pair. When
route
encounters one that matches one of its
arguments it sends it to the correct number box.
Moses
A stream splitter” which sends numbers below a threshold to its left outlet,
and numbers greater than or equal to the threshold to the right outlet. The
threshold is set by the first argument or a value appearing on the right inlet.
moses 20
splits any incoming numbers at 20.0
Spigot
This is a switch that can control a ny strea m of messages including lists and
symbols. A zero on the right inlet of
spigot
stops any mess ages on the left inlet
passing to the outlet. Any non-zero number turns the spigot on.
Swap
swap
15
20
20
15
fig 3.11: Swapping values
It might look like a very trivial thing to do, and you
may ask - why not just cross two wires? In fact
swap
is
really useful object. It just exchanges the two values
on its inlets and passes them to its outlets, but it can
take an argument so it always exchanges a number
with a constant. It’s useful when this constant is 1 as
shown later for calculating complement 1 x and inverse 1/x of a number, or
where it is 100 for calculating values as a percent.
Change
f 0 + 1
/ 2
int
3
1.5
change
1
1
metro 1000
fig 3.12: Pass val-
ues that change
This is useful if we have a stream of numbers, perhaps from a
physical controller like a joystick that is polled at regular in-
tervals, but we only want to know values when they change.
It is frequently seen preceded by
int
to denoise a jittery sig-
nal or when dividing timebases. In Fig. 3.12 we see a counter
that has been stopped after reaching 3. The components be-
low it are designed to divide the timebase in half. That is
to say, for a sequence {1, 2, 3, 4, 5, 6 ...} we will get
{1, 2, 3 ...}. There should be half as many numbers in
the output during the same time interval. In other words the output changes
half a s often as the input. Since the counte r has just passed 3 the output of
/
is 1.5 and
int
truncates this to 1. But this is the second time we have seen 1