Biquad.h
#ifndef IIR1_BIQUAD_H
#define IIR1_BIQUAD_H
#include "Common.h"
#include "MathSupplement.h"
#include "Types.h"
namespace Iir {
struct DllExport BiquadPoleState;
/*
* Holds coefficients for a second order Infinite Impulse Response
* digital filter. This is the building block for all IIR filters.
*
*/
class DllExport Biquad
{
public:
complex_t response (double normalizedFrequency) const;
std::vector<PoleZeroPair> getPoleZeros () const;
double getA0 () const { return m_a0; }
double getA1 () const { return m_a1*m_a0; }
double getA2 () const { return m_a2*m_a0; }
double getB0 () const { return m_b0*m_a0; }
double getB1 () const { return m_b1*m_a0; }
double getB2 () const { return m_b2*m_a0; }
template <class StateType>
inline double filter(double s, StateType& state) const
{
return state.filter(s, *this);
}
public:
void setCoefficients (double a0, double a1, double a2,
double b0, double b1, double b2);
void setOnePole (complex_t pole, complex_t zero);
void setTwoPole (complex_t pole1, complex_t zero1,
complex_t pole2, complex_t zero2);
void setPoleZeroPair (const PoleZeroPair& pair)
{
if (pair.isSinglePole ())
setOnePole (pair.poles.first, pair.zeros.first);
else
setTwoPole (pair.poles.first, pair.zeros.first,
pair.poles.second, pair.zeros.second);
}
void setPoleZeroForm (const BiquadPoleState& bps);
void setIdentity ();
void applyScale (double scale);
public:
double m_a0 = 1;
double m_a1 = 0;
double m_a2 = 0;
double m_b1 = 0;
double m_b2 = 0;
double m_b0 = 1;
};
//------------------------------------------------------------------------------
struct DllExport BiquadPoleState : PoleZeroPair
{
BiquadPoleState () { }
explicit BiquadPoleState (const Biquad& s);
double gain = 1;
};
}
#endif
Iir::Biquad::getA0
double getA0() const
Definition: Biquad.h:69
Iir::Biquad
Definition: Biquad.h:52
Iir::Biquad::getA1
double getA1() const
Definition: Biquad.h:74
Iir::Biquad::setPoleZeroPair
void setPoleZeroPair(const PoleZeroPair &pair)
Definition: Biquad.h:135
Iir::Biquad::getB1
double getB1() const
Definition: Biquad.h:89
Iir::Biquad::getA2
double getA2() const
Definition: Biquad.h:79
Iir
Definition: Biquad.cpp:41
Iir::Biquad::getB0
double getB0() const
Definition: Biquad.h:84
Iir::PoleZeroPair
Definition: Types.h:100
Iir::Biquad::filter
double filter(double s, StateType &state) const
Definition: Biquad.h:103
Iir::BiquadPoleState
Definition: Biquad.h:173
Iir::Biquad::getB2
double getB2() const
Definition: Biquad.h:94