#include <Filters/BiQuad.hpp>
BiQuad filter Direct Form 1 implementation that normalizes the coefficients upon initialization.
This class is faster than NonNormalizingBiQuadFilterDF1, because each filter iteration involves only addition and multiplication, no divisions.
It works great for floating point numbers, but might be less ideal for integer types, because it can create large rounding errors on the coefficients.
Implements the following difference equation:
\[ y[n] = \frac{b_0 \cdot x[n] + b_1 \cdot x[n-1] + b_2 \cdot x[n-2] - a_1 \cdot y[n-1] - a_2 \cdot y[n-2]}{a_0} \]
Definition at line 39 of file BiQuad.hpp.
Public Member Functions | |
NormalizingBiQuadFilterDF1 ()=default | |
NormalizingBiQuadFilterDF1 (const AH::Array< T, 3 > &b, const AH::Array< T, 3 > &a) | |
NormalizingBiQuadFilterDF1 (const BiQuadCoefficients< T > &coefficients) | |
NormalizingBiQuadFilterDF1 (const AH::Array< T, 3 > &b, const AH::Array< T, 3 > &a, T gain) | |
NormalizingBiQuadFilterDF1 (const BiQuadCoefficients< T > &coefficients, T gain) | |
T | operator() (T input) |
Update the internal state with the new input \( x[n] \) and return the new output \( y[n] \). More... | |
Static Public Member Functions | |
template<bool Enable = true> | |
static std::enable_if_t< std::is_floating_point< T >::value &&Enable, T > | update (T input, AH::Array< T, 2 > &x, AH::Array< T, 2 > &y, const AH::Array< T, 3 > &b, const AH::Array< T, 2 > &a) |
template<bool Enable = true> | |
static std::enable_if_t<!std::is_floating_point< T >::value &&Enable, T > | update (T input, AH::Array< T, 2 > &x, AH::Array< T, 2 > &y, const AH::Array< T, 3 > &b, const AH::Array< T, 2 > &a) |
Private Attributes | |
AH::Array< T, 2 > | x = {{}} |
Previous inputs. More... | |
AH::Array< T, 2 > | y = {{}} |
Previous outputs. More... | |
AH::Array< T, 3 > | b = {{}} |
Numerator coefficients. More... | |
AH::Array< T, 2 > | a = {{}} |
Denominator coefficients. More... | |
|
default |
|
inline |
Definition at line 43 of file BiQuad.hpp.
|
inline |
Definition at line 47 of file BiQuad.hpp.
|
inline |
Definition at line 50 of file BiQuad.hpp.
|
inline |
Definition at line 54 of file BiQuad.hpp.
|
inlinestatic |
Definition at line 60 of file BiQuad.hpp.
|
inlinestatic |
Definition at line 76 of file BiQuad.hpp.
|
inline |
Update the internal state with the new input \( x[n] \) and return the new output \( y[n] \).
input | The new input \( x[n] \). |
Definition at line 98 of file BiQuad.hpp.
|
private |
Previous inputs.
Definition at line 101 of file BiQuad.hpp.
|
private |
Previous outputs.
Definition at line 102 of file BiQuad.hpp.
|
private |
Numerator coefficients.
Definition at line 103 of file BiQuad.hpp.
|
private |
Denominator coefficients.
Definition at line 104 of file BiQuad.hpp.