Why does this jump from -1 to 0, instead of fading?
I don’t expect the crossfade to take 5 seconds because writing back to the bus will alter the “old” signal – but I do expect it to take longer than one control block.
(
s.waitForBoot {
k = Bus.control(s, 1).set(-1);
b = Buffer.alloc(s, s.sampleRate * 2 / s.options.blockSize, 1);
s.sync;
r = {
RecordBuf.kr(In.kr(k, 1), b, run: 1, loop: 0, doneAction: 2);
Silent.ar(1)
}.play;
0.5.wait;
a = {
var old = In.kr(k, 1);
var new = SinOsc.kr(0.1);
var fade = Line.kr(-1, 1, 5);
var t = Impulse.kr(0);
var result = LinXFade2.kr(old, new, fade);
[old, new, fade, result].poll(t);
result
}.play(outbus: k);
1.5.wait;
a.free;
{ b.plot(minval: -1, maxval: 1) }.defer;
};
)
(“Dev” topic b/c I think this is a bug.)
EDIT: Here’s a more revealing case – old signal = 0.25, new signal begins at -1, the result jumps to 0 even though neither input signal is 0 and the xfade is not in the middle.
That points to an initialization bug – a 0 is being returned somewhere and written back onto the bus, corrupting the rest of the crossfade.
(
s.waitForBoot {
k = Bus.control(s, 1).set(0.25);
b = Buffer.alloc(s, s.sampleRate * 2 / s.options.blockSize, 1);
s.sync;
r = {
RecordBuf.kr(In.kr(k, 1), b, run: 1, loop: 0, doneAction: 2);
Silent.ar(1)
}.play;
0.5.wait;
a = {
var old = In.kr(k, 1);
var new = SinOsc.kr(0.1, -0.5pi); // negative cosine
var fade = Line.kr(-1, 1, 5);
var t = Impulse.kr(0);
var result = LinXFade2.kr(old, new, fade);
[old, new, fade, result].poll(t);
result
}.play(outbus: k);
1.5.wait;
a.free;
{ b.plot(minval: -1, maxval: 1) }.defer;
};
)
hjh