eDSP  0.0.1
A cross-platform DSP library written in C++.
Public Types | Public Member Functions | List of all members
edsp::filter::biquad< T > Class Template Reference

This Biquad class implements a second-order recursive linear filter, containing two poles and two zeros. More...

#include <biquad.hpp>

Public Types

using value_type = T
 

Public Member Functions

constexpr biquad () noexcept=default
 
constexpr biquad (const biquad &) noexcept=default
 
constexpr biquad (biquad &&) noexcept=default
 
constexpr biquadoperator= (const biquad &) noexcept=default
 
constexpr biquadoperator= (biquad &&) noexcept=default
 
constexpr biquad (const std::complex< T > &pole, const std::complex< T > &zero)
 Initialize a Biquad filter with one single pole and zero. More...
 
constexpr biquad (const std::complex< T > &pole_first, const std::complex< T > &zero_first, const std::complex< T > &pole_second, const std::complex< T > &zero_second)
 Initialize a Biquad filter with a pair of zero-pole. More...
 
constexpr biquad (value_type a0, value_type a1, value_type a2, value_type b0, value_type b1, value_type b2) noexcept
 Initialize a Biquad fitler with the given coefficients. More...
 
 ~biquad ()=default
 Default destructor. More...
 
constexpr value_type a0 () const noexcept
 Returns the value of the coefficient \( a_0 \). More...
 
constexpr value_type a1 () const noexcept
 Returns the value of the coefficient \( a_1 \). More...
 
constexpr value_type a2 () const noexcept
 Returns the value of the coefficient \( a_2 \). More...
 
constexpr value_type b0 () const noexcept
 Returns the value of the coefficient \( b_0 \). More...
 
constexpr value_type b1 () const noexcept
 Returns the value of the coefficient \( b_1 \). More...
 
constexpr value_type b2 () const noexcept
 Returns the value of the coefficient \( b_2 \). More...
 
constexpr void set_a0 (T value) noexcept
 Updates the value of the coefficient \( a_0 \). More...
 
constexpr void set_a1 (T value) noexcept
 Updates the value of the coefficient \( a_1 \). More...
 
constexpr void set_a2 (T value) noexcept
 Updates the value of the coefficient \( a_2 \). More...
 
constexpr void set_b0 (T value) noexcept
 Updates the value of the coefficient \( b_0 \). More...
 
constexpr void set_b1 (T value) noexcept
 Updates the value of the coefficient \( b_1 \). More...
 
constexpr void set_b2 (T value) noexcept
 Updates the value of the coefficient \( b_2 \). More...
 
template<typename InputIt , typename OutputIt >
constexpr void filter (InputIt first, InputIt last, OutputIt d_first)
 Filters the signal in the range [first, last) and stores the result in another range, beginning at d_first. More...
 
constexpr void reset () noexcept
 Reset the filter to the original state. More...
 
constexpr bool stability () const noexcept
 Checks if the Biquad Filter is stable. More...
 
constexpr operator bool () const noexcept
 Boolean operator to checks if the filter is stable. More...
 
constexpr value_type tick (T value) noexcept
 Computes the output of filtering one digital time-step. More...
 

Detailed Description

template<typename T>
class edsp::filter::biquad< T >

This Biquad class implements a second-order recursive linear filter, containing two poles and two zeros.

In the Z domain, its transfer function is:

\[ H(z)={\frac {b_{0}+b_{1}z^{{-1}}+b_{2}z^{{-2}}}{a_{0}+a_{1}z^{{-1}}+a_{2}z^{{-2}}}} \]

Which is often normalized by dividing all coefficients by a0. This class performs the filtering with a Direct Form I:

\[ y[n]={\frac {1}{a_{0}}}\left(b_{0}x[n]+b_{1}x[n-1]+b_{2}x[n-2]-a_{1}y[n-1]-a_{2}y[n-2]\right) \]

Member Typedef Documentation

◆ value_type

template<typename T>
using edsp::filter::biquad< T >::value_type = T

Constructor & Destructor Documentation

◆ biquad() [1/6]

template<typename T>
constexpr edsp::filter::biquad< T >::biquad ( )
defaultnoexcept

◆ biquad() [2/6]

template<typename T>
constexpr edsp::filter::biquad< T >::biquad ( const biquad< T > &  )
defaultnoexcept

◆ biquad() [3/6]

template<typename T>
constexpr edsp::filter::biquad< T >::biquad ( biquad< T > &&  )
defaultnoexcept

◆ biquad() [4/6]

template<typename T >
constexpr edsp::filter::biquad< T >::biquad ( const std::complex< T > &  pole,
const std::complex< T > &  zero 
)

Initialize a Biquad filter with one single pole and zero.

Parameters
poleComplex value representing the pole.
zeroComplex value representing the zero.

◆ biquad() [5/6]

template<typename T >
constexpr edsp::filter::biquad< T >::biquad ( const std::complex< T > &  pole_first,
const std::complex< T > &  zero_first,
const std::complex< T > &  pole_second,
const std::complex< T > &  zero_second 
)

Initialize a Biquad filter with a pair of zero-pole.

Parameters
pole_firstComplex value representing the first pole.
zero_firstComplex value representing the first zero.
pole_secondComplex value representing the second pole.
zero_secondComplex value representing the second zeo.

