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
}
};
}
)
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.
ReplyDeleteThanks Martin.
ReplyDeleteI've played around a little with your suggestions and have come up with some interesting sonic results.