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