MostlyHarmless 0.0.1
 
Loading...
Searching...
No Matches
marvin::dsp::filters::Biquad< SampleType, NumStages > Class Template Referencefinal

A cascading direct form ii biquad filter. More...

#include <marvin_Biquad.h>

Public Member Functions

void setCoeffs (size_t stage, BiquadCoefficients< SampleType > coeffs) noexcept
 
SampleType operator() (SampleType x) noexcept
 
void reset () noexcept
 

Detailed Description

template<FloatType SampleType, size_t NumStages>
class marvin::dsp::filters::Biquad< SampleType, NumStages >

A cascading direct form ii biquad filter.

Biquads have a tendency to "blow up" at high modulation frequencies, so keep in mind that a StateVariableFilter (coming soon) might be a better choice if that's the kind of thing you need. Uses a coeffs as the numerators (zeroes) and b coeffs as the denominators (poles).
Usage example:

class Processor final {
public:
void initialise(double sampleRate) {
const auto coeffs = marvin::dsp::filters::rbj::lowpass<float>(sampleRate, 1000.0f, 0.5f);
m_lpf.setCoeffs(0, coeffs);
}
[[nodiscard]] float operator()(float x) noexcept {
const auto filtered = m_lpf(x);
return filtered;
}
void reset() noexcept {
m_lpf.reset();
}
private:
};
A cascading direct form ii biquad filter.
Definition marvin_Biquad.h:49
BiquadCoefficients< SampleType > lowpass(double sampleRate, SampleType cutoff, SampleType q) noexcept
Definition marvin_RBJCoefficients.h:25

Member Function Documentation

◆ operator()()

template<FloatType SampleType, size_t NumStages>
SampleType marvin::dsp::filters::Biquad< SampleType, NumStages >::operator() ( SampleType x)
inlinenodiscardnoexcept

Processes a sample through the biquad cascade.

Parameters
xThe sample to filter.
Returns
The filtered sample.

◆ reset()

template<FloatType SampleType, size_t NumStages>
void marvin::dsp::filters::Biquad< SampleType, NumStages >::reset ( )
inlinenoexcept

Initialises the filter to its default state (does not zero the coefficients).

◆ setCoeffs()

template<FloatType SampleType, size_t NumStages>
void marvin::dsp::filters::Biquad< SampleType, NumStages >::setCoeffs ( size_t stage,
BiquadCoefficients< SampleType > coeffs )
inlinenoexcept

Sets the coeffs the Biquad should use. Note that BiquadCoefficients is trivially copyable (and is just a POD type), so this function can be (and should be) called on the audio thread - the BiquadCoefficients class' members aren't atomic.

Parameters
stageThe stage to assign these coefficients to. Must be less than NumStages.
coeffsThe coeffs to set.

The documentation for this class was generated from the following file: