kfrlib / kfr

Fast, modern C++ DSP framework, FFT, Sample Rate Conversion, FIR/IIR/Biquad Filters (SSE, AVX, AVX-512, ARM NEON)
https://www.kfrlib.com
GNU General Public License v2.0
1.65k stars 253 forks source link

Unexpected resulls with even-numbered highpass filter size #60

Closed mujjingun closed 5 years ago

mujjingun commented 5 years ago

The filter coefficients created by the following code plots the following seemingly low-pass filter:

    auto kaiser = to_pointer(kfr::window_kaiser(128, 3.0));

    kfr::univector<dd::fbase, 128> sClutter_coeff;
    kfr::fir_highpass(sClutter_coeff, 0.1, kaiser, true);

    for (auto c : sClutter_coeff) {
        std::cout << c << "\t";
    }

image

Note that I used the kfr::fir_highpass function.

dancazarin commented 5 years ago

Highpass FIR filters require odd number of taps.

FIR filters with even number of taps (Type II filters) always have a zero at z=−1 (Nyquist frequency) and can't be used as high pass filters which require 1 at the Nyquist frequency.