Specifications

82 Pure Data essentials
del
list append
unpack f f
list split 2
f
t b b
s synth
vline~
*~
mtof
*~
t f b
0, 1 1 0, 0 400 1
phasor~
*~ 2
-~ 1
vcf~ 1 1
+~ 100
*~ 600
r synth
dac~
*~ 0.35
61 0 60 500 59 500
fig 7.24: An asynchronous list sequencer
banged so the remainder of the list is passed back to
list split 2
and the whole
process repeats, chomping 2 elements off each time until the list is empty. To
the rig ht of Fig . 7.24 is a simple monophonic music synthesiser used to test the
sequencer. It converts MIDI note numbers to Hertz with
mtof
and provides
a filtered sawtooth wave with a 400ms curved decay envelope. To scale the
sequence delay times, a nd thus change the tempo without rewriting the entire
list, you can make each time offset be a sc aling factor for the delay which is
then multiplied by some other fraction. List sequencers of this type behave
asynchronously, so don’t need a timebase.
Text file control
Eventually lists stored in messag e boxes become unwieldy for large da ta sets
and it’s time to move to se c ondary storage with textfiles. The
textfile
object
provides an easy way to write and read plain text files. These can have any
format you like, but a general method is to use a comma or linebreak delimited
structure to store events or program data. It is somewhat beyond this textb ook
to describe the many ways you can use this object, so I will present only one
example of how to implement a text file based MIDI sequencer. A combination
of
textfile
and
route
can provide complex score control for music or games. If
you need even larger data sets with rapid access a SQL object is available in
pd-extended which can interface to a databa se.
Starting at the top left corner of Fig. 7.25 you can see a monophonic synthe-
siser used to test the patch. Replace this with a MIDI note out function if you
like. The remainder of the patch consists of two sec tions, one to store and write
the sequence and one to read a nd play it back. Recording commences when
the start-record button is pressed. This causes a clear message to be sent
to
textfile
, the list accumulator is cleared and the
timer
object reset. When a
note is rece ived by
notein
and then reduced to just its note- on value by
stripnote
it passes to the trigger unit below which dispatches two bangs to
timer
. The
result of this is for
timer
to output the time since the last bang it rec e ived, then