Wednesday, October 18, 2006

Week10 - SuperCollider - Granular Synthesis (2) - 28 Days

I successfully managed to recreate a sine granulation patch with my own minor modifications. Thus, I got some granular synthesis working. The next step for me was applying it to the Karplus-Strong Method of physical modelling...and it almost worked. I will post what I have done (the patch) and at some point work out how to get the pitch to granulate. If I don't do this I am left with a sound that is fairly useless.

Here is the revised code that works:
//Karplus Strong Granulated
(
//Noise > Filter > Delay
SynthDef(
\noiseBurst,

{
//Arguments
arg amp = 0.5,
dur = 1,
pan = 0,
midiPitch = 69,
dec = 0.001;

//Variables
var burstEnv,
env,
att = 0,
delayTime,
decayTime = 10,
noise,
del,
panning;

//Delay Time
delayTime = midiPitch.midicps.reciprocal;

//Envelope
burstEnv = EnvGen.kr(
envelope: Env.perc(att, dec));

//Envelope2
env = (EnvGen.kr(Env.sine(dur, amp), doneAction: 2));
//Noise
noise = PinkNoise.ar(burstEnv);

//Delay
del = CombL.ar(
in: noise,
maxdelaytime: delayTime,
delaytime: delayTime,
decaytime: decayTime,
add: noise) * env;

//Spatialisation
panning = Pan2.ar(del, pan);

//Output
Out.ar(0, panning)
}).load(s);

)
(
//Variables
var message,
wait,
thisGrainDur,
time = 0,
totalTime = 20;

//Routine
fork{
block{|break|

inf.do{
message = [ \midiPitch, rrand(40, 52, 64, 76),
\amp, rrand(-18.0, -6.0).dbamp,
\dur, thisGrainDur = exprand(0.1, 0.2),
\pan, 1.0.rand2,
\dec, rrand(0.001, 0.2)
];
//Instance
Synth(\noiseBurst, message);

//Duration and Interval
wait = thisGrainDur * rrand(0.05, 0.5);
time = time + wait;
if (time > totalTime) { break.value};
wait.wait
}
};
}
)

2 Comments:

At 1:45 pm, Blogger unknown said...

It's quite a simple error; you've probably figured it out yourself already. Your SynthDef is called 'noiseBurst', but in your routine you instantiate 'sineGrain'. By the way, I've been playing with this patch a little and it sounds awesome! If you make the 'dec' variable (for the burstEnv envelope) an argument instead, you can further control the timbre when you instantiate your synth in the routine: e.g. \dec, rrand(0.001, 0.2),... The noise is more prevalent when this value is higher.

 
At 3:38 pm, Blogger Adrian said...

Thanks Martin.

I've played around a little with your suggestions and have come up with some interesting sonic results.

 

Post a Comment

<< Home