Specifications

50 Abstraction
tabosc4~ array1
110
dac~
; array1 sinesum 64 1
array1
loadbang
fig 5.7: Table oscillator
patch
Consider the table oscillator patch in Fig. 5.7 which
uses an ar ray to hold a sine wave. There are three
significant parts, a
tabosc4~
running at 110Hz, a table
to hold one cycle of the waveform and an initialisation
message to fill the table with a waveform. What if we
want to make a multi-oscillator synthesiser using this
method, but with a square wave in a one table and a
triangle wave in another? We could make a subpatch
of this arrangement and copy it, or just copy everything shown here within the
main ca nva s. But if we do that without changing the array name, Pd will say;
warning: array1: multiply defined
warning: array1: multiply defined
The warning message is given twice because while checking the first array it
notices another one with the same name, then later, while checking the duplicate
array, it notices the firs t one has the same na me. This is a serious warning
and if we ignore it erratic, ill defined behaviour will result. We could rename
each array we create as array1, array2, array3 etc, but that becomes tedious.
What we can to do is make the table oscillator an abs traction and give the array
a special name that will give it local scope. To do this, select eve rything with
CTRL+E, CTRL+A and make a new file from the file menu (Or you can use CTRL+N
as a shortcut to make a new canva s). Paste the objects into the new canvas
with CTRL+V and save it as my-tabosc.pd in a directory called tableocillator.
The name of the directory isn’t important, but it is important that we know
where this abstraction lives so that other patches that will use it can find it.
Now create another new blank file a nd save it as wavetablesynth in the same
directory as the abstraction. This is a patch that will use the abstraction. By
default a patch can find any abstraction that lives in the same directory as itself.
SECTION 5.2
Instantiation
Create a new object in the empty patch and type my-tabosc in the object
box. Now you have an instance of the abstraction. Open it just as you would
edit a normal s ubpatch and make the following changes as shown in Fig. 5.8;
sinesum 64 1
loadbang
tabosc4~ $0-array1
inlet pitch
s $0-array1
outlet~
$0-array1
fig 5. 8: Table oscillator ab-
straction
First we have repla c e d the number box with an inlet
so that pitch data can come from outside the ab-
straction. Instead o f a
dac~
the audio signal appears
on an outlet we’ve provided. The most important
change is the name of the array. Changing it to
$0-array1 gives it a special property. Adding the
$0- prefix makes it local to the abstraction because
at runtime, $0- is replaced by a unique p e r instance
number. Of course we have renamed the array ref-
erenced by
tabosc4~
too. Notice another slight change in the table initialis ation