What is the best way to fill the contents of buffer and reading them in real time. Is there something I can do to make it sound a bit more interesting, assuming my one single buffer was more interesting musically, sounded more rich but when I am scaling it up to four buffers it creates clicks and cracks but nothing in between like in the single buffer case which I have tried. Code is below, and any tips appreciated.
//The buffs and control signals writing in the formers.
c = {Bus.control(s, 1)}!4;
b = {Buffer.alloc(s, 44100, 1)}!4;
//Input is a set of control device parameters but any between -1.0 and 1.0 will do.
[14, 15, 16, 17].collect{
|el, i|
~gamepad.elements[el].action = {|...args|
c[i].set(args[0].range(-1.0, 1.0));
};
};
//The synths, writing and reading consequently:
(
s.waitForBoot{
SynthDef(\record_buf, { arg out=0, input=0, bufnum=0, gate = 1, speed=1, offset=0.5, mul=1, dur = 2;
EnvGen.kr( Env.sine, gate, dur ) * BufWr.kr(In.kr(input, 1) * mul - offset, bufnum, Phasor.kr( gate, speed, 0, BufFrames.kr(bufnum) ), loop:1);
}).add;
s.sync;
SynthDef(\play_buf, { arg out = 0, bufnum = 0, rate = 1;
var playbuf;
playbuf = BufRd.ar(1, bufnum, LFSaw.ar(BufDur.ir(bufnum).reciprocal * rate * 2).range(0, BufFrames.ir(bufnum)) );
playbuf = LeakDC.ar(HPF.ar(playbuf, 60), 0.995);
Out.ar(out, playbuf.dup);
}).add;
}
)
(
~rec = Group();
~play = Group();
[0, 1, 2, 3].collect{ |i|
Synth(\record_buf, [\input, c[i].index, \bufnum, b[i].bufnum, \speed, 1], target:~rec);
Synth(\play_buf, [\out, 0, \bufnum, b[i].bufnum, \rate, 12], target:~play);
}
)
Thanks