4.2 Audio objects and principles 41
samples this depends on the sa mpling rate o f the progr a m or thesoundcardof
the computer system on which it runs. The current sample rate is returned by
the
object. Typically a sample is 1/44100th of a second and is the
smallest unit of time that can be measured a s a signal. But the time resolution
also depends on the object doing the computation. For example
and
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 blo ck to messages
To see the contents of a signal block we can take a snapshot or anaverage.The
object provides the RMS value of one blo ck of audio data scaled0to100
in dB, while
gives the instantaneous value of the last sample in the
previous block. To view an entire block for debugging
can be used. It
accepts an audio signal and a bang message on the same inlet andprintsthe
current audio block contents when banged.
Sending and receiving audio signals
Audio equivalents of
and
are written
and
,with
shortened forms
and
.Unlikemessagesendsonlyoneaudiosendcan
exist with a given name. If you want to cr eate a signal bus with many to one
connectivity use
and
instead. Within subpatches and abstractions
we use the signal objects
and
to create inlets and outlets.
Audio generators
Only a few objects are signal sources. The most important and simple one is
the
.Thisoutputsanasymmetricalperiodicrampwaveandisusedat
the heart of man y other digital oscillators we are going to make. Its left inlet
specifies the frequency in Hz, and its right inlet sets the phase, b etween 0.0and
1.0. The first and only argument is for frequency, so a typical instance of a
phasor looks like
.Forsinusoidalwaveformswecanuse
.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 Apitchisdefinedby
.Whitenoiseisanothercommonlyusedsourceinsounddesign.The
noise genera tor in Pd is simply
and has no creation arguments. Its output
is in the range −1.0to1.0. Lo oped waveforms stored in an array can be used
to implement wavetable synthesis using the
object. This is a 4 p oint
interpolating table ocillator and requires an array that is apowerof2,plus3
(eg. 0 to 258) in order to work properly. It can be instantiatedlike
or
with a frequency argument. A table oscillator running a t 3kHzisshownin
Fig. 4.4. It takes the waveform stored in array A and loops around this at the
frequency given by its argument or left inlet value. To make sound samplers
we need to read and write audio data from an array . The index to
and
its interpolating friend
is a sample number, so you need to supply a
signal with the correct slope and magnitude to get the proper playback rate.
You can use the special set message to reassign
to read from another