This post is part of a series of notes and exercises for a summer camp on making musical instruments with Arduino and Pure Data.
Pure Data patches can get very messy very quickly. Imagine what it would look like if our monodrone had two buttons. Or three. Or five! Lines would canvas the screen like a spider web.
One solution to managing complexity is to create an abstraction. Abstractions reduce a complex set of boxes into a single mega-box. Recall the patch for our monodrone:
These are the boxes that are responsible for producing a note:
We are going to reduce this collection into this single abstraction named
See that 52? That’s our note number. When we include it after the name of our abstraction, it’s called a creation argument.
To make an abstraction, copy the boxes from
noteout into a new file. Name it
note.pd. But we still need to make two changes. First, the number boxes don’t work very well in abstractions. Change the stop and velocity boxes to
float objects. Replace the note number box with a
float object as well, but pass it
$1 refers to the first creation argument—which is 52 in the example.
Here’s our patch after these changes:
Second, we need to announce that this abstraction expects a number 0 or 1 to start or stop the note. Add an
inlet object, and wire it up to the
Finally, let’s replace the boxes in the monodrone with our new
Test it. It should sound the same as before, but you’ve just seen a way to manage complexity. This will be quite helpful as we jump to our next instrument: the five-fingered pentatouch.
After you get your abstraction working, answer the following questions on a piece of scratch paper.
inletis used by an abstraction to receive data as input, what object sends data along as output?
double. It receives one number through an
inlet, doubles the number, and sends the results along as output. Test your abstraction like this:
noteabstraction. What do we do if we also want to send in the velocity to start a note? Try it.