|
DSPark 1.6.1
Header-only audio DSP framework in pure C++20 — zero dependencies
|
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)) noexcept |
| Designs a low-pass FIR filter. | |
| static std::vector< T > | highPass (double sampleRate, double cutoffHz, int numTaps, T beta=T(5)) noexcept |
| Designs a high-pass FIR filter. | |
| static std::vector< T > | bandPass (double sampleRate, double lowCutoffHz, double highCutoffHz, int numTaps, T beta=T(5)) noexcept |
| Designs a band-pass FIR filter. | |
| static std::vector< T > | bandStop (double sampleRate, double lowCutoffHz, double highCutoffHz, int numTaps, T beta=T(5)) noexcept |
| 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.
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 74 of file FIRFilter.h.
|
inlinestaticnoexcept |
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 125 of file FIRFilter.h.
|
inlinestaticnoexcept |
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 152 of file FIRFilter.h.
|
inlinestaticnoexcept |
Estimates the Kaiser beta parameter for a desired attenuation.
| attenuationDb | Desired stopband attenuation in dB (positive). |
Definition at line 204 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 185 of file FIRFilter.h.
|
inlinestaticnoexcept |
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 105 of file FIRFilter.h.
|
inlinestaticnoexcept |
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 86 of file FIRFilter.h.