Skip to content

FIR filter and design functions

delay function

template <size_t samples = 1, typename E1>
internal::expression_delay<samples, E1>
delay(E1 &&e1, csize_t<samples> = csize_t<samples>())

Returns template expression that applies delay to the input (uses ring buffer internally)
e1 an input expression
samples delay in samples (must be a compile time value)

univector<double, 10> v = counter();
auto d = delay(v, csize<4>);

Source code
template <size_t samples = 1, typename E1>
KFR_INTRINSIC internal::expression_delay<samples, E1> delay(E1&& e1, csize_t<samples> = csize_t<samples>())
{
    static_assert(samples >= 1 && samples < 1024, "");
    return internal::expression_delay<samples, E1>(std::forward<E1>(e1));
}

https://github.com/kfrlib/kfr/blob//include/kfr/dsp/delay.hpp#L112

fir function

template <typename T, typename E1, univector_tag Tag>
internal::expression_fir<T, value_type_of<E1>, E1>
fir(E1 &&e1, const univector<T, Tag> &taps)

Returns template expression that applies FIR filter to the input
e1 an input expression
taps coefficients for the FIR filter

Source code
template <typename T, typename E1, univector_tag Tag>
KFR_INTRINSIC internal::expression_fir<T, value_type_of<E1>, E1> fir(E1&& e1, const univector<T, Tag>& taps)
{
    return internal::expression_fir<T, value_type_of<E1>, E1>(std::forward<E1>(e1), taps.ref());
}

https://github.com/kfrlib/kfr/blob//include/kfr/dsp/fir.hpp#L164

template <typename T, typename U, typename E1>
internal::expression_fir<T, U, E1, true>
fir(fir_state<T, U> &state, E1 &&e1)

Returns template expression that applies FIR filter to the input
state FIR filter state
e1 an input expression

Source code
template <typename T, typename U, typename E1>
KFR_INTRINSIC internal::expression_fir<T, U, E1, true> fir(fir_state<T, U>& state, E1&& e1)
{
    return internal::expression_fir<T, U, E1, true>(std::forward<E1>(e1), state);
}

https://github.com/kfrlib/kfr/blob//include/kfr/dsp/fir.hpp#L175

fir_bandpass function

template <typename T, univector_tag Tag>
void fir_bandpass(univector<T, Tag> &taps,
                  identity<T> frequency1,
                  identity<T> frequency2,
                  const expression_pointer<T> &window,
                  bool normalize = true)

Calculates coefficients for the band-pass FIR filter
taps array where computed coefficients are stored
frequency1 Normalized frequency (frequency_Hz / samplerate_Hz)
frequency2 Normalized frequency (frequency_Hz / samplerate_Hz)
window pointer to a window function
normalize true for normalized coefficients

Source code
template <typename T, univector_tag Tag>
KFR_INTRINSIC void fir_bandpass(univector<T, Tag>& taps, identity<T> frequency1, identity<T> frequency2,
                                const expression_pointer<T>& window, bool normalize = true)
{
    return internal::fir_bandpass(taps.slice(), frequency1, frequency2, window, normalize);
}

https://github.com/kfrlib/kfr/blob//include/kfr/dsp/fir_design.hpp#L163

template <typename T>
void fir_bandpass(const univector_ref<T> &taps,
                  identity<T> frequency1,
                  identity<T> frequency2,
                  const expression_pointer<T> &window,
                  bool normalize = true)

@copydoc kfr::fir_bandpass

Source code
template <typename T>
KFR_INTRINSIC void fir_bandpass(const univector_ref<T>& taps, identity<T> frequency1, identity<T> frequency2,
                                const expression_pointer<T>& window, bool normalize = true)
{
    return internal::fir_bandpass(taps, frequency1, frequency2, window, normalize);
}

https://github.com/kfrlib/kfr/blob//include/kfr/dsp/fir_design.hpp#L208

fir_bandstop function

template <typename T, univector_tag Tag>
void fir_bandstop(univector<T, Tag> &taps,
                  identity<T> frequency1,
                  identity<T> frequency2,
                  const expression_pointer<T> &window,
                  bool normalize = true)

Calculates coefficients for the band-stop FIR filter
taps array where computed coefficients are stored
frequency1 Normalized frequency (frequency_Hz / samplerate_Hz)
frequency2 Normalized frequency (frequency_Hz / samplerate_Hz)
window pointer to a window function
normalize true for normalized coefficients

Source code
template <typename T, univector_tag Tag>
KFR_INTRINSIC void fir_bandstop(univector<T, Tag>& taps, identity<T> frequency1, identity<T> frequency2,
                                const expression_pointer<T>& window, bool normalize = true)
{
    return internal::fir_bandstop(taps.slice(), frequency1, frequency2, window, normalize);
}

https://github.com/kfrlib/kfr/blob//include/kfr/dsp/fir_design.hpp#L178

