Specifications

7.2 Audio file tools 77
adc~
sampler
record
play
gain
dac~
fig 7.15: us-
ing a sampler
Using the sampler is very easy. Create an instance and connect
it to a sig nal so urce via the first inlet. In Fig. 7.15 the left audio
input is taken from
adc~
. A slider with a range 0.0 to 1.0 connects
to the gain inlet and two bang buttons are used to start recording
or playback. Sound files of up to 3min can be stored happily in
memory. Beyond this limit you need to use other objects for 32
bit machines because the sound quality will suffer due to pointer
inaccuracies. If you have files longer than 3 minutes then you may
want to think about us ing disk based storage and playback.
File recorder
When creating sounds for use in other applications, like multitracks or samplers
you could choose to record the output of Pd directly from the
dac~
using your
favourite wave file editor or software like Timemachine. This could mean editing
long recordings later, so sometimes you want to just write fixed leng th files
directly from Pd.
done
start
noise~
writefile 1000 RENDER
throw~ audio
catch~ audio
10 written
fig 7.16: Using a file writer
In Fig. 7.16 we see a file writer in use , which I will
show you how to make in a moment. It catches
audio, pe rhaps from other patches, on a bus called
audio. It was created with two arg uments, the
length of each file to record (in this case 1s) and
the name of an existing folder beneath the current
working directory in which to put them. Each time
you hit the start button a new file is written to
disk and then the done indicator tells you when it’s finished. A numerical suffix
is appended to each file, which you can see on the second outlet, in order to keep
track of how many files you’ve created. The internals of the file writer are shown
start
stop
+ 1f 0
t b b b b
writesf~ 1
inlet
outlet done
inlet~
makefilename $2/soundfile%d.wav
del $1
outlet number written
stop,
open $1
fig 7.17: Making a file writer
in Fig. 7.17. Audio comes into the first inlet and to the
writesf~
object which
has an argument of 1, so writes a sing le channel (mono) file. There are three
commands that
writesf~
needs, the name of a file to open for writing, a start
command, and a stop command. Each bang on the second inlet increments