Is there a ugen or a method with existing ugens to enable and disable circular recording into a buffer without loosing timing? For instance, if I use BufWr with a phasor, the only way I know how to (almost( stop recording is by setting the phasor to a single frame, but this will cause a discontinuity if reading from that frame. With RecordBuf I can use run to stop and start recording but as far as I can tell, not without loosing timing.
One way is to have a separate synth that reads from buses for phasor and audio signal, and uses bufwr to write the signal. Then you can free that synth to stop recording, and make a new synth to start it again (or pause/unpause the node)
I have a recordMix parameter, which crossfades between BufRd from the circular buffer (at recordMix = 0) and the live input (at recordMix = 1). Then BufWr writes the crossfade result into the buffer. So itās possible to do feedback that way but in practice, I never did. I do think itās nice, though, when disabling recording, to ramp this parameter and smooth out the discontinuity.
Ericās modularized solution is a good design, too.
hjh
Yes, that sounds like a good solution even though I would love to have it in one synthdef.
For my case I would still want whatever is in the buffer at the time of āfreezeā and not overwrite it with live input or am I misunderstanding your approach? I am not listening back from the synthdef which records to the buffer but using other synthdefs to index into the buffer.
Actually after thinking about at bit your approach is the way I will go, having one server-clock which feeds different synths sounds like the best way to keep everything in sync, plus the pause/resume scheme sounds easy. I will give it a try.
Misunderstanding ā youāre assuming that the BufRd I mentioned is an output, when Iām using it as the ānon-liveā input to the crossfader.
Pseudo-code (not at the computer):
phase = Phasor.ar(yadda);
oldBufferData = BufRd(at phase);
liveInput = In.ar or whatever;
signalToWrite = XFade2(oldBufferData, liveInput, recordMix * 2 - 1);
BufWr(signalToWrite, at phase);
hjh
Ah I get it now, thanks.
In case itās useful, one way to stop BufWr from recording is to use 2 buffers and change to a different buffer when you donāt want to record into the first one. Then you can leave the Phasor as it is.
This example uses Select.kr with LFPulse.kr to change the buffer while recording:
// allocate buffers
s = Server.local;
s.sendMsg("/b_alloc", 0, 44100 * 2);
s.sendMsg("/b_alloc", 1, 44100 * 2); // extra buffer
)
//write into alternating buffers with a BufWr
(
y = { arg rate=1, bufNumA = 0, bufNumB = 1;
var in, env, bufChoose;
in = SinOsc.ar(LFNoise1.kr(2, 300, 400), 0, 0.1);
env = Env([1, 1], [2]).ar(2); // 2 sec env
bufChoose = Select.kr(LFPulse.kr(4), [bufNumA, bufNumB]);
env * BufWr.ar(in, bufChoose, Phasor.ar(0, BufRateScale.kr(0) * rate, 0, BufFrames.kr(0)));
0.0 //quiet
}.play;
)
//read it with a BufRd
(
x = { arg rate=1, bufNumA = 0;
BufRd.ar(1, bufNumA, Phasor.ar(0, BufRateScale.kr(0) * rate, 0, BufFrames.kr(0)))
}.play(s);
)
Best,
Paul