Home Understanding granular synthesis with pure data
Post
Cancel

Understanding granular synthesis with pure data

Granulation is a technique in which you manipulate a short-duration microacoustic event (typically between 1 to 100ms) known as grain, that can be used on sound design to achieve multiple results, like creating unpredictability, for instance. An interesting thing about granular synthesis is that it gives you the ability to control pitch without affecting speed and speed without affecting pitch which gives you a great amount of control. It may be useful if you’re thinking sound as a process and you can take it to many interesting directions. If you are interested in learning more deeply about granular synthesis and its possibilities, refer to ROADS, 2004.

Granular synthesis is behind many fancy plugins or built-in fx you are used to see in your DAW of choice, such as Ableton’s Grain Delay. A good way to understand how they’re used might be to just try to build a simple granular synthesizer yourself.

Let's do it!

The recorder

So we need a way to record an input. We do that by using an analog to digital converter [adc~]. For the sake of organization, we’re going to put it into a subpatch, so our patch will look more clear further on.

pd_recorder Fig.1 Creating a subpatch

The signal coming from your microphone is an analog signal which represents in voltage the changes that happen in air pressure. What the adc does is to translate those into digital domain by capturing periodic snapshots of that voltage and representing those snapshots as discrete numbers.

Later in the patch you’ll see that we need a [dac~], a digital-to-analog-converter in order to listen to these numbers back through our speakers.

RecordInput Fig.2 Recorder subpatch

The bang is your record button. Note that pd records at whatever sample rate ADC and DAC are running at, this is defined in your audio settings, so be aware of that.

[tabwrite~] will allow us to visualize our waveform and store it. For that to happen, you need to create an array with a matching name.

Here our array is going to be one second long we’re going to call it “sampling”.

array-properties Fig.3 Defining array properties

wf-array Fig.4 Waveform recorded into array

I’ve added 3 points to the size so that I could use a 44.1 value in my patch. You might want to look up how our [tabwrite4~] object operates to understand interpolation. For a more in depth explanation you can also check chapter 2 of Miller Puckette’s book “The theory and technique of electronic music”. We’re going to use interpolation here to increase the accuracy of table lookup and read continuously.

I’m also going to create a way for us to write and read our sample file. Here’s how:

soundfiler Fig.5 Soundfiler: read and write soundfiles to arrays

→ Why can’t I read my file?
A reason you might not be able to read a file from soundfiler is that you must save the patch first so that pd knows what directory to read from. Pd will save your sample to the same directory as the patch.

Let’s put a [tabread4~] as I mentioned before to read from our “sampling” array. And we should also add a [dac~] in order to listen to the sample and give it a on and off button.

dac-tab Fig.6 Table lookup and DAC

The sampler

Now we’re going to have a [phasor~] reading the sample and then a multiplier [*~] and [+~] initially set to read the entire sample. You’ll see where this is going now.

phasor Fig.7 phasor~ - sawtooth signal for table lookup

The [*~] object will allow us to manipulate the amount of the sample we want to playback and the [+~] will set the starting point.

patch-overview Fig.8 Patch overview

We’re going to put the sample size control and starting point control into subpatches to keep things clean.

sampler Fig.9 Creating sample size control subpatch

Now, if you change the 1000 ms to a lower value, you will read just a portion of the array, but it will take an entire second to do it, as defined by phasor speed.

Try changing to 500ms and you’ll see that to read at the original speed you will have to increase the phasor speed to 2 Hz.

sample-size Fig.10 Sample size control subpatch

starting-point Fig.11 Starting point control subpatch

You might have noticed at this point that something is causing your audio to produce little clicks while you manipulate the values on your number boxes. This is caused by discontinuity on the [tableread4~] object. [line~] will fix it by ramping up the value instead of jumping so we pack the sample size information together with a ramping time for [line~].

Now that we’ve got everything working, try exploring the possibilities of this patch, you can always add more to it: add filters, delay, reverb, envelope generators, it’s up to you really.

This is just an introductory tutorial, but it opens a lot of possibilities to explore this technique in more complex ways. I hope it can give you a better grasp on how granular synthesis works in your computer.

References

Roads, Curtis. Microsound. MIT press, 2004.
Puckette, Miller. The theory and technique of electronic music. World Scientific Publishing Company, 2007.
Johannes Kreidler’s website: http://www.pd-tutorial.com/english/ch03s07.html

This post is licensed under CC BY 4.0 by the author.
Contents