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

Discoverable façade over the FilterKernel FIR-filter engine. More...

#include <firfilter.h>

Public Types

enum  FilterType { LowPass = 0 , HighPass = 1 , BandPass = 2 , BandStop = 3 }
 FIR filter type — mirrors IirFilter::FilterType for a uniform API. More...
enum  DesignMethod { Cosine = 0 , ParksMcClellan = 1 }
 FIR design method — wraps FilterKernel's iDesignMethod integer codes. More...

Static Public Member Functions

static FilterKernel design (int iOrder, FilterType type, double dCutoffLow, double dCutoffHigh, double dSFreq, double dTransition=5.0, DesignMethod method=Cosine)
static Eigen::RowVectorXd apply (const Eigen::RowVectorXd &vecData, FilterKernel &kernel)
static Eigen::RowVectorXd applyZeroPhase (const Eigen::RowVectorXd &vecData, FilterKernel &kernel)
static Eigen::MatrixXd applyZeroPhaseMatrix (const Eigen::MatrixXd &matData, FilterKernel &kernel, const Eigen::RowVectorXi &vecPicks=Eigen::RowVectorXi())

Detailed Description

Discoverable façade over the FilterKernel FIR-filter engine.

Quick-start example — mirrors the IirFilter API:

// Design a 256-tap band-pass filter
FilterKernel bpf = FirFilter::design(256, FirFilter::BandPass, 1.0, 40.0, sFreq);
// Apply to a single row vector (group delay already removed — symmetric FIR)
Eigen::RowVectorXd out = FirFilter::apply(vecData, bpf);
// Apply to all rows of a matrix
Eigen::MatrixXd clean = FirFilter::applyZeroPhaseMatrix(matData, bpf);
The FilterKernel class provides methods to create/design a FIR filter kernel.
static Eigen::MatrixXd applyZeroPhaseMatrix(const Eigen::MatrixXd &matData, FilterKernel &kernel, const Eigen::RowVectorXi &vecPicks=Eigen::RowVectorXi())
static FilterKernel design(int iOrder, FilterType type, double dCutoffLow, double dCutoffHigh, double dSFreq, double dTransition=5.0, DesignMethod method=Cosine)
Definition firfilter.cpp:63
static Eigen::RowVectorXd apply(const Eigen::RowVectorXd &vecData, FilterKernel &kernel)

Definition at line 79 of file firfilter.h.

Member Enumeration Documentation

◆ DesignMethod

FIR design method — wraps FilterKernel's iDesignMethod integer codes.

Enumerator
Cosine 

Cosine window (fast, moderate roll-off).

ParksMcClellan 

Equiripple Parks-McClellan (optimal minimax).

Definition at line 97 of file firfilter.h.

◆ FilterType

FIR filter type — mirrors IirFilter::FilterType for a uniform API.

Enumerator
LowPass 

Low-pass filter.

HighPass 

High-pass filter.

BandPass 

Band-pass filter.

BandStop 

Band-stop (notch) filter.

Definition at line 86 of file firfilter.h.

Member Function Documentation

◆ apply()

RowVectorXd FirFilter::apply ( const Eigen::RowVectorXd & vecData,
FilterKernel & kernel )
static

Apply the filter to a single row vector.

Uses overlap-add FFT convolution. The group delay of a symmetric FIR is removed by the FilterKernel engine (it takes the output segment starting at order/2), so the result is already approximately zero-phase for symmetric designs.

Parameters
[in]vecDataInput row vector.
[in,out]kernelFilterKernel (prepareFilter is called if needed).
Returns
Filtered row vector (same length as input).

Definition at line 121 of file firfilter.cpp.

◆ applyZeroPhase()

RowVectorXd FirFilter::applyZeroPhase ( const Eigen::RowVectorXd & vecData,
FilterKernel & kernel )
static

Apply the filter in a zero-phase forward-backward pass to a single row vector.

Runs the filter twice (forward then reverse) to achieve exactly zero phase shift. Effective order is doubled; transition bandwidth is halved.

Parameters
[in]vecDataInput row vector.
[in,out]kernelFilterKernel.
Returns
Zero-phase filtered row vector.

Definition at line 131 of file firfilter.cpp.

◆ applyZeroPhaseMatrix()

MatrixXd FirFilter::applyZeroPhaseMatrix ( const Eigen::MatrixXd & matData,
FilterKernel & kernel,
const Eigen::RowVectorXi & vecPicks = Eigen::RowVectorXi() )
static

Apply the filter in a zero-phase forward-backward pass to every row of a matrix.

Parameters
[in]matDataInput matrix (n_channels × n_samples).
[in,out]kernelFilterKernel.
[in]vecPicksOptional row indices to filter; if empty, all rows are filtered.
Returns
Zero-phase filtered matrix (same dimensions as input).

Definition at line 147 of file firfilter.cpp.

◆ design()

FilterKernel FirFilter::design ( int iOrder,
FilterType type,
double dCutoffLow,
double dCutoffHigh,
double dSFreq,
double dTransition = 5.0,
DesignMethod method = Cosine )
static

Design a linear-phase FIR filter using FilterKernel as the backend.

Frequencies are given in Hz; the method converts them to the Nyquist-normalised form expected by FilterKernel internally.

Parameters
[in]iOrderFilter order (number of taps − 1). Must be even for linear phase.
[in]typeFilter type (LowPass, HighPass, BandPass, BandStop).
[in]dCutoffLowLower cutoff frequency in Hz. For LowPass/HighPass: the single cutoff. For BandPass/BandStop: lower edge of the transition band.
[in]dCutoffHighUpper cutoff frequency in Hz (ignored for LowPass/HighPass).
[in]dSFreqSampling frequency in Hz.
[in]dTransitionWidth of the transition band in Hz (Parks-McClellan steepness / Cosine roll-off width). Defaults to 5 Hz.
[in]methodDesign method (Cosine or ParksMcClellan).
Returns
A ready-to-use FilterKernel object.

Definition at line 63 of file firfilter.cpp.


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