How to Apply an FIR Filter¶
Filter Initialization (Window Method)¶
1 2 3 4 5 6 7 8 9 10 11 12 | |
KFR supports following filter types:
* Low-pass: fir_lowpass(taps, cutoff, window, normalize)
* High-pass: fir_highpass(taps, cutoff, window, normalize)
* Band-pass: fir_bandpass(taps, cutoff1, cutoff2, window, normalize)
* Band-stop: fir_bandstop(taps, cutoff1, cutoff2, window, normalize)
You can pass your own coefficients to the filter_fir constructor or use another method to calculate coefficients for the filter.
Use the apply function to apply the filter to audio.
All the internal state (delay line, etc.) is preserved between calls to apply. Use reset to reset the filter's internal state.
[!note] Note that for a high-pass FIR filter, the number of taps must be odd. FIR filters with an even number of taps (Type II filters) always have a zero at z=−1 (Nyquist frequency) and cannot be used as high-pass filters, which require 1 at the Nyquist frequency.
How to Apply an FIR Filter to a Plain Array (In-Place)¶
1 2 | |
... to a Plain Array¶
1 2 3 4 | |
... Using a Pointer and Size (In-Place)¶
1 2 3 | |
... Using Two Pointers and Size¶
1 2 3 4 5 | |
... to univector (In-Place)¶
1 2 | |
... to univector¶
1 2 3 | |
... to Expression¶
1 2 3 | |
convolve_filter is numerically equivalent to an FIR filter but uses DFT internally for better performance.
See also Filter Class Definition
See also a gallery with results of applying various FIR filters