template <typename T>
void fir_bandstop(const univector_ref<T> &taps,
                  identity<T> frequency1,
                  identity<T> frequency2,
                  const expression_pointer<T> &window,
                  bool normalize = true)

@copydoc kfr::fir_bandstop

Source code
template <typename T>
KFR_INTRINSIC void fir_bandstop(const univector_ref<T>& taps, identity<T> frequency1, identity<T> frequency2,
                                const expression_pointer<T>& window, bool normalize = true)
{
    return internal::fir_bandstop(taps, frequency1, frequency2, window, normalize);
}

https://github.com/kfrlib/kfr/blob//include/kfr/dsp/fir_design.hpp#L218

fir_highpass function

template <typename T, univector_tag Tag>
void fir_highpass(univector<T, Tag> &taps,
                  identity<T> cutoff,
                  const expression_pointer<T> &window,
                  bool normalize = true)

Calculates coefficients for the high-pass FIR filter
taps array where computed coefficients are stored
cutoff Normalized frequency (frequency_Hz / samplerate_Hz)
window pointer to a window function
normalize true for normalized coefficients

Source code
template <typename T, univector_tag Tag>
KFR_INTRINSIC void fir_highpass(univector<T, Tag>& taps, identity<T> cutoff,
                                const expression_pointer<T>& window, bool normalize = true)
{
    return internal::fir_highpass(taps.slice(), cutoff, window, normalize);
}

https://github.com/kfrlib/kfr/blob//include/kfr/dsp/fir_design.hpp#L148

template <typename T>
void fir_highpass(const univector_ref<T> &taps,
                  identity<T> cutoff,
                  const expression_pointer<T> &window,
                  bool normalize = true)

@copydoc kfr::fir_highpass

Source code
template <typename T>
KFR_INTRINSIC void fir_highpass(const univector_ref<T>& taps, identity<T> cutoff,
                                const expression_pointer<T>& window, bool normalize = true)
{
    return internal::fir_highpass(taps, cutoff, window, normalize);
}

https://github.com/kfrlib/kfr/blob//include/kfr/dsp/fir_design.hpp#L198

fir_lowpass function

template <typename T, univector_tag Tag>
void fir_lowpass(univector<T, Tag> &taps,
                 identity<T> cutoff,
                 const expression_pointer<T> &window,
                 bool normalize = true)

Calculates coefficients for the low-pass FIR filter
taps array where computed coefficients are stored
cutoff Normalized frequency (frequency_Hz / samplerate_Hz)
window pointer to a window function
normalize true for normalized coefficients

Source code
template <typename T, univector_tag Tag>
KFR_INTRINSIC void fir_lowpass(univector<T, Tag>& taps, identity<T> cutoff,
                               const expression_pointer<T>& window, bool normalize = true)
{
    return internal::fir_lowpass(taps.slice(), cutoff, window, normalize);
}

https://github.com/kfrlib/kfr/blob//include/kfr/dsp/fir_design.hpp#L134

template <typename T>
void fir_lowpass(const univector_ref<T> &taps,
                 identity<T> cutoff,
                 const expression_pointer<T> &window,
                 bool normalize = true)

@copydoc kfr::fir_lowpass

Source code
template <typename T>
KFR_INTRINSIC void fir_lowpass(const univector_ref<T>& taps, identity<T> cutoff,
                               const expression_pointer<T>& window, bool normalize = true)
{
    return internal::fir_lowpass(taps, cutoff, window, normalize);
}

https://github.com/kfrlib/kfr/blob//include/kfr/dsp/fir_design.hpp#L188

reset function

void reset() final

Reset internal filter state

Source code
void reset() final
{
    state.delayline        = scalar(0);
    state.delayline_cursor = 0;
}

https://github.com/kfrlib/kfr/blob//include/kfr/dsp/fir.hpp#L204

short_fir function

template <typename T, size_t TapCount, typename E1>
internal::expression_short_fir<
    next_poweroftwo(TapCount - 1) + 1, T, value_type_of<E1>,
    E1>
short_fir(E1 &&e1, const univector<T, TapCount> &taps)

Returns template expression that applies FIR filter to the input (count of coefficients must be in range 2..32)
e1 an input expression
taps coefficients for the FIR filter

Source code
template <typename T, size_t TapCount, typename E1>
KFR_INTRINSIC internal::expression_short_fir<next_poweroftwo(TapCount - 1) + 1, T, value_type_of<E1>, E1>
short_fir(E1&& e1, const univector<T, TapCount>& taps)
{
    static_assert(TapCount >= 2 && TapCount <= 33, "Use short_fir only for small FIR filters");
    return internal::expression_short_fir<next_poweroftwo(TapCount - 1) + 1, T, value_type_of<E1>, E1>(
        std::forward<E1>(e1), taps);
}

https://github.com/kfrlib/kfr/blob//include/kfr/dsp/fir.hpp#L188


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