Skip to content

IIR filter and design functions

iir function

template <typename T, typename E1>
expression_handle<T, 1> iir(E1 &&e1, const zpk<T> &params)

Returns template expressions that applies biquad filter to the input.
e1 Input expression
params IIR filter in ZPK form @remark This overload converts ZPK to biquad coefficients using to_sos function at every call

Source code
template <typename T, typename E1>
KFR_FUNCTION expression_handle<T, 1> iir(E1&& e1, const zpk<T>& params)
{
    return iir(std::forward<E1>(e1), to_sos(params));
}

https://github.com/kfrlib/kfr/blob//include/kfr/dsp/iir_design.hpp#L1255

iir_bandpass function

template <typename T>
zpk<T>
iir_bandpass(const zpk<T> &filter, identity<T> lowfreq,
             identity<T> highfreq, identity<T> fs = T(2.0))

Calculates zero-pole-gain coefficients for the band-pass IIR filter
filter Filter type: chebyshev1, chebyshev2, bessel, butterworth
lowfreq Low cutoff frequency (Hz)
lowfreq High cutoff frequency (Hz)
fs Sampling frequency (Hz) @return The resulting zpk filter

Source code
template <typename T>
KFR_FUNCTION zpk<T> iir_bandpass(const zpk<T>& filter, identity<T> lowfreq, identity<T> highfreq,
                                 identity<T> fs = T(2.0))
{
    T warpedlow  = internal::warp_freq(lowfreq, fs);
    T warpedhigh = internal::warp_freq(highfreq, fs);

    zpk<T> result = filter;
    result        = internal::lp2bp_zpk(result, std::sqrt(warpedlow * warpedhigh), warpedhigh - warpedlow);
    result        = internal::bilinear(result, T(2.0)); // fs = 2.0
    return result;
}

https://github.com/kfrlib/kfr/blob//include/kfr/dsp/iir_design.hpp#L1079

iir_bandstop function

template <typename T>
zpk<T>
iir_bandstop(const zpk<T> &filter, identity<T> lowfreq,
             identity<T> highfreq, identity<T> fs = T(2.0))

Calculates zero-pole-gain coefficients for the band-stop IIR filter
filter Filter type: chebyshev1, chebyshev2, bessel, butterworth
lowfreq Low cutoff frequency (Hz)
lowfreq High cutoff frequency (Hz)
fs Sampling frequency (Hz) @return The resulting zpk filter

Source code
template <typename T>
KFR_FUNCTION zpk<T> iir_bandstop(const zpk<T>& filter, identity<T> lowfreq, identity<T> highfreq,
                                 identity<T> fs = T(2.0))
{
    T warpedlow  = internal::warp_freq(lowfreq, fs);
    T warpedhigh = internal::warp_freq(highfreq, fs);

    zpk<T> result = filter;
    result        = internal::lp2bs_zpk(result, std::sqrt(warpedlow * warpedhigh), warpedhigh - warpedlow);
    result        = internal::bilinear(result, T(2.0)); // fs = 2.0
    return result;
}

https://github.com/kfrlib/kfr/blob//include/kfr/dsp/iir_design.hpp#L1100

iir_highpass function

template <typename T>
zpk<T> iir_highpass(const zpk<T> &filter,
                    identity<T> frequency,
                    identity<T> fs = T(2.0))

Calculates zero-pole-gain coefficients for the high-pass IIR filter
filter Filter type: chebyshev1, chebyshev2, bessel, butterworth
frequency Cutoff frequency (Hz)
fs Sampling frequency (Hz) @return The resulting zpk filter

Source code
template <typename T>
KFR_FUNCTION zpk<T> iir_highpass(const zpk<T>& filter, identity<T> frequency, identity<T> fs = T(2.0))
{
    T warped = internal::warp_freq(frequency, fs);

    zpk<T> result = filter;
    result        = internal::lp2hp_zpk(result, warped);
    result        = internal::bilinear(result, T(2.0)); // fs = 2.0
    return result;
}

https://github.com/kfrlib/kfr/blob//include/kfr/dsp/iir_design.hpp#L1060

iir_lowpass function

template <typename T>
zpk<T> iir_lowpass(const zpk<T> &filter,
                   identity<T> frequency,
                   identity<T> fs = T(2.0))

Calculates zero-pole-gain coefficients for the low-pass IIR filter
filter Filter type: chebyshev1, chebyshev2, bessel, butterworth
frequency Cutoff frequency (Hz)
fs Sampling frequency (Hz) @return The resulting zpk filter

Source code
template <typename T>
KFR_FUNCTION zpk<T> iir_lowpass(const zpk<T>& filter, identity<T> frequency, identity<T> fs = T(2.0))
{
    T warped = internal::warp_freq(frequency, fs);

    zpk<T> result = filter;
    result        = internal::lp2lp_zpk(result, warped);
    result        = internal::bilinear(result, T(2.0)); // fs = 2.0
    return result;
}

https://github.com/kfrlib/kfr/blob//include/kfr/dsp/iir_design.hpp#L1041


Auto-generated from sources, Revision , https://github.com/kfrlib/kfr/blob//include/kfr/