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
}
};
}
)