23 #ifndef INCLUDED_IIR_FILTER_H
24 #define INCLUDED_IIR_FILTER_H
37 template<
class i_type,
class o_type,
class tap_type>
66 const std::vector<tap_type>& fbtaps)
throw (std::invalid_argument)
79 o_type
filter(
const i_type input);
85 void filter_n(o_type output[],
const i_type input[],
long n);
96 void set_taps(
const std::vector<tap_type> &fftaps,
97 const std::vector<tap_type> &fbtaps)
throw (std::invalid_argument)
104 int n = fftaps.size();
105 int m = fbtaps.size();
109 for(
int i = 0; i < 2 * n; i++) {
112 for(
int i = 0; i < 2 * m; i++) {
129 template<
class i_type,
class o_type,
class tap_type>
135 unsigned n = ntaps_ff();
136 unsigned m = ntaps_fb();
141 int latest_n = d_latest_n;
142 int latest_m = d_latest_m;
144 acc = d_fftaps[0] * input;
145 for(i = 1; i < n; i ++)
146 acc += (d_fftaps[i] * d_prev_input[latest_n + i]);
147 for(i = 1; i < m; i ++)
148 acc += (d_fbtaps[i] * d_prev_output[latest_m + i]);
151 d_prev_output[latest_m] = acc;
152 d_prev_output[latest_m+m] = acc;
153 d_prev_input[latest_n] = input;
154 d_prev_input[latest_n+n] = input;
163 d_latest_m = latest_m;
164 d_latest_n = latest_n;
168 template<
class i_type,
class o_type,
class tap_type>
171 const i_type input[],
174 for(
int i = 0; i < n; i++)
175 output[i] = filter(input[i]);