Seeing Waveforms
This post is part of a series of notes and exercises for a summer camp on making musical instruments with Arduino and Pure Data.
Author Christopher Paul Curtis writes in Elijah of Buxton, “Believe some to none of what you hear and only half of what you see.” This wisdom applies equally well to gossip and physical sound. Our ears are easily tricked, and sometimes we need to see sound to make sense of it.
In this exercise, we will visualize the waveforms of pure frequencies using Pure Data’s array object. In particular, we will create a patch that looks like this:
An array is two things in Pure Data. First, it is a container that stores many numbers. Second, it is a graph of those many numbers.
Follow these steps to produce your patch:
- Create a new Pd patch. Click File / New.
- Notice the left three widgets are exactly the same as the ones in the oscillator that we made earlier. Either recreate them or copy and paste.
- Add a plot to the window. Click Put / Array. In the dialog that pops up, configure the array as follows:
- Name the array
wave
. - Set its size to 500.
- Uncheck Save Contents so it doesn’t store the wave in the file.
- Name the array
- Widen the plot. Two-finger-click or right-click on the array’s box, and in the Canvas Properties window, change the size to 500.
- Record the soundwave’s amplitudes in the array. Use Put / Object to add a
tabwrite~
object. This command is an abbreviation of table write. Write to thewave
array by typingtabwrite~ wave
in the object box. This expression passeswave
as a parameter to thetabwrite~
command. - Connect the outlet of
osc~
to the inlet oftabwrite~
. - Leave Edit Mode and generate some sounds. What do they look like? Probably you aren’t seeing anything. That’s because we’re only storing numbers in the array; we aren’t plotting them.
- Plot the array. Use Put / Object to add a
bng
object. This command is an abbreviation for bang. Iftabwrite~
is given a number in its left inlet, it stores it. If it’s given abng
, it plots the numbers it has stored. - Connect the outlet of
bng
to the inlet oftabwrite~
. Leave Edit Mode and generate a sound. Click thebng
to view the waveform. - Change the frequency, click the
bng
, and observe how the waveform changes.
Challenges
After you get your patch working, answer the following questions on a piece of scratch paper.
- How does the waveform change as the frequency changes?
- How can you tweak the patch so that every time you change the frequency the plot automatically updates?
- Imagine a wall. Imagine a high frequency sound wave being directed at the wall. Then, imagine a low frequency wave being directed at the wall. Why are we more likely to hear the low frequency sound on the other side of the wall?