Hi there!
I wish this message finds you well!
I am studying Eli Fieldsteel Line6 loop pedal emulation (Week 4: Intermediate Coding with SuperCollider – MUS 499C Spring 2021 - YouTube).
What I would like to do is to use only the loop part (the recording part) for further processing techniques (e…g: delays, time-stretches, granular synthesis, FM or any other.)
The looper SynthDef is the following:
SynthDef(\looper, {
var mic, trig, max, ptr, loop, rec, mix;
var xfade = \xfade.kr(0.02);
var buf = \buf.kr(0);
mic = SoundIn.ar(\in.ir(0));
trig = Trig1.ar(\trig.tr(0), ControlDur.ir);
max = Sweep.ar(trig, SampleRate.ir * \run.kr(0));
ptr = Phasor.ar(trig, 1, 0, max, 0);
loop = BufRd.ar(1, buf, ptr);
rec = sum([
mic * \reclev.kr(0).varlag(xfade,-2),
loop * \prelev.kr(0).varlag(xfade,-2)
]);
rec = rec * \recAmp.kr(1).varlag(xfade,-2);
BufWr.ar(rec, buf, ptr);
mix = sum([
loop * \loopAmp.kr(1).varlag(xfade,-2),
mic * \micAmp.kr(1).varlag(xfade,-2) * 0;
]);
mix = mix * \mixAmp.kr(1).varlag(xfade,-2);
Out.ar(\out.ir(0), mix!2);
}).add;
and the buffer.aloc is the following:
// ~b = Buffer.alloc(s, s.sampleRate * 13, 1); //13 seconds of maximum size for example
Then, the SynthDef for further processing:
SynthDef(\playLinearSin, {
arg syncSigOrPar = 0, syncPar = 1, start = 1, end = 10, dur = 8, lineAmp = 1,
buf = 0, rate = 1, atk = 0.1, rel = 1, c1 = 3, c2 = (-1), spos = 0,
parFreq = 5, parScale = 1, minPar = 1, maxPar = 100, durPar = 10, pan = 0, amp = 1, out = 0;
var env, sin, sig, par, sigOrpar;
env = Env([0,1,0], [atk, rel], [c1, c2]).kr(2);
sin = SinOsc.ar(Line.kr(start, end, dur), 0, lineAmp);
par = Select.ar(syncPar, [LFPar.ar(parFreq), LFPar.ar(Line.kr(minPar, maxPar, durPar))]);
sig = PlayBuf.ar(2, buf, rate, startPos: spos);
sigOrpar = Select.ar(syncSigOrPar, [sig * sin * env, sig * sin * par * env]);
sig = sigOrpar;
sig = Pan2.ar(sig, pan, amp);
Out.ar(out, sig);
}).add;
and to play this synth:
(
Synth(\playLinearSin, [\buf, ~b, \amp, 1, \rate, rrand(-12,12).midiratio, \end, 20, \rel, 8,
\parFreq, rrand(2,8), \syncSigOrPar, 0, \syncPar, 1]);
)
I know that this ~b is related to the whole Buffer allocation (the whole 13 seconds in the example)
I intend to use only the loop part, for example, to play it back, to process some effects…
How can I do that, please? any tips?
Any help will be amazing,
Thank you so much!