23 #ifndef INCLUDED_IIR_FILTER_H 24 #define INCLUDED_IIR_FILTER_H 81 template<
class i_type,
class o_type,
class tap_type,
class acc_type>
121 const std::vector<tap_type>& fbtaps,
123 throw (
std::invalid_argument)
125 d_oldstyle = oldstyle;
126 set_taps(fftaps, fbtaps);
137 o_type filter(
const i_type input);
143 void filter_n(o_type output[],
const i_type input[],
long n);
148 unsigned ntaps_ff()
const {
return d_fftaps.size(); }
149 unsigned ntaps_fb()
const {
return d_fbtaps.size(); }
155 const std::vector<tap_type> &fbtaps)
156 throw (std::invalid_argument)
168 d_fbtaps.resize(fbtaps.size());
169 d_fbtaps[0] = fbtaps[0];
170 for(
size_t i = 1; i < fbtaps.size(); i++) {
171 d_fbtaps[i] = -fbtaps[i];
175 int n = fftaps.size();
176 int m = fbtaps.size();
177 d_prev_input.clear();
178 d_prev_output.clear();
179 d_prev_input.resize(2 * n, 0);
180 d_prev_output.resize(2 * m, 0);
196 template<
class i_type,
class o_type,
class tap_type,
class acc_type>
202 unsigned n = ntaps_ff();
203 unsigned m = ntaps_fb();
208 int latest_n = d_latest_n;
209 int latest_m = d_latest_m;
211 acc = d_fftaps[0] * input;
212 for(i = 1; i < n; i ++)
213 acc += (d_fftaps[i] * d_prev_input[latest_n + i]);
214 for(i = 1; i < m; i ++)
215 acc += (d_fbtaps[i] * d_prev_output[latest_m + i]);
218 d_prev_output[latest_m] = acc;
219 d_prev_output[latest_m+m] = acc;
220 d_prev_input[latest_n] = input;
221 d_prev_input[latest_n+n] = input;
230 d_latest_m = latest_m;
231 d_latest_n = latest_n;
235 template<
class i_type,
class o_type,
class tap_type,
class acc_type>
238 const i_type input[],
241 for(
int i = 0; i < n; i++)
242 output[i] = filter(input[i]);
std::vector< i_type > d_prev_input
Definition: iir_filter.h:190
std::vector< tap_type > d_fftaps
Definition: iir_filter.h:185
o_type filter(const i_type input)
compute a single output value.
Definition: iir_filter.h:198
iir_filter()
Definition: iir_filter.h:129
std::vector< acc_type > d_prev_output
Definition: iir_filter.h:189
Base class template for Infinite Impulse Response filter (IIR)
Definition: iir_filter.h:82
void set_taps(const std::vector< tap_type > &fftaps, const std::vector< tap_type > &fbtaps)
install new taps.
Definition: iir_filter.h:154
unsigned ntaps_ff() const
Definition: iir_filter.h:148
std::complex< float > gr_complex
Definition: gr_complex.h:27
Include this header to use the message passing features.
Definition: logger.h:695
int d_latest_n
Definition: iir_filter.h:187
unsigned ntaps_fb() const
Definition: iir_filter.h:149
bool d_oldstyle
Definition: iir_filter.h:184
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:120
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:237
~iir_filter()
Definition: iir_filter.h:131
std::vector< tap_type > d_fbtaps
Definition: iir_filter.h:186
int d_latest_m
Definition: iir_filter.h:188
#define FILTER_API
Definition: gr-filter/include/gnuradio/filter/api.h:30