-
- if k == ho and xfade == 0 then
- ARDOUR.DSP.copy_vector (outs[c]:offset (off), mem:to_float (off), siz)
- elseif k == ho + 1 then
- ARDOUR.DSP.mix_buffers_with_gain (outs[c]:offset (off), mem:to_float (off), siz, xfade)
- end
+ end
+ ARDOUR.DSP.copy_vector (outs[c]:offset (off), mem:to_float (off), siz)
+
+ -- mix the output of |ho| biquads (with weight |1-xfade|)
+ -- with the output of |ho+1| biquads (with weight |xfade|)
+ if xfade > 0 then
+ ARDOUR.DSP.apply_gain_to_buffer (outs[c]:offset (off), siz, 1 - xfade)
+ hp[c][ho+1]:run (mem:to_float (off), siz)
+ ARDOUR.DSP.mix_buffers_with_gain (outs[c]:offset (off), mem:to_float (off), siz, xfade)
+ -- also run the next biquad because it needs to have the correct state
+ -- in case it start affecting the next chunck of output. Higher order
+ -- ones are guaranteed not to be needed for the next run because the
+ -- interpolated order won't increase more than 0.86 in one step thanks
+ -- to the choice of the value of |lpf|.
+ if ho + 2 <= 4 then hp[c][ho+2]:run (mem:to_float (off), siz) end
+ elseif ho + 1 <= 4 then
+ -- run the next biquad in case it is used next chunk
+ hp[c][ho+1]:run (mem:to_float (off), siz)