|
DSPark 1.8.0
Header-only C++20 DSP for real-time and offline audio
|
Static methods for designing FIR filter coefficients. More...
#include <FIRFilter.h>
Static Public Member Functions | |
| static std::vector< T > | lowPass (double sampleRate, double cutoffHz, int numTaps, T beta=T(5)) |
| Designs a low-pass FIR filter. | |
| static std::vector< T > | highPass (double sampleRate, double cutoffHz, int numTaps, T beta=T(5)) |
| Designs a high-pass FIR filter. | |
| static std::vector< T > | bandPass (double sampleRate, double lowCutoffHz, double highCutoffHz, int numTaps, T beta=T(5)) |
| Designs a band-pass FIR filter. | |
| static std::vector< T > | bandStop (double sampleRate, double lowCutoffHz, double highCutoffHz, int numTaps, T beta=T(5)) |
| Designs a band-stop (notch) FIR filter. | |
| static int | estimateTaps (double sampleRate, double transitionHz, double attenuationDb) noexcept |
| Estimates the required number of taps for a given specification. | |
| static T | estimateKaiserBeta (double attenuationDb) noexcept |
| Estimates the Kaiser beta parameter for a desired attenuation. | |
Static methods for designing FIR filter coefficients.
Uses the windowed-sinc method: an ideal (sinc) impulse response is multiplied by a window function to produce a realisable FIR filter. Coefficient factories allocate during setup. With exceptions enabled, allocation failures propagate to the caller without publishing partial results.
All methods return a vector of filter coefficients (taps). The number of taps determines the filter's steepness and stopband attenuation. More taps = steeper transition but more latency and computation.
Rule of thumb for number of taps:
N ~ 4 / (transitionWidth / sampleRate) for a Kaiser window| T | Coefficient type (float or double). |
Definition at line 77 of file FIRFilter.h.
|
inlinestatic |
Designs a band-pass FIR filter.
Created by subtracting a low-pass at lowCutoff from a low-pass at highCutoff.
| sampleRate | Sample rate in Hz. |
| lowCutoffHz | Lower cutoff frequency in Hz. |
| highCutoffHz | Upper cutoff frequency in Hz. |
| numTaps | Number of filter taps (must be odd, >= 3). |
| beta | Kaiser window beta. |
Definition at line 128 of file FIRFilter.h.
|
inlinestatic |
Designs a band-stop (notch) FIR filter.
| sampleRate | Sample rate in Hz. |
| lowCutoffHz | Lower cutoff frequency in Hz. |
| highCutoffHz | Upper cutoff frequency in Hz. |
| numTaps | Number of filter taps (must be odd, >= 3). |
| beta | Kaiser window beta. |
Definition at line 155 of file FIRFilter.h.
|
inlinestaticnoexcept |
Estimates the Kaiser beta parameter for a desired attenuation.
| attenuationDb | Desired stopband attenuation in dB (positive). |
Definition at line 207 of file FIRFilter.h.
|
inlinestaticnoexcept |
Estimates the required number of taps for a given specification.
Uses the Kaiser formula to estimate the minimum number of odd taps needed to achieve the desired stopband attenuation with a given transition bandwidth.
| sampleRate | Sample rate in Hz. |
| transitionHz | Width of the transition band in Hz. Must be > 0. |
| attenuationDb | Desired stopband attenuation in dB (positive value, e.g., 60). |
Definition at line 188 of file FIRFilter.h.
|
inlinestatic |
Designs a high-pass FIR filter.
Created by spectrally inverting a low-pass filter.
| sampleRate | Sample rate in Hz. |
| cutoffHz | Cutoff frequency in Hz. |
| numTaps | Number of filter taps (must be odd, >= 3). |
| beta | Kaiser window beta. |
Definition at line 108 of file FIRFilter.h.
|
inlinestatic |
Designs a low-pass FIR filter.
| sampleRate | Sample rate in Hz. |
| cutoffHz | Cutoff frequency in Hz (-6 dB point). |
| numTaps | Number of filter taps (must be odd, >= 3). |
| beta | Kaiser window beta (default: 5.0). Higher = more attenuation. |
Definition at line 89 of file FIRFilter.h.