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)
Param e1
an input expression
Param samples
delay in samples (must be a compile time value)
univector<double, 10\> v = counter();
auto d = delay(v, csize<4\>);
template <size_t samples, typename T, typename E1,
univector_tag STag>
expression_delay<samples, E1, true, STag>
delay(E1 &&e1,
std::reference_wrapper<delay_state<T, samples, STag>>
state)
Returns template expression that applies delay to the input (uses ring buffer in state)
Param state
delay filter state (taken by reference)
Param e1
an input expression
univector<double, 10\> v = counter();
delay_state<double, 4\> state;
auto d = delay(state, v);
template <size_t samples, typename T, typename E1,
univector_tag STag>
[[deprecated("delay(state, expr) is deprecated. Use "
"delay(expr, std::ref(state))")]]
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)
Param state
delay filter state
Param e1
an input expression
univector<double, 10\> v = counter();
delay_state<double, 4\> state;
auto d = delay(state, v);
fir
function¶
template <typename E1, typename U = expression_value_type<E1>, typename Taps,
typename T = std::remove_cv_t<container_value_type<Taps>>>
[[deprecated("fir(expr, taps) is deprecated. Use fir(expr, fir_params
Returns template expression that applies FIR filter to the input
Param e1
an input expression
Param taps
coefficients for the FIR filter (taken by value)
template <typename T, typename E1,
typename U = expression_value_type<E1>>
expression_fir<T, U, E1, false> fir(E1 &&e1,
fir_params<T> state)
Returns template expression that applies FIR filter to the input
Param e1
an input expression
Param state
coefficients for the FIR filter (taken by value)
template <typename T, typename E1, typename U>
expression_fir<T, U, E1, true>
fir(E1 &&e1, std::reference_wrapper<fir_state<T, U>> state)
Returns template expression that applies FIR filter to the input
Param e1
an input expression
Param state
coefficients and state of the filter (taken by reference, ensure proper lifetime)
template <typename T, typename U, typename E1>
[[deprecated(
"fir(state, expr) is deprecated. Use fir(expr, "
"std::ref(state))")]] expression_fir<T, U, E1, true>
fir(fir_state<T, U> &state, E1 &&e1)
Returns template expression that applies FIR filter to the input
Param state
FIR filter state (state is referenced, ensure proper lifetime)
Param e1
an input expression
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
Param taps
array where computed coefficients are stored
Param frequency1
Normalized frequency (frequency_Hz / samplerate_Hz)
Param frequency2
Normalized frequency (frequency_Hz / samplerate_Hz)
Param window
pointer to a window function
Param normalize
true for normalized coefficients
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
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
Param taps
array where computed coefficients are stored
Param frequency1
Normalized frequency (frequency_Hz / samplerate_Hz)
Param frequency2
Normalized frequency (frequency_Hz / samplerate_Hz)
Param window
pointer to a window function
Param normalize
true for normalized coefficients
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
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
Param taps
array where computed coefficients are stored
Param cutoff
Normalized frequency (frequency_Hz / samplerate_Hz)
Param window
pointer to a window function
Param normalize
true for normalized coefficients
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
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
Param taps
array where computed coefficients are stored
Param cutoff
Normalized frequency (frequency_Hz / samplerate_Hz)
Param window
pointer to a window function
Param normalize
true for normalized coefficients
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
fracdelay
function¶
template <typename T, typename E1>
expression_short_fir<2, T, expression_value_type<E1>, E1>
fracdelay(E1 &&e1, T delay)
Returns template expression that applies a fractional delay to the input
Param e1
an input expression
Param e1
a fractional delay in range 0..1
moving_sum
function¶
template <typename E1>
expression_moving_sum<expression_value_type<E1>, E1,
tag_dynamic_vector>
moving_sum(E1 &&e1, size_t sum_length)
Returns template expression that performs moving sum on the input
Param e1
an input expression
template <size_t sum_length, typename E1>
[[deprecated("moving_sum<len> is deprecated. Use "
"moving_sum(expr, len) instead")]]
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
Param e1
an input expression
template <typename E1, typename U, size_t Tag>
expression_moving_sum<U, E1, Tag, true> moving_sum(
E1 &&e1,
std::reference_wrapper<moving_sum_state<U, Tag>> state)
Returns template expression that performs moving sum on the input
Param e1
an input expression
Param state
State (taken by reference)
template <typename U, typename E1, univector_tag STag>
[[deprecated(
"moving_sum(state, expr) is deprecated. Use "
"moving_sum(expr, std::ref(state)) "
"instead")]] 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
Param state
moving sum state
Param e1
an input expression
reset
function¶
void reset() final
Reset internal filter state
short_fir
function¶
template <typename T, size_t TapCount, typename E1,
size_t InternalTapCount =
next_poweroftwo(TapCount - 1) + 1,
typename U = expression_value_type<E1>>
expression_short_fir<InternalTapCount, T, U, E1, false>
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)
Param e1
an input expression
Param taps
coefficients for the FIR filter
template <typename T, size_t TapCount, typename E1,
typename U>
expression_short_fir<TapCount, T, U, E1, true> short_fir(
E1 &&e1,
std::reference_wrapper<short_fir_state<TapCount, T, U>>
state)
Returns template expression that applies FIR filter to the input (count of coefficients must be in
range 2..32)
Param e1
an input expression
Param state
FIR filter state (state is referenced, ensure proper lifetime)
template <size_t TapCount,
size_t InternalTapCount =
next_poweroftwo(TapCount - 1) + 1,
typename T, typename U, typename E1>
[[deprecated("short_fir(state, expr) is deprecated, use "
"short_fir(expr, std::ref(state))")]]
expression_short_fir<InternalTapCount, T,
expression_value_type<E1>, E1, true>
short_fir(short_fir_state<InternalTapCount, T, U> &state,
E1 &&e1)
Returns template expression that applies FIR filter to the input (count of coefficients must be in
range 2..32)
Param state
FIR filter state
Param e1
an input expression
Auto-generated from sources, Revision 6aea976a464de59d522d0c629e64bf0c044e6777, https://github.com/kfrlib/kfr/blob/6aea976a464de59d522d0c629e64bf0c044e6777/include/kfr/