v2.0.0
Loading...
Searching...
No Matches
UTILSLIB::IirFilter Class Reference

Butterworth IIR filter design and application using second-order sections. More...

#include <iirfilter.h>

Public Types

enum  FilterType { LowPass = 0 , HighPass = 1 , BandPass = 2 , BandStop = 3 }
 Filter type selector. More...

Static Public Member Functions

static QVector< IirBiquaddesignButterworth (int iOrder, FilterType type, double dCutoffLow, double dCutoffHigh, double dSFreq)
static Eigen::RowVectorXd applySos (const Eigen::RowVectorXd &vecData, const QVector< IirBiquad > &sos)
static Eigen::RowVectorXd applyZeroPhase (const Eigen::RowVectorXd &vecData, const QVector< IirBiquad > &sos)
static Eigen::MatrixXd applyZeroPhaseMatrix (const Eigen::MatrixXd &matData, const QVector< IirBiquad > &sos)

Detailed Description

Butterworth IIR filter design and application using second-order sections.

All filter types (LP, HP, BP, BS) are supported via the classical analogue-prototype → bilinear-transform design route with pre-warped cutoff frequencies. The resulting biquad cascade is numerically stable for high filter orders.

Typical usage:

// Design a 4th-order zero-phase Butterworth bandpass 1–40 Hz at 1000 Hz sampling rate
auto sos = IirFilter::designButterworth(4, IirFilter::BandPass, 1.0, 40.0, 1000.0);
// Apply to one channel
Eigen::RowVectorXd filtered = IirFilter::applyZeroPhase(rawChannel, sos);
// Apply to all channels of a matrix
Eigen::MatrixXd matFiltered = IirFilter::applyZeroPhaseMatrix(rawMatrix, sos);
static Eigen::RowVectorXd applyZeroPhase(const Eigen::RowVectorXd &vecData, const QVector< IirBiquad > &sos)
static QVector< IirBiquad > designButterworth(int iOrder, FilterType type, double dCutoffLow, double dCutoffHigh, double dSFreq)
static Eigen::MatrixXd applyZeroPhaseMatrix(const Eigen::MatrixXd &matData, const QVector< IirBiquad > &sos)

Definition at line 106 of file iirfilter.h.

Member Enumeration Documentation

◆ FilterType

Filter type selector.

Enumerator
LowPass 

Low-pass: attenuate above cutoffLow.

HighPass 

High-pass: attenuate below cutoffLow.

BandPass 

Band-pass: pass cutoffLow–cutoffHigh.

BandStop 

Band-stop (notch): attenuate cutoffLow–cutoffHigh.

Definition at line 113 of file iirfilter.h.

Member Function Documentation

◆ applySos()

RowVectorXd IirFilter::applySos ( const Eigen::RowVectorXd & vecData,
const QVector< IirBiquad > & sos )
static

Apply a biquad cascade to one data row (causal, single-pass).

Parameters
[in]vecDataInput row vector.
[in]sosSecond-order sections from designButterworth().
Returns
Filtered row vector (same length as vecData).

Definition at line 384 of file iirfilter.cpp.

◆ applyZeroPhase()

RowVectorXd IirFilter::applyZeroPhase ( const Eigen::RowVectorXd & vecData,
const QVector< IirBiquad > & sos )
static

Apply a biquad cascade with zero-phase (forward + backward pass) to one row. The effective order is doubled and there is no phase distortion.

Parameters
[in]vecDataInput row vector.
[in]sosSecond-order sections from designButterworth().
Returns
Zero-phase filtered row vector (same length as vecData).

Definition at line 415 of file iirfilter.cpp.

◆ applyZeroPhaseMatrix()

MatrixXd IirFilter::applyZeroPhaseMatrix ( const Eigen::MatrixXd & matData,
const QVector< IirBiquad > & sos )
static

Apply zero-phase filtering to every row of a matrix (each row = one channel).

Parameters
[in]matDataInput matrix (n_channels x n_samples).
[in]sosSecond-order sections from designButterworth().
Returns
Filtered matrix (n_channels x n_samples).

Definition at line 436 of file iirfilter.cpp.

◆ designButterworth()

QVector< IirBiquad > IirFilter::designButterworth ( int iOrder,
FilterType type,
double dCutoffLow,
double dCutoffHigh,
double dSFreq )
static

Design a Butterworth filter as a cascade of second-order sections.

Parameters
[in]iOrderFilter order (≥ 1). For BP/BS the effective order is 2*iOrder.
[in]typeFilter type: LowPass, HighPass, BandPass, or BandStop.
[in]dCutoffLowLower cutoff frequency in Hz. Used for LP, HP, BP, BS.
[in]dCutoffHighUpper cutoff frequency in Hz. Used for BP and BS only.
[in]dSFreqSampling frequency in Hz.
Returns
QVector of IirBiquad sections (multiply their transfer functions to get H(z)).

Definition at line 175 of file iirfilter.cpp.


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