Skip to content

FIR filter and design functions

delay function

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

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, typename T = value_type_of<E1>>
KFR_INTRINSIC internal::expression_delay<samples, E1, false, samples> delay(E1&& e1)
{
    static_assert(samples >= 1 && samples < 1024, "");
    return internal::expression_delay<samples, E1, false, samples>(std::forward<E1>(e1),
                                                                   delay_state<T, samples>());
}

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

template <size_t samples, typename T, typename E1,
          univector_tag STag>
internal::expression_delay<samples, E1, true, STag>
delay(delay_state<T, samples, STag> &state, E1 &&e1)

Returns template expression that applies delay to the input (uses ring buffer in state)
state delay filter state
e1 an input expression

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

Source code
template <size_t samples, typename T, typename E1, univector_tag STag>
KFR_INTRINSIC internal::expression_delay<samples, E1, true, STag> delay(delay_state<T, samples, STag>& state,
                                                                        E1&& e1)
{
    static_assert(STag == tag_dynamic_vector || (samples >= 1 && samples < 1024), "");
    return internal::expression_delay<samples, E1, true, STag>(std::forward<E1>(e1), state);
}

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

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#L205

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#L216

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

moving_sum function

template <size_t sum_length, typename E1>
internal::expression_moving_sum<value_type_of<E1>, E1,
                                tag_dynamic_vector>
moving_sum(E1 &&e1)

Returns template expression that performs moving sum on the input
state moving sum state
e1 an input expression

Source code
template <size_t sum_length, typename E1>
KFR_INTRINSIC internal::expression_moving_sum<value_type_of<E1>, E1, tag_dynamic_vector> moving_sum(E1&& e1)
{
    return internal::expression_moving_sum<value_type_of<E1>, E1, tag_dynamic_vector>(std::forward<E1>(e1),
                                                                                      sum_length);
}

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

template <typename U, typename E1, univector_tag STag>
internal::expression_moving_sum<U, E1, STag, true>
moving_sum(moving_sum_state<U, STag> &state, E1 &&e1)

Returns template expression that performs moving sum on the input
state moving sum state
e1 an input expression

Source code
template <typename U, typename E1, univector_tag STag>
KFR_INTRINSIC internal::expression_moving_sum<U, E1, STag, true> moving_sum(moving_sum_state<U, STag>& state,
                                                                            E1&& e1)
{
    return internal::expression_moving_sum<U, E1, STag, true>(std::forward<E1>(e1), state);
}

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

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#L285

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#L253

template <size_t TapCount, typename T, typename U,
          typename E1>
internal::expression_short_fir<
    next_poweroftwo(TapCount - 1) + 1, T, value_type_of<E1>,
    E1, true>
short_fir(short_fir_state<next_poweroftwo(TapCount - 1) + 1,
                          T, U> &state,
          E1 &&e1)

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

Source code
template <size_t TapCount, typename T, typename U, typename E1>
KFR_INTRINSIC internal::expression_short_fir<next_poweroftwo(TapCount - 1) + 1, T, value_type_of<E1>, E1,
                                             true>
    short_fir(short_fir_state<next_poweroftwo(TapCount - 1) + 1, T, U>& state, E1&& e1)
{
    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, true>(
        std::forward<E1>(e1), state);
}

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


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