Class CrossfadingBiQuadFilter
Wraps two BiQuadFilter instances to retune a running filter without the click an in-place coefficient change causes. BiQuadFilter deliberately resets its state on every coefficient change (to recover from a divergent NaN/Inf run), so retuning it in place is discontinuous. Instead, reconfigure the Standby filter to the new settings, call BeginCrossfade(), and the output linearly crossfades from the old response to the new one over a short window.
public sealed class CrossfadingBiQuadFilter
- Inheritance
-
CrossfadingBiQuadFilter
- Inherited Members
Constructors
CrossfadingBiQuadFilter(BiQuadFilter, BiQuadFilter, int)
Creates a crossfading filter from an initially-audible
active filter and a standby filter
(a second instance used to stage the next set of coefficients). Both are
created by the caller through the public BiQuadFilter factory
methods.
public CrossfadingBiQuadFilter(BiQuadFilter active, BiQuadFilter standby, int crossfadeSamples)
Parameters
activeBiQuadFilterThe filter that is initially audible.
standbyBiQuadFilterA second filter instance used to stage the next settings.
crossfadeSamplesintLength of the retune crossfade in samples. Must be at least 1.
Properties
IsCrossfading
True while a retune crossfade is in progress.
public bool IsCrossfading { get; }
Property Value
Standby
The filter that stages the next settings. Reconfigure this (via its
Set… methods) before calling BeginCrossfade(), or replace
it wholesale with ReplaceStandby(BiQuadFilter) for filter shapes that have no
in-place setter (shelves, notch, band-pass, all-pass).
public BiQuadFilter Standby { get; }
Property Value
Methods
BeginCrossfade()
Starts crossfading from the currently-audible filter to the Standby filter. If a crossfade is already running it restarts from the beginning; the output stays continuous because both filters are run.
public void BeginCrossfade()
Process(Span<float>)
Processes a block of samples in place.
public void Process(Span<float> buffer)
Parameters
ReplaceStandby(BiQuadFilter)
Swaps in a freshly-built filter as the next settings. Use this when retuning
to a shape that has no in-place Set… method (build it with the
BiQuadFilter factories), then call BeginCrossfade().
Intended for parameter-change events, not the audio thread's steady state.
public void ReplaceStandby(BiQuadFilter filter)
Parameters
filterBiQuadFilter
Reset()
Cancels any crossfade in progress and clears both wrapped filters' sample history, so the next input is filtered as if from silence. Coefficients are left unchanged.
public void Reset()
Transform(float)
Processes one sample.
public float Transform(float input)
Parameters
inputfloat