Hello everyone,
For a project I’m looking to trigger live recordings (using RecordBuf) with a pedal (MIDI control). The problem I have is that I only have one pedal and I want to make about 10 recordings during the performance.
Here is the code I have so far
(
Buffer.freeAll;
~buffers = 10.collect{
Buffer.alloc(s, s.sampleRate*(rrand(2.0,10.0)), 1)
})
(
~rec = 10.collect{
arg index;
{RecordBuf.ar(
inputArray: SoundIn.ar(0),
bufnum: ~buffers[index].bufnum,
recLevel: 1.0.varlag(0.05),
preLevel: 0.0.varlag(0.05),
loop: 0,
doneAction: 2,
)};
}
)
//attention au feedback!
~rec[0].play
~rec[0].stop
(
SynthDef(\playBuf, {
arg bufnum, rate=1.0, out=0, pos=0.0, pan=0.0, amp=0.5, trig=1, freqFiltre=2000, gate = 1, envatk=0.01, envrel=1;
var sig, env;
env = EnvGen.kr(Env.adsr(envatk, releaseTime: envrel), gate, amp, doneAction:2);
sig = PlayBuf.ar(
numChannels: 1,
bufnum: bufnum,
rate: rate*BufRateScale.kr(bufnum),
trigger: trig,
startPos: BufFrames.kr(bufnum)* pos,
loop:0,
doneAction:0,
);
sig = RLPF.ar(sig, freqFiltre);//.lag(0.1), 0.5);
sig =Pan2.ar(sig, pan);
Out.ar(out, sig*env);
}).add;
)
d = Synth(\playBuf,[\bufnum, ~buffers[0]]);
d.release;
(
MIDIClient.init;
MIDIIn.connectAll;
MIDIdef.cc(\rec, {
arg vel, num;
(vel == 127).if
(
{~rec[0].play},
)
}, 19);
)
And I’m wondering how I can make it so that once the first recording is done (stored in ~buffers[0]), I can make a second recording stored in ~buffers[1] and so on, with only one pedal.
Does anyone have a clue?
Thank you very much for your attention.