c@225: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ c@225: c@225: /* c@225: QM DSP Library c@225: c@225: Centre for Digital Music, Queen Mary, University of London. c@309: c@309: This program is free software; you can redistribute it and/or c@309: modify it under the terms of the GNU General Public License as c@309: published by the Free Software Foundation; either version 2 of the c@309: License, or (at your option) any later version. See the file c@309: COPYING included with this distribution for more information. c@225: */ c@225: cannam@489: #ifndef QM_DSP_FILTER_H cannam@489: #define QM_DSP_FILTER_H c@225: c@434: #include "base/Restrict.h" c@434: c@417: #include c@225: c@417: class Filter c@225: { c@225: public: c@417: struct Parameters { c@417: std::vector a; c@417: std::vector b; c@417: }; c@417: c@417: /** c@417: * Construct an IIR filter with numerators b and denominators c@417: * a. The filter will have order b.size()-1. To make an FIR c@417: * filter, leave the vector a in the param struct empty. c@417: * Otherwise, a and b must have the same number of values. c@417: */ c@417: Filter(Parameters params); c@417: c@417: ~Filter(); c@225: c@225: void reset(); c@225: c@417: /** c@417: * Filter the input sequence \arg in of length \arg n samples, and c@417: * write the resulting \arg n samples into \arg out. There must be c@417: * enough room in \arg out for \arg n samples to be written. c@417: */ c@434: void process(const double *const QM_R__ in, c@434: double *const QM_R__ out, c@417: const int n); c@225: c@417: int getOrder() const { return m_order; } c@417: c@225: private: c@417: int m_order; c@417: int m_sz; c@417: std::vector m_a; c@417: std::vector m_b; c@417: std::vector m_bufa; c@417: std::vector m_bufb; c@417: int m_offa; c@417: int m_offb; c@417: int m_offmax; c@417: bool m_fir; c@225: c@417: Filter(const Filter &); // not supplied c@417: Filter &operator=(const Filter &); // not supplied c@225: }; c@417: c@225: #endif