Implementation of real time, time granulation synthesis in Chuck, with the ability to be used in live performance. The synthesis parameters (grain length, position, position randomness, pitch, and pitch randomness) can be tweaked in real time.

+

-

+

-

== DESIGN ==

+

-

SndBuf stores a sound file into a buffer, which is then chucked to a linear envelope for the grains. The envelope is used to prevent pops and clicks from starting the sound file from a random position. The envelope used in the sound files below has a rise time that is randomly chosen from 0.45 to 0.5 ms. This can be altered to achieve a more varying asynchronous envelope for each grain. For granular synthesis, grain length is usually from 1 - 100 ms. The grain length, position in the sound file, the randomness of the position, pitch transposition, and randomness of pitch are the parameters that can be controlled in this patch. All the parameters were mapped to a midi controller, allowing for real time control of each parameter simultaneously.

[http://ccrma.stanford.edu/~baeksan/220a/final_project/rand_position.wav Varying randomness of position] - Changing the parameter which controls how far from the starting position the patch should play grains. This essentially chops up the sound file into desired grain lengths and orders them randomly one after another. A grain length of 80 ms was used.

+

-

+

-

[http://ccrma.stanford.edu/~baeksan/220a/final_project/pitch_shifting.wav Transposing pitch] - The pitch of the grains is transposed. The randomness of the pitch of each grain can be controlled as well.

+

-

+

-

[http://ccrma.stanford.edu/~baeksan/220a/final_project/time_stretching.wav Time stretching] - Time stretching of the sound file can be achieved by changing the grain position in the buffer. Granular synthesis allows to time stretch the sound file, without altering the pitch. In this example, the grain length is 80 ms and the position randomness is set to 0. This was done in real time with a knob on a midi controller.

+

-

+

-

[http://ccrma.stanford.edu/~baeksan/220a/final_project/time_stretching_pitch.wav Time stretching with transposition]

+

-

[http://ccrma.stanford.edu/~baeksan/220a/final_project/Time_Stretching-1.wav Time stretching another example] - These examples show time stretching and pitch transposition of the sound file.

+

-

+

-

[http://ccrma.stanford.edu/~baeksan/220a/final_project/everything.wav Everything all together with reverb control on top] - All the parameters are tweaked simultaneously in real time. The dry wet mix of the reverb is also controllable

+

-

+

-

== CODE ==

+

-

+

-

Machine.add( "grain.ck" );

+

-

Std.rand2f(5,20)::ms=>now;

+

-

Machine.add( "grain.ck" );

+

-

Std.rand2f(5,20)::ms=>now;

+

-

Machine.add( "grain.ck" );

+

-

Std.rand2f(5,20)::ms=>now;

+

-

Machine.add( "grain.ck" );

+

-

Std.rand2f(5,20)::ms=>now;

+

-

Machine.add( "grain.ck" );

+

-

Std.rand2f(5,20)::ms=>now;

+

-

Machine.add( "grain.ck" );

+

-

Std.rand2f(5,20)::ms=>now;

+

-

Machine.add( "grain.ck" );

+

-

Adding multiple instances of grains with different phase. This allows for a more dense/cloud like sound, compared to using one grain instance.

+

-

+

-

+

-

while(min.recv(msg))

+

-

{

+

-

if( msg.data1 == 176 && msg.data2 == 74 )

+

-

{

+

-

msg.data3*150/127 => duration;

+

-

<<<duration>>>;

+

-

}

+

-

if( msg.data1 == 176 && msg.data2 == 71 )

+

-

{

+

-

msg.data3*samples/(127) => position;

+

-

<<<position>>>;

+

-

}

+

-

if( msg.data1 == 224 )

+

-

{

+

-

msg.data3*2.0/127 => pitch;

+

-

<<<pitch>>>;

+

-

}

+

-

if( msg.data1 == 176 && msg.data2 == 1 )

+

-

{

+

-

msg.data3*4.0/127 => randpitch;

+

-

<<<randpitch>>>;

+

-

}

+

-

if( msg.data1 == 176 && msg.data2 == 73 )

+

-

{

+

-

msg.data3*samples/127 => randompos;

+

-

<<<randompos>>>;

+

-

}

+

-

if( msg.data1 == 176 && msg.data2 == 72 )

+

-

{

+

-

msg.data3/127.0 => R.mix;

+

-

}

+

-

}

+

-

Midi controller mapping.

+

-

+

-

Std.rand2f(pitch-randpitch,pitch+randpitch) => buf2.rate;

+

-

Std.rand2(position-randompos,position+randompos) => buf2.pos;

+

-

0.4 => buf2.gain;

+

-

e.keyOn();

+

-

duration*0.5::ms => now;

+

-

e.keyOff();

+

-

duration*0.5::ms => now;

+

-

Control of the play back rate (pitch transposition), position, and envelope.

+

-

+

-

+

-

+

-

== Usage ==

+

-

Download both chuck files. In "grain.ck" change the sound file to the specified location. Then add a shred from "grain_control.ck" Midi controller numbers might have to be changed for your midi controller. Tweak some knobs and ENJOY!