IirBiquad
Namespace: RTPROCESSINGLIB · Library: DSP Library
#include <dsp/iirfilter.h>
struct UTILSLIB::IirBiquad
Coefficients of one second-order IIR section (biquad).
Transfer function (Direct-Form II):
H(z) = (b0 + b1*z^-1 + b2*z^-2) / (1 + a1*z^-1 + a2*z^-2)
Note: a0 is normalised to 1. For first-order sections set b2 = a2 = 0.
src/examples/ex_dsp_spectral/main.cpp
const QVector<IirBiquad> sos = IirFilter::designButterworth(4, IirFilter::LowPass, 30.0, 0.0, kSFreq);
const RowVectorXd lowPassed = IirFilter::applyZeroPhase(signal, sos); // forward-backward, no phase shift
Example
- Full source:
src/examples/ex_dsp_spectral/main.cpp - Build target:
ex_dsp_spectral(runs under CTest)
Used in examples
ex_dsp_spectral
Spectral and filtering tools of the dsp library on signals with known content.
src/examples/ex_dsp_spectral/main.cpp, line 97
double gainAt(const QVector<IirBiquad>& sos, double freq)
{
const std::complex<double> z = std::polar(1.0, -2.0 * kPi * freq / kSFreq); // z^-1
std::complex<double> h(1.0, 0.0);
for (const IirBiquad& s : sos) {
h *= (s.b0 + s.b1 * z + s.b2 * z * z) / (1.0 + s.a1 * z + s.a2 * z * z);
}
return std::abs(h);
}
Authors of this file
- Christoph Dinh <christoph.dinh@mne-cpp.org>