Dear list,
i’m trying to figure out how to seamlessly playback continuously recording buffers at variable rates/reading positions (delays). To avoid rec and playback points coinciding im setting up two buffers of which one is recording input and the other playing back and fading between them so as only to hear the already recorded buffer.
in this example there are still clicks due to the sudden muting of one of the recording buffer (lagging the demand ugen it makes worse). Any advice how to optimize this or other ideas to make it possible to have seamless variable rate playback with live input? (I also tried a setup with RecordBuf but to no avail…seemed easier than it turns out to be!)
(
b = Buffer.alloc(s,s.sampleRate*2);
c = Buffer.alloc(s,s.sampleRate*2);
)
(
SynthDef(\buftest,{|freq|
var sig=SinOsc.ar(200*LFDNoise3.kr(1).range(1,4));
var bdur=BufDur.kr(b);
var trig=Impulse.ar(1/bdur);
var delay=((0.1*(1..8)/8)*BufFrames.kr(b));
var playbackrate=MouseY.kr(0.5,2,1);
var switch=Demand.ar(trig,0,Dseq([-1,1],inf)).lag(0.05);
var mute1=Demand.ar(trig,0,Dseq([1,0],inf)).lag(0); //rec switch
var mute2=Demand.ar(trig,0,Dseq([0,1],inf)).lag(0);
var wphasor=Phasor.ar(0,BufRateScale.kr(b),0,BufFrames.kr(b));
var rphasor=Phasor.ar(0,BufRateScale.kr(b)*playbackrate,0,BufFrames.kr(b));
var rec1= BufWr.ar(sig*mute1,b,wphasor*mute1); //muting buffer recording alternatively
var rec2= BufWr.ar(sig*mute1,c,wphasor*mute1);
var snd1=(BufRd.ar(1,b,rphasor-delay,1,4));
var snd2=BufRd.ar(1,c,rphasor-delay,1,4);
var mix= LinXFade2.ar(snd2,snd1,switch); //hear buffer that is currently not recording
Out.ar(0, Pan2.ar(sum(mix)));}
).add
)
a = Synth(\buftest);
Thank you!
Jan