FIR filter and design functions¶
delay
function¶
template <size_t samples = 1, typename E1,
typename T = expression_value_type<E1>>
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 = expression_value_type<E1>>
KFR_INTRINSIC expression_delay<samples, E1, false, samples> delay(E1&& e1)
{
static_assert(samples >= 1 && samples < 1024, "");
return 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#L161
template <size_t samples, typename T, typename E1,
univector_tag STag>
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 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 expression_delay<samples, E1, true, STag>(std::forward<E1>(e1), state);
}
https://github.com/kfrlib/kfr/blob//include/kfr/dsp/delay.hpp#L178
fir
function¶
template <typename T, typename E1, univector_tag Tag>
expression_fir<T, expression_value_type<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 expression_fir<T, expression_value_type<E1>, E1> fir(E1&& e1, const univector<T, Tag>& taps)
{
return expression_fir<T, expression_value_type<E1>, E1>(std::forward<E1>(e1), taps.ref());
}
https://github.com/kfrlib/kfr/blob//include/kfr/dsp/fir.hpp#L216
template <typename T, typename U, typename E1>
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 expression_fir<T, U, E1, true> fir(fir_state<T, U>& state, E1&& e1)
{
return expression_fir<T, U, E1, true>(std::forward<E1>(e1), state);
}
https://github.com/kfrlib/kfr/blob//include/kfr/dsp/fir.hpp#L227
fir_bandpass
function¶
template <typename T, univector_tag Tag>
void fir_bandpass(univector<T, Tag> &taps,
identity<T> frequency1,
identity<T> frequency2,
const expression_handle<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_handle<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#L161
template <typename T>
void fir_bandpass(const univector_ref<T> &taps,
identity<T> frequency1,
identity<T> frequency2,
const expression_handle<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_handle<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#L206
fir_bandstop
function¶
template <typename T, univector_tag Tag>
void fir_bandstop(univector<T, Tag> &taps,
identity<T> frequency1,
identity<T> frequency2,
const expression_handle<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_handle<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#L176
template <typename T>
void fir_bandstop(const univector_ref<T> &taps,
identity<T> frequency1,
identity<T> frequency2,
const expression_handle<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_handle<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#L216
fir_highpass
function¶
template <typename T, univector_tag Tag>
void fir_highpass(univector<T, Tag> &taps,
identity<T> cutoff,
const expression_handle<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_handle<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#L146
template <typename T>
void fir_highpass(const univector_ref<T> &taps,
identity<T> cutoff,
const expression_handle<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_handle<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#L196
fir_lowpass
function¶
template <typename T, univector_tag Tag>
void fir_lowpass(univector<T, Tag> &taps,
identity<T> cutoff,
const expression_handle<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_handle<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#L132
template <typename T>
void fir_lowpass(const univector_ref<T> &taps,
identity<T> cutoff,
const expression_handle<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_handle<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#L186
moving_sum
function¶
template <size_t sum_length, typename E1>
expression_moving_sum<expression_value_type<E1>, E1,
tag_dynamic_vector>
moving_sum(E1 &&e1)
Returns template expression that performs moving sum on the input
e1 an input expression
Source code
template <size_t sum_length, typename E1>
KFR_INTRINSIC expression_moving_sum<expression_value_type<E1>, E1, tag_dynamic_vector> moving_sum(E1&& e1)
{
return expression_moving_sum<expression_value_type<E1>, E1, tag_dynamic_vector>(std::forward<E1>(e1),
sum_length);
}
https://github.com/kfrlib/kfr/blob//include/kfr/dsp/fir.hpp#L237
template <typename U, typename E1, univector_tag STag>
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 expression_moving_sum<U, E1, STag, true> moving_sum(moving_sum_state<U, STag>& state, E1&& e1)
{
return expression_moving_sum<U, E1, STag, true>(std::forward<E1>(e1), state);
}
https://github.com/kfrlib/kfr/blob//include/kfr/dsp/fir.hpp#L249
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#L293
short_fir
function¶
template <typename T, size_t TapCount, typename E1>
expression_short_fir<next_poweroftwo(TapCount - 1) + 1, T,
expression_value_type<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 expression_short_fir<next_poweroftwo(TapCount - 1) + 1, T, expression_value_type<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 expression_short_fir<next_poweroftwo(TapCount - 1) + 1, T, expression_value_type<E1>, E1>(
std::forward<E1>(e1), taps);
}
https://github.com/kfrlib/kfr/blob//include/kfr/dsp/fir.hpp#L262
template <size_t TapCount, typename T, typename U,
typename E1>
expression_short_fir<next_poweroftwo(TapCount - 1) + 1, T,
expression_value_type<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 expression_short_fir<next_poweroftwo(TapCount - 1) + 1, T, expression_value_type<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 expression_short_fir<next_poweroftwo(TapCount - 1) + 1, T, expression_value_type<E1>, E1, true>(
std::forward<E1>(e1), state);
}
https://github.com/kfrlib/kfr/blob//include/kfr/dsp/fir.hpp#L277
Auto-generated from sources, Revision , https://github.com/kfrlib/kfr/blob//include/kfr/