Professional Documents
Culture Documents
5.4 Granular Bonus Examples
5.4 Granular Bonus Examples
chosen position
(
SynthDef(\shortsample,{arg buffer, dur=0.05, pos = 0.0, amp= 0.5, pan= 0.0;
var env, source;
source = PlayBuf.ar(1,buffer,startPos:pos*BufFrames.ir(buffer));
env = EnvGen.ar(Env([0,1,1,0],[0.01,dur,0.01]),doneAction:2);
Out.ar(0,Pan2.ar(env*source*amp,pan))
}).add
)
{
100.do{arg count;
var time = count*grainspacing;
Synth(\shortsample, [\buffer,b,\pos,env.at(time),\dur,rrand(0.01,0.05)]);
grainspacing.wait;
}
}.fork
)
//granular cross fade; as increase density of grains from one, reduce from another
(done in a basic probabilistic way here). Doesn't sound great with these two
sounds, but could certainly be improved by exploring other sources and mixing
strategies
(
var grainspacing = 0.05;
var mixprobability = Env([0.0,1.0,0.0],[3.0,2.0]); //use a language side envelope
to vary position
{
100.do{arg count;
var time = count*grainspacing;
Synth(\shortsample, [\buffer,if(mixprobability.at(time).coin,c,b),\pos,time*0.1,\
dur,grainspacing*4.0,\amp, 0.25]);
grainspacing.wait;
}
}.fork
)