Hi all,
I’ve been tinkering with RecordBuf/PlayBuf combinations, and encountered a situation I don’t fully understand. I’m writing to a buffer while simultaneously playing the contents of the buffer to speakers. If RecordBuf’s offset value is >= s.options.blockSize, I get expected results. If the offset is between 0 and the block size, the output is glitchy, and the waveform has the appearance of two interleaved waveforms (screenshot included). If offset is zero (the default), there is a delay equal to the buffer’s duration before sound is heard.
(offset = s.options.blockSize - 7)
I can accept the fact that trying to perform interrelated processes within the same control block are prone to these sorts of issues — perhaps not guaranteed to occur in the correct order. I would like to understand more deeply why these sub-blockSize results occur, if anyone is able and willing to explain.
Thanks,
Eli
s.boot;
z = Buffer.alloc(s, s.sampleRate/4);
(
SynthDef(\rec, { |buf=0, offset=0, out=0|
var sig, delay;
sig = BPF.ar(WhiteNoise.ar, 500, 0.01, 4);
RecordBuf.ar(sig, buf, offset);
delay = PlayBuf.ar(1, buf, loop:1);
delay = delay + Impulse.ar(0, mul:0.5);
Out.ar(out, delay!2);
}).add;
)
//fine:
x = Synth(\rec, [buf:z, offset:s.options.blockSize]);
(
x.free;
z.zero;
)
// > blocksize also fine
x = Synth(\rec, [buf:z, offset:s.options.blockSize * 50.19]);
(
x.free;
z.zero;
)
//(0 < offset < block size) produces glitchy sound
x = Synth(\rec, [buf:z, offset:s.options.blockSize - 7]);
(
x.free;
z.zero;
)
//0 offset produces buffer-length delay before sounding
x = Synth(\rec, [buf:z, offset:0]);
(
x.free;
z.zero;
)