Specifications

78 Pure Data essentials
a counter and the value of this is appended to the current file name using
makefilename
which can substitute numerical values into a string like the C printf
statement does. This string is then substituted after the open keyword in the
following message. As soon as this is done a start message is sent to
writesf~
and a bang to the
delay
which waits for a period given by the first argument
befo re sto pping
writesf~
.
Loop player
inlet
soundfiler
openpanel
t b
outlet~
read -resize $1 $2
pack s s
t a b
bang
spigot 1
inlet
sel 1
table $0-a
tabplay~ $0-a
symbol $0-a
fig 7.18: sample loop
player
A looping sample player is useful in many situations, to
create a texture from looped background samples, or to
provide a b e at from a drum loop, especially if you need a
continuous sound to test some process with. In Fig. 7 .18
we see a patch that should be created as an abstractio n
so that many can be instantiated if required. It’s opera-
tion is unsophisticated, just playing a loop of a sound file
forever. When the abstraction receives a bang
openpanel
is activated and provides a nice file dialogue for you to
choose a sound file. You should pick a Microsoft .wav
or Mac .aiff type, either stereo or mono will do but this
player patch will only give mono output. The name and
path of this file is passed through the trigger “any” outlet and packed as the
first part of a list along with a second part which is a symbol $0-a. The second
symbol is the name of our storage table, the place in memory wher e the contents
of the soundfile will be put once r e ad. It has the prefix $- to give it local scope
so we can have many sample loop players in a patch. Now the elements of the
list will be substituted in $1 and $2 of the message read -resize $1 $2, which
forms a complete command to
soundfiler
telling it to read in a sound file and put
it in an ar ray resizing the array as required. Once this operation is complete
soundfiler
returns the number of bytes read, which in this case we ignore and
simply trigger a new bang message to start
tabplay~
. Notice the argument is the
name of the array living in the table just above it.
tabplay~
will now play once
through the file at its original sample rate, so there is no need to tune it. When
it has finished, the right outlet emits a bang. We take this bang, buffering it
through another trigger and apply it back to the
tabplay~
inlet, which means it
plays the sound forever in a loop. A zero arriving at the second inlet allows you
to stop the loop playing.
SECTION 7.3
Events and sequencing
Now let’s look at a few concepts used for creating time, sequences and event
triggers.
Timebase
At the heart of many audio scenes or musical constructio ns is a timebase to
drive events. We’ve already seen how to construct a simple timebase from a