Specifications

3.3 Data flow control 25
bang
delay 1000
stop
2000
timer
214.6
pipe 300
0
0
250
fig 3.8: Time objects
Clicking the first bang button will reset and start
timer
and then hitting the second one will out-
put the time elapsed (in ms). Notice that
timer
is unusual, it’s one of the few objects where the
right inlet behaves as the hot control.
delay
shown in the middle of Fig. 3.8 will output a
single bang message a certain time period after
receiving a bang on its left inlet. This interval
is set by its first argument o r right inlet, or by the value of a float arriving at its
left inlet, so there are three ways of setting the time delay. If a new bang arrives
any pending one is cancelled and a new delay is initiated. If a stop message
arrives then
delay
is reset and all pending events are cancelled. Sometimes we
want to delay a stream of number messages by a fixed amount, which is where
pipe
comes in. This allocates a memory buffer that moves messages from its
inlet to its outlet, taking a time set by its first argument or second inlet. If you
change the top number box of the right patch in Fig. 3.8 you will s e e the lower
number box follow it, but lagging behind by 300ms.
Select
This object outputs a bang on one of its outlets matching something in its
argument list. For example
select 2 4 6
will output a ba ng on its second outlet if
it receives a number 4, or on its third outlet when a number 6 arrives. Messages
that do not match any argument are passed through to the rightmo st outlet.
f 0 + 1
0
select 0 1 2 3
metro 300
fig 3.9: Simple sequencer
This makes it rather easy to begin making sim-
ple sequences . The pa tch in Fig. 3.9 c ycles aro und
four steps blinking each bang button in turn. It
is a metronome running with a 300ms period and
a counter. On the first step the counter holds 0,
and when this is output to
select
it sends a bang
to its first outlet which matches 0. As the counter
increments, successive outlets of
select
produce a
bang, until the fourth one is reached. When this happens a message co ntaining
0 is trig gered which feeds into the cold inlet of
f
resetting the counter to 0.
SECTION 3.3
Data flow control
In this section are a few common objects used to control the flow of data
around patches. As you have just seen
select
can send bang messages along a
choice of connections, so it gives us a kind of selective flow.
Route
Route behaves in a similar fashion to select, only it operates on lists. If the first
element of a list matches an argument the remainder of the list is passed to the
corresponding outlet.