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]);