Arduino Filters master
Filter library for Arduino
Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
NormalizingBiQuadFilterDF2< T > Class Template Reference

#include <Filters/BiQuad.hpp>

Detailed Description

template<class T>
class NormalizingBiQuadFilterDF2< T >

BiQuad filter Direct Form 2 implementation that normalizes the coefficients upon initialization.

This class is faster than NonNormalizingBiQuadFilterDF2, 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 311 of file BiQuad.hpp.

+ Collaboration diagram for NormalizingBiQuadFilterDF2< T >:

Public Member Functions

 NormalizingBiQuadFilterDF2 ()=default
 
 NormalizingBiQuadFilterDF2 (const AH::Array< T, 3 > &b, const AH::Array< T, 3 > &a)
 
 NormalizingBiQuadFilterDF2 (const BiQuadCoefficients< T > &coefficients)
 
 NormalizingBiQuadFilterDF2 (const AH::Array< T, 3 > &b, const AH::Array< T, 3 > &a, T gain)
 
 NormalizingBiQuadFilterDF2 (const BiQuadCoefficients< T > &coefficients, T gain)
 
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 > &w, 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 > &w, const AH::Array< T, 3 > &b, const AH::Array< T, 2 > &a)
 

Private Attributes

AH::Array< T, 2 > w = {{}}
 Internal state. More...
 
AH::Array< T, 3 > b = {{}}
 Numerator coefficients. More...
 
AH::Array< T, 2 > a = {{}}
 Denominator coefficients. More...
 

Constructor & Destructor Documentation

◆ NormalizingBiQuadFilterDF2() [1/5]

◆ NormalizingBiQuadFilterDF2() [2/5]

NormalizingBiQuadFilterDF2 ( const AH::Array< T, 3 > &  b,
const AH::Array< T, 3 > &  a 
)
inline

Definition at line 315 of file BiQuad.hpp.

◆ NormalizingBiQuadFilterDF2() [3/5]

NormalizingBiQuadFilterDF2 ( const BiQuadCoefficients< T > &  coefficients)
inline

Definition at line 319 of file BiQuad.hpp.

◆ NormalizingBiQuadFilterDF2() [4/5]

NormalizingBiQuadFilterDF2 ( const AH::Array< T, 3 > &  b,
const AH::Array< T, 3 > &  a,
gain 
)
inline

Definition at line 322 of file BiQuad.hpp.

◆ NormalizingBiQuadFilterDF2() [5/5]

NormalizingBiQuadFilterDF2 ( const BiQuadCoefficients< T > &  coefficients,
gain 
)
inline

Definition at line 326 of file BiQuad.hpp.

Member Function Documentation

◆ update() [1/2]

static std::enable_if_t< std::is_floating_point< T >::value &&Enable, T > update ( input,
AH::Array< T, 2 > &  w,
const AH::Array< T, 3 > &  b,
const AH::Array< T, 2 > &  a 
)
inlinestatic

Definition at line 332 of file BiQuad.hpp.

◆ update() [2/2]

static std::enable_if_t<!std::is_floating_point< T >::value &&Enable, T > update ( input,
AH::Array< T, 2 > &  w,
const AH::Array< T, 3 > &  b,
const AH::Array< T, 2 > &  a 
)
inlinestatic

Definition at line 346 of file BiQuad.hpp.

◆ operator()()

T operator() ( input)
inline

Update the internal state with the new input \( x[n] \) and return the new output \( y[n] \).

Parameters
inputThe new input \( x[n] \).
Returns
The new output \( y[n] \).

Definition at line 366 of file BiQuad.hpp.

Member Data Documentation

◆ w

AH::Array<T, 2> w = {{}}
private

Internal state.

Definition at line 369 of file BiQuad.hpp.

◆ b

AH::Array<T, 3> b = {{}}
private

Numerator coefficients.

Definition at line 370 of file BiQuad.hpp.

◆ a

AH::Array<T, 2> a = {{}}
private

Denominator coefficients.

Definition at line 371 of file BiQuad.hpp.


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