23 if (params.
a.empty()) {
25 if (params.
b.empty()) {
26 throw logic_error(
"Filter must have at least one pair of coefficients");
30 if (params.
a.size() != params.
b.size()) {
31 throw logic_error(
"Inconsistent numbers of filter coefficients");
35 m_sz = int(params.
b.size());
53 m_bufa.resize(m_order + m_offmax);
56 m_bufb.resize(m_sz + m_offmax);
70 m_bufa.assign(m_bufa.size(), 0.0);
73 m_bufb.assign(m_bufb.size(), 0.0);
81 for (
int s = 0; s < n; ++s) {
86 for (
int i = m_sz - 2; i >= 0; --i) {
87 m_bufb[i + m_offmax + 1] = m_bufb[i];
91 m_bufb[m_offb] = in[s];
94 for (
int i = 0; i < m_sz; ++i) {
95 b_sum += m_b[i] * m_bufb[i + m_offb];
107 for (
int i = 0; i < m_order; ++i) {
108 a_sum += m_a[i + 1] * m_bufa[i + m_offa];
111 outval = b_sum - a_sum;
116 for (
int i = m_order - 2; i >= 0; --i) {
117 m_bufa[i + m_offmax + 1] = m_bufa[i];
121 m_bufa[m_offa] = outval;
void process(const double *const QM_R__ in, double *const QM_R__ out, const int n)
Filter the input sequence.
Filter(Parameters params)
Construct an IIR filter with numerators b and denominators a.