// title: looping buffer granuals // author: blueprint // description: // This is a granular synth, much inspired by http://sccode.org/1-4WM // // It's distinct in that the SynthDef loops in a live recording buffer with a slight delay and is added back to the input (on the bus) .... // // When I was starting I was looking for something like this .... // code: // allocate a Buffer s = Server.local; b = Buffer.alloc(s, 44100 * 1.0, 1); // a 1 second 1 channel Buffer SynthDef("granular_sampling", {arg trigger = 0, graindur = 0.2, sndbuf, transp = 1, pos = 0, pan = 0, envbuf = -1, amp = 1, gate = 1; var env, snd; RecordBuf.ar(SoundIn.ar(0), sndbuf, loop: 1); env = EnvGen.kr(Env.asr, gate, levelScale: amp, doneAction: 2); snd = GrainBuf.ar( numChannels: 1, trigger: Impulse.kr(trigger), dur: graindur, sndbuf: sndbuf, rate: transp, pos: pos, pan: pan, envbufnum: envbuf); snd = DelayC.ar(snd, 0.1, 0.1); // add delay OR add some reverg :) // snd = GVerb.ar(BPF.ar(snd, 90.midicps), roomsize:30, revtime:8, drylevel:0.5); snd = snd!2 * 0.8 + (SoundIn.ar([0,1]) * 0.3); // many ways to add the src :) Out.ar(0, snd * env ); // use the envelope, and out // this is a freak :) but get's env and stereo ; with out arts) //Out.ar(0, (snd!2 * 0.7) * env + (SoundIn.ar(0,1)*0.1)); // Plain and mono out //Out.ar(0, (snd * env) + SoundIn.ar(0,1)); }).add; // Play it with Pbind ... // with 'just 8' grains it bounces around nicely ;) a = Pbind( \instrument, "granular_sampling", \trigger, 8, \graindur, Pexprand(0.01, 0.9, inf), \sndbuf, b, \transp, Prand([1/4,1/3,1/2,2/3,3/4,1], inf), \pos, 0, //\pos, Pseq([1/4,1/2,3/4], inf), \pan, 0, \amp, Prand([0.5, 0.9], inf), \envbuf, -1, \dur, Prand([1+1/3,1/2,2/3,3/4,1], inf), ); a.play;