23 #ifndef INCLUDED_IIR_FILTER_H
24 #define INCLUDED_IIR_FILTER_H
38 template<
class i_type,
class o_type,
class tap_type>
70 const std::vector<tap_type>& fbtaps,
72 throw (std::invalid_argument)
86 o_type
filter(
const i_type input);
92 void filter_n(o_type output[],
const i_type input[],
long n);
104 const std::vector<tap_type> &fbtaps)
105 throw (std::invalid_argument)
119 for(
size_t i = 1; i < fbtaps.size(); i++) {
124 int n = fftaps.size();
125 int m = fbtaps.size();
145 template<
class i_type,
class o_type,
class tap_type>
151 unsigned n = ntaps_ff();
152 unsigned m = ntaps_fb();
157 int latest_n = d_latest_n;
158 int latest_m = d_latest_m;
160 acc = d_fftaps[0] * input;
161 for(i = 1; i < n; i ++)
162 acc += (d_fftaps[i] * d_prev_input[latest_n + i]);
163 for(i = 1; i < m; i ++)
164 acc += (d_fbtaps[i] * d_prev_output[latest_m + i]);
167 d_prev_output[latest_m] = acc;
168 d_prev_output[latest_m+m] = acc;
169 d_prev_input[latest_n] = input;
170 d_prev_input[latest_n+n] = input;
179 d_latest_m = latest_m;
180 d_latest_n = latest_n;
184 template<
class i_type,
class o_type,
class tap_type>
187 const i_type input[],
190 for(
int i = 0; i < n; i++)
191 output[i] = filter(input[i]);
int d_latest_m
Definition: iir_filter.h:137
o_type filter(const i_type input)
compute a single output value.
Definition: iir_filter.h:147
std::vector< i_type > d_prev_input
Definition: iir_filter.h:139
bool d_oldstyle
Definition: iir_filter.h:133
base class template for Infinite Impulse Response filter (IIR)
Definition: iir_filter.h:39
iir_filter(const std::vector< tap_type > &fftaps, const std::vector< tap_type > &fbtaps, bool oldstyle=true)
Construct an IIR with the given taps.
Definition: iir_filter.h:69
std::vector< tap_type > d_fftaps
Definition: iir_filter.h:134
void set_taps(const std::vector< tap_type > &fftaps, const std::vector< tap_type > &fbtaps)
install new taps.
Definition: iir_filter.h:103
std::complex< float > gr_complex
Definition: gr_complex.h:27
~iir_filter()
Definition: iir_filter.h:80
void filter_n(o_type output[], const i_type input[], long n)
compute an array of N output values. input must have N valid entries.
Definition: iir_filter.h:186
std::vector< tap_type > d_fbtaps
Definition: iir_filter.h:135
unsigned ntaps_ff() const
Definition: iir_filter.h:97
int d_latest_n
Definition: iir_filter.h:136
unsigned ntaps_fb() const
Definition: iir_filter.h:98
iir_filter()
Definition: iir_filter.h:78
std::vector< o_type > d_prev_output
Definition: iir_filter.h:138