Parks-McClellan equiripple FIR filter design algorithm (Remez exchange). More...
#include <parksmcclellan.h>
Public Types | |
| enum | TPassType { LPF , HPF , BPF , NOTCH } |
Public Member Functions | |
| ParksMcClellan () | |
| ParksMcClellan (int NumTaps, double OmegaC, double BW, double ParksWidth, TPassType PassType) | |
| ~ParksMcClellan () | |
| void | init (int NumTaps, double OmegaC, double BW, double ParksWidth, TPassType PassType) |
| void | CalcParkCoeff2 (int NBANDS, int NFILT) |
| double | LeGrangeInterp2 (int K, int N, int M) |
| double | GEE2 (int K, int N) |
| int | Remez2 (int GridIndex) |
| bool | ErrTest (int k, int Nut, double Comp, double *Err) |
| void | CalcCoefficients () |
Public Attributes | |
| Eigen::RowVectorXd | FirCoeff |
Parks-McClellan equiripple FIR filter design algorithm (Remez exchange).
DECLARE CLASS ParksMcClellan
Definition at line 67 of file parksmcclellan.h.

| Enumerator | |
|---|---|
| LPF | |
| HPF | |
| BPF | |
| NOTCH | |
Definition at line 73 of file parksmcclellan.h.
| ParksMcClellan::ParksMcClellan | ( | ) |
Definition at line 46 of file parksmcclellan.cpp.
| ParksMcClellan::ParksMcClellan | ( | int | NumTaps, |
| double | OmegaC, | ||
| double | BW, | ||
| double | ParksWidth, | ||
| TPassType | PassType ) |
NumTaps must be odd for high pass and notch filters. Max number of taps is 128. The arrays can handle up to 256 taps, but 128 is a good practical limit for convergence. The minimum number of taps is 9 (maybe < 9, I forget the exact lower limit or what sets it) OmegaC is the 3 dB corner freq for low pass and high pass filters. It is the center freq for band pass and notch filters. BW is the bandwidth for bandpass and notch filters (ignored on low and high pass). OmegaC and BW are in terms of Pi. e.g. OmegaC = 0.5 centers a BPF at Omega = Pi/2. The PM algorithm however uses frequencies in terms of 2Pi, so we need to to this: Edge[j] /= 2.0 ParksWidth is the width of the transition bands. For simplicity, we only use one width, but the algorithm allows for unique values on every band edge. Practical limits for ParksWidth are 0.02 - 0.15 for BPF and Notch, 0.02 - 0.30 for LPF and HPF. TPassType is defined in the header file. LPF = Low Pass Filter, etc. You should note our 0.01 minimum width for each band. This limit works well for the algorithm. You will also find that OmegaC and BW need to be scaled a bit, depending ParksWidth, to get the 3 dB corner frequencies to come in on target.
e.g. NewParksMcClellan(33, 0.7, 0.2, 0.1, HPF); gives a 33 tap high pass filter with 3 dB corner at 0.7 with a transition bandwidth of 0.1 The FIR coefficients are placed in FirCoeff, starting at index 0.
| [in] | NumTaps | Number of filter taps (9 to 128; odd for HPF and NOTCH). |
| [in] | OmegaC | Corner (LPF/HPF) or center (BPF/NOTCH) frequency, normalized to Pi. |
| [in] | BW | Bandwidth for BPF and NOTCH, normalized to Pi; ignored for LPF/HPF. |
| [in] | ParksWidth | Width of the transition bands, normalized to Pi. |
| [in] | PassType | Filter type (LPF, HPF, BPF or NOTCH). |
Definition at line 66 of file parksmcclellan.cpp.
| ParksMcClellan::~ParksMcClellan | ( | ) |
Definition at line 88 of file parksmcclellan.cpp.
| void ParksMcClellan::CalcCoefficients | ( | ) |
This was added by IowaHills and is called from CalcParkCoeff2(). Calculation of the coefficients of the best approximation using the inverse discrete fourier transform.
Definition at line 585 of file parksmcclellan.cpp.
| void ParksMcClellan::CalcParkCoeff2 | ( | int | NBANDS, |
| int | NFILT ) |
Definition at line 206 of file parksmcclellan.cpp.
| bool ParksMcClellan::ErrTest | ( | int | k, |
| int | Nut, | ||
| double | Comp, | ||
| double * | Err ) |
This was added by IowaHills and is used in Remez() in 6 places.
| [in] | k | Index into the dense frequency grid. |
| [in] | Nut | Sign (+1 or -1) of the expected error extremum. |
| [in] | Comp | Current comparison error magnitude. |
| [out] | Err | Weighted approximation error at grid point k. |
Definition at line 573 of file parksmcclellan.cpp.
| double ParksMcClellan::GEE2 | ( | int | K, |
| int | N ) |
Function to evaluate the frequency response using the Lagrange interpolation formula in the barycentric form.
| [in] | K | Index into the dense frequency grid at which to evaluate. |
| [in] | N | Number of extremal points used in the interpolation. |
Definition at line 542 of file parksmcclellan.cpp.
| void ParksMcClellan::init | ( | int | NumTaps, |
| double | OmegaC, | ||
| double | BW, | ||
| double | ParksWidth, | ||
| TPassType | PassType ) |
Using nothrow prevents an exception from being thrown. new will instead return NULL. These array are much larger than actually needed. See the notes in the orig fortran file.
| [in] | NumTaps | Number of filter taps (9 to 128; odd for HPF and NOTCH). |
| [in] | OmegaC | Corner (LPF/HPF) or center (BPF/NOTCH) frequency, normalized to Pi. |
| [in] | BW | Bandwidth for BPF and NOTCH, normalized to Pi; ignored for LPF/HPF. |
| [in] | ParksWidth | Width of the transition bands, normalized to Pi. |
| [in] | PassType | Filter type (LPF, HPF, BPF or NOTCH). |
Definition at line 94 of file parksmcclellan.cpp.
| double ParksMcClellan::LeGrangeInterp2 | ( | int | K, |
| int | N, | ||
| int | M ) |
Function to calculate the lagrange interpolation coefficients for use in the function gee.
| [in] | K | Index of the extremal point whose coefficient is computed. |
| [in] | N | Number of extremal points. |
| [in] | M | Stride used to interleave the product for numerical stability. |
Definition at line 520 of file parksmcclellan.cpp.
| int ParksMcClellan::Remez2 | ( | int | GridIndex | ) |
Definition at line 308 of file parksmcclellan.cpp.
| Eigen::RowVectorXd UTILSLIB::ParksMcClellan::FirCoeff |
containt the generated filter coefficients.
Definition at line 190 of file parksmcclellan.h.