Specifications

4.2 Audio objects and principles 41
samples this depends on the sampling rate of the program or the sound card of
the computer system on which it runs. The current sample rate is returned by
the
samplerate~
object. Typically a sample is 1/44100th of a second and is the
smallest unit of time that can be measured as a signal. But the time resolution
also depends on the object doing the computation. For example
metro
and
vline~
are able to deal in fractions of a millisecond, even less than one sample. Tim-
ing irregularities can occur where some objects are only accurate to one block
boundary and some are not.
Audio signal block to messages
To see the contents of a signa l block we can take a snapshot or an average. The
env~
object prov ides the RMS value of one block of audio data scaled 0 to 100
in dB, while
snapshot~
gives the instantaneous value of the last sample in the
previous block. To view an entire block for debugging
print~
can be used. It
accepts an audio signa l and a bang message on the same inlet and prints the
current audio block contents when banged.
Sending and receiving audio signals
Audio equivalents of
send
and
receive
are written
send~
and
receive~
, with
shortened forms
s~
and
r~
. Unlike message sends only one audio s e nd can
exist with a given name. If you want to create a signal bus with many to one
connectivity use
throw~
and
catch~
instead. Within subpatches and abstractions
we use the signal objects
inlet~
and
outlet~
to create inlets and outlets.
Audio generators
Only a few objects ar e signal sources. The most important and simple one is
the
phasor~
. This outputs an asy mmetrical p e riodic ramp wave and is used at
the heart of many other digital oscillators we are going to make. Its left inlet
sp e c ifies the fre quency in Hz, and its right inlet s e ts the phase, between 0.0 and
1.0. The first and only argument is for frequency, so a typical instance of a
phasor looks like
phasor~ 110
. For sinusoidal waveforms we can use
osc~
. Again,
frequency and phase are set by the left and right inlets, or frequency is set by
the creation parameter. A sinusoidal oscillator at concert A pitch is defined by
osc~ 440
. White noise is another commonly used source in sound design. The
noise generator in Pd is simply
noise~
and has no creation arguments. Its output
is in the range −1.0 to 1.0. Loop ed waveforms stored in an array can be used
to implement wavetable synthesis using the
tabosc4~
object. This is a 4 point
interpolating table ocillator and requires an array that is a power of 2, plus 3
(eg. 0 to 258) in order to work properly. It can be instantia ted like
phasor~
or
osc~
with a frequency argument. A table oscillator running at 3k Hz is shown in
Fig. 4.4. It takes the waveform stored in ar ray A and loops around this at the
frequency given by its a rgument or left inlet value. To make sound samplers
we need to read and write audio data from an array. The index to
tabread~
and
its interpolating friend
tabread4~
is a sample number, so you need to supply a
signal with the correct slope and magnitude to g e t the proper playback rate.
You c an use the special set messa ge to rea ssign
tabread4~
to re ad from another