c@225
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
c@225
|
2
|
c@225
|
3 /*
|
c@225
|
4 QM DSP Library
|
c@225
|
5
|
c@225
|
6 Centre for Digital Music, Queen Mary, University of London.
|
c@309
|
7
|
c@309
|
8 This program is free software; you can redistribute it and/or
|
c@309
|
9 modify it under the terms of the GNU General Public License as
|
c@309
|
10 published by the Free Software Foundation; either version 2 of the
|
c@309
|
11 License, or (at your option) any later version. See the file
|
c@309
|
12 COPYING included with this distribution for more information.
|
c@225
|
13 */
|
c@225
|
14
|
cannam@489
|
15 #ifndef QM_DSP_FILTER_H
|
cannam@489
|
16 #define QM_DSP_FILTER_H
|
c@225
|
17
|
c@434
|
18 #include "base/Restrict.h"
|
c@434
|
19
|
c@417
|
20 #include <vector>
|
c@225
|
21
|
c@417
|
22 class Filter
|
c@225
|
23 {
|
c@225
|
24 public:
|
c@417
|
25 struct Parameters {
|
c@417
|
26 std::vector<double> a;
|
c@417
|
27 std::vector<double> b;
|
c@417
|
28 };
|
c@417
|
29
|
c@417
|
30 /**
|
c@417
|
31 * Construct an IIR filter with numerators b and denominators
|
c@417
|
32 * a. The filter will have order b.size()-1. To make an FIR
|
c@417
|
33 * filter, leave the vector a in the param struct empty.
|
c@417
|
34 * Otherwise, a and b must have the same number of values.
|
c@417
|
35 */
|
c@417
|
36 Filter(Parameters params);
|
c@417
|
37
|
c@417
|
38 ~Filter();
|
c@225
|
39
|
c@225
|
40 void reset();
|
c@225
|
41
|
c@417
|
42 /**
|
c@417
|
43 * Filter the input sequence \arg in of length \arg n samples, and
|
c@417
|
44 * write the resulting \arg n samples into \arg out. There must be
|
c@417
|
45 * enough room in \arg out for \arg n samples to be written.
|
c@417
|
46 */
|
c@434
|
47 void process(const double *const QM_R__ in,
|
c@434
|
48 double *const QM_R__ out,
|
c@417
|
49 const int n);
|
c@225
|
50
|
c@417
|
51 int getOrder() const { return m_order; }
|
c@417
|
52
|
c@225
|
53 private:
|
c@417
|
54 int m_order;
|
c@417
|
55 int m_sz;
|
c@417
|
56 std::vector<double> m_a;
|
c@417
|
57 std::vector<double> m_b;
|
c@417
|
58 std::vector<double> m_bufa;
|
c@417
|
59 std::vector<double> m_bufb;
|
c@417
|
60 int m_offa;
|
c@417
|
61 int m_offb;
|
c@417
|
62 int m_offmax;
|
c@417
|
63 bool m_fir;
|
c@225
|
64
|
c@417
|
65 Filter(const Filter &); // not supplied
|
c@417
|
66 Filter &operator=(const Filter &); // not supplied
|
c@225
|
67 };
|
c@417
|
68
|
c@225
|
69 #endif
|