Pure Data Tutorial 1: Tone Generator

This is the first in a series of tutorials showing you how to get Pure Data patches up and running on your OWL Pedal or OWL Modular. We won’t go into too much detail about Pure Data because we think one of the best ways to learn is by just diving in and using it, and there are plenty of tutorials on the web if you want to dig deeper – instead we’ll be focusing on getting some fun and useful patches quickly running on the OWL so you can make sounds and hopefully learn a bit of Pure Data on the way.

This first tutorial will show you how to build a simple sine wave generator, that generates 3 sine waves. The first three dials change the frequency of each sine wave independently, and the fourth dial controls overall volume. This patch is very simple but nice for generating rich tones to explore the resonance of rooms and upset neighbours and dogs.

1.) Download and install Pure Data Vanilla (not Pure Data Extended) from https://puredata.info/downloads/pure-data

2.) Once you’ve installed Pure Data (PD), open it and create a new window (File>New, or cmd+N on Mac). PD uses objects, connected by patch cables. These generate sounds, do maths – all sorts. To be able to create and connect new objects, we need to be in “edit” mode, which is the opposite of play mode – enable this is edit>Edit mode. Create a new object with Put>Object, or cmd+1 on Mac. The object to generate sine waves is called [osc~]. The ~ (known as tilde) symbol means it’s an audio rate object. We’ll learn more about the two types of object – audio and control – as we move on. In general, audio rate objects are dealing with sound, whist control objects are doing maths.2-osc3.) Because we’re adding three sine waves together, we don’t want the volume to get too loud and distort. So, the first thing to do is to reduce the volume of the output of the oscillator, by connecting the outlet to a [*~ 0.3] object. One of the great things about PD is you can treat audio like maths – multiply a stream of audio by a fraction (eg 0.3) and you reduce the volume! Note that we still need the tilde because we are dealing with audio rate objects.

3-vollarger

4.) To get the input from the first dial, we need to use a [receive] object, shortened, to [r], with the name Channel-A – so, [r Channel-A].

4-channelalarger

5.) The range of the dial is 0 to 1, but the range of human hearing (and so a useful range for the frequency of the oscillator) is 20 to 20,000 hz. So, we need to do some maths to it to get it into the right range. If we want our sine waves to be between 20 and 2020 hz (I for one can’t hear high frequencies anyway!), we multiply the input by 2000 and add 20 – as simple as that! We use the [*] object without a tilde, because this is control rate and not yet audio rate.

6-freqlarger6.) The next step is to duplicate this three times – once for each oscillator. To control the frequencies with different dials, update to the receives for the two duplications to [r Channel-B] and [r-Channel C].

7-3osc7.) The next step is to add these sine waves together. To do this, creata another [*~] object (with the tilde, because it’s audio rate), but leave the “argument” (the number inside) blank, because we can update this to make a volume control.

8-vol18.) Now, we can use the right inlet of the [~] object at the bottom as a volume control, controlled by the fourth dial. Remember the range is 0 to 1 – this is perfect for volume, with 0 being silence and 1 being the full volume of all the sine waves added together. Finally, we connect the output of the [~] object to the [dac~] object. Imagine this to be the speaker out – it has a left and a right channel.9-finished9.) If we want to test this, turn off edit mode, put some number boxes (a special object) where the channels are connected, turn off (Edit>edit mode), turn on audio (media>audio ON), and input values into the number boxes (remember – they need to be between 0 and 1, like the dials). You should get sound out. Now save your patch, and follow the instructions to upload to the OWL.

You can download the patch from our patch library here:

https://www.rebeltech.org/patch-library/patch/PD_Sine_Wave_Tutorial/