You are on page 1of 7

Introductory Granular Synthesis in Max/MSP

Granular synthesis is a technique in which you take small chunks of sound, called grains, and sequence them in time to create soundscapes and music. Each of these grains is usually 20 milliseconds or longer. Grains that are shorter in length are usually perceived as clicks, but can be sonically useful so do experiment. The silence between grains is known as intergrain time and can be of any length also. Each grain has its own characteristics, such as envelope shape, length, pitch, and amplitude,, and multiple layers of grains can be created to produce very complex sounds. Granular synthesis can be implemented in real-time or non-real-time. In this tutorial, you will learn the basics of granulating live and pre-recorded audio in real-time. We will start by granulating live audio. The first step is to create the grains, meaning we need sound going into the patch with envelopes being applied to it in real-time. To generate the envelopes, we will use the function object, and for the audio, we will use cycle~, though you can use ezadc~ or any MSP synthesizer you wish. The following patch creates a single stream of grains:

Figure 1: Basic grain generator. In this patch, a triangular envelope has been drawn into the function object and a grain is generated each time the button is pressed. The grain duration is set using the setdomain message. Right now, pressing the button controls the intergrain time, i.e., Rupa Dhillon 28/05/2009 1

the patch is silent until you press the button and generate a new grain. In the next patch, we will add a metro and do some simple maths to control the intergrain time.

Figure 2: Basic grain generator with metro controlling intergrain time. In this patch, we are adding the intergrain time, i.e., the amount of silence we want between grains, to the duration of the grain in order to control when the metro triggers the generation of each grain. If we wanted to create more than one stream of grains in this manner, we could simply duplicate what we have already done, i.e., copy and paste, or we could implement a delay line or several delay lines using tapin~ tapout~. It all depends on how many grain streams we want!!

Rupa Dhillon

28/05/2009

Figure 3: Basic granulator with delay line. In this patch, there is a simple delay line utilizing tapin~ tapout~. I have sent the original stream to the left output channel and the delayed stream to the right output channel for testing. You can send them to whatever channels you like of course. Next, we will change the pitch of the grain streams by using the pfft~ object. We will use the pitch shifter supplied by the wonderful people at Cyling74. Create a new object called gizmo~, open its help file, enter Edit mode, and copy the object called pfft~ gizmo_loadme 4096 4. This pitch shifter is fantastic!! You may now delete the gizmo~ object you just created. We will also add a preset object and attach it to the function object. This will allow us to save and recall the envelopes we draw.

Rupa Dhillon

28/05/2009

Figure 4: Basic granulator with one grain stream being pitch shifted and a preset object for saving envelopes. This patch only pitch shifts one of the grain streams, but you can pitch shift all streams if you wish. Also, notice the preset object is connected to the function object. This means it will only memorize the settings of the function object. Draw an envelope, then shiftclick on one of the light gray dots. A dark gray dot will appear and means you have saved a preset there. A blue denotes the preset you are using. The preset object can also be used to save all the settings in a patch by not connecting it to anything. Read its help file to learn about its functionality. It can be a handy timesaving object, especially when you need to initialize the settings/values of many different things in a patch at once. We can also randomize the grain duration, intergrain time, transposition value, delay amount, and panning of each grain by using the random object and sending it a series of bangs. If you want the randomization to be smooth and for no clipping to occur, then you Rupa Dhillon 28/05/2009 4

must make sure a random value is only ever generated for each parameter after a grain has finished playing. The following patch shows how to do this:

Figure 5: Added randomized grain duration, pitch, and panning to grain stream 1. In this patch, the right outlet of the line~ object is attached to the input of the gate object. The right outlet of the line~ object sends out a bang every time an envelope has finished being generated. This allows us to generate a new randomized value for affecting pitch, grain duration, and panning only when a grain has finished being generated, and therefore reduces clipping that would occur if these values changed while a grain was still being played. Next, we will granulate pre-recorded sounds using the groove~ object. Granulating sounds saved in a buffer offers us quite a lot of flexibility and allows us to granulate any portion of a clip we want. We can also randomize where our grains come from within a clip!! For this part of the tutorial, we are going to duplicate the granulator we have already made. This allows us to access multiple parts of a clip simultaneously to create grains,

Rupa Dhillon

28/05/2009

i.e., we can create a grain from the very beginning of a clip while also generating a grain that originates from the middle of the clip at the same time.

First, we are going to encapsulate most of the patch in a subpatcher called p Granulator to clean things up. This will also make duplicating the granulator much easier. To do this, select everything in the patch except for the Toggle switches that control the metro and randomization, the cycle~ object and the number box for its frequency control, and the number boxes that control the pitch shifting and delay time. Next, click on Edit in Maxs main menu bar, and select Encapsulate. You should be left with something that looks close to this:

Figure 6: Encapsulated granulator. Commenting added and toggle switch enlarged after. For this patch, you will have to add the commenting and dont forget to name the subpatcher. Also, while in Edit mode, keep the Command key pressed and then doubleclick on p Granulator to see whats inside. You will notice that square numbered boxes have appeared. These represent the inlets and outlets of the subpatcher. Follow these to figure out whats going where. Now, we are going to replace the cycle~ object with the groove~ object. The groove~ object requires a buffer~ to read from and it must have the same name as the buffer~ in order to work. The groove~ object is being used instead of other MSP samplers because it allows us to access any part of a loaded sample easily and to loop it.

Rupa Dhillon

28/05/2009

Figure 7: Granulator using the groove~ object instead of cycle~. Note the use of the replace message attached to the buffer~. The replace message is used instead of the read message because it automatically resizes the buffer to fit the audio sample being loaded. Now we can duplicate this as many times as we want to create as many grain streams as we want!!

Rupa Dhillon

28/05/2009

You might also like