◆ biquad() [6/6]

template<typename T >
constexpr edsp::filter::biquad< T >::biquad ( value_type  a0,
value_type  a1,
value_type  a2,
value_type  b0,
value_type  b1,
value_type  b2 
)
noexcept

Initialize a Biquad fitler with the given coefficients.

Parameters
a0Value of the coefficient \( a_0 \).
a1Value of the coefficient \( a_1 \).
a2Value of the coefficient \( a_2 \).
b0Value of the coefficient \( b_0 \).
b1Value of the coefficient \( b_1 \).
b2Value of the coefficient \( b_2 \).

◆ ~biquad()

template<typename T>
edsp::filter::biquad< T >::~biquad ( )
default

Default destructor.

Member Function Documentation

◆ a0()

template<typename T >
constexpr biquad< T >::value_type edsp::filter::biquad< T >::a0 ( ) const
noexcept

Returns the value of the coefficient \( a_0 \).

Returns
Value of the coefficient \( a_0 \).

◆ a1()

template<typename T >
constexpr biquad< T >::value_type edsp::filter::biquad< T >::a1 ( ) const
noexcept

Returns the value of the coefficient \( a_1 \).

Returns
Value of the coefficient \( a_1 \).

◆ a2()

template<typename T >
constexpr biquad< T >::value_type edsp::filter::biquad< T >::a2 ( ) const
noexcept

Returns the value of the coefficient \( a_2 \).

Returns
Value of the coefficient \( a_2 \).

◆ b0()

template<typename T >
constexpr biquad< T >::value_type edsp::filter::biquad< T >::b0 ( ) const
noexcept

Returns the value of the coefficient \( b_0 \).

Returns
Value of the coefficient \( b_0 \).

◆ b1()

template<typename T >
constexpr biquad< T >::value_type edsp::filter::biquad< T >::b1 ( ) const
noexcept

Returns the value of the coefficient \( b_1 \).

Returns
Value of the coefficient \( b_1 \).

◆ b2()

template<typename T >
constexpr biquad< T >::value_type edsp::filter::biquad< T >::b2 ( ) const
noexcept

Returns the value of the coefficient \( b_2 \).

Returns
Value of the coefficient \( b_2 \).

◆ filter()

template<typename T >
template<typename InputIt , typename OutputIt >
constexpr void edsp::filter::biquad< T >::filter ( InputIt  first,
InputIt  last,
OutputIt  d_first 
)

Filters the signal in the range [first, last) and stores the result in another range, beginning at d_first.

Parameters
firstInput iterator defining the beginning of the input range.
lastInput iterator defining the ending of the input range.
d_firstOutput iterator defining the beginning of the destination range.
See also
tick

◆ operator bool()

template<typename T >
constexpr edsp::filter::biquad< T >::operator bool ( ) const
explicitnoexcept

Boolean operator to checks if the filter is stable.

See also
stability

◆ operator=() [1/2]

template<typename T>
constexpr biquad& edsp::filter::biquad< T >::operator= ( const biquad< T > &  )
defaultnoexcept

◆ operator=() [2/2]

template<typename T>
constexpr biquad& edsp::filter::biquad< T >::operator= ( biquad< T > &&  )
defaultnoexcept

◆ reset()

template<typename T >
constexpr void edsp::filter::biquad< T >::reset ( )
noexcept

Reset the filter to the original state.

◆ set_a0()

template<typename T >
constexpr void edsp::filter::biquad< T >::set_a0 ( value)
noexcept

Updates the value of the coefficient \( a_0 \).

Returns
value Value of the coefficient \( a_0 \).

◆ set_a1()

template<typename T >
constexpr void edsp::filter::biquad< T >::set_a1 ( value)
noexcept

Updates the value of the coefficient \( a_1 \).

Returns
value Value of the coefficient \( a_1 \).

◆ set_a2()

template<typename T >
constexpr void edsp::filter::biquad< T >::set_a2 ( value)
noexcept

Updates the value of the coefficient \( a_2 \).

Returns
value Value of the coefficient \( a_2 \).

◆ set_b0()

template<typename T >
constexpr void edsp::filter::biquad< T >::set_b0 ( value)
noexcept

Updates the value of the coefficient \( b_0 \).

Returns
value Value of the coefficient \( b_0 \).

◆ set_b1()

template<typename T >
constexpr void edsp::filter::biquad< T >::set_b1 ( value)
noexcept

Updates the value of the coefficient \( b_1 \).

Returns
value Value of the coefficient \( b_1 \).

◆ set_b2()

template<typename T >
constexpr void edsp::filter::biquad< T >::set_b2 ( value)
noexcept

Updates the value of the coefficient \( b_2 \).

Returns
value Value of the coefficient \( b_2 \).

◆ stability()

template<typename T >
constexpr bool edsp::filter::biquad< T >::stability ( ) const
noexcept

Checks if the Biquad Filter is stable.

In general, the two poles of the biquad filter must be inside the unit circle for it to be stable

Returns
true if the filter is stable, false otherwise.

◆ tick()

template<typename T >
constexpr biquad< T >::value_type edsp::filter::biquad< T >::tick ( value)
noexcept

Computes the output of filtering one digital time-step.

Parameters
valueInput value to be filtered.
Returns
Filtered value.

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