«looping buffer granuals» by blueprint

on 15 Feb'18 11:47 in liveloopgrainsgranular

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 ....

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// 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;
raw 1504 chars (focus & ctrl+a+c to copy)
reception
comments