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@209
|
18 #include "base/Restrict.h"
|
Chris@209
|
19
|
Chris@193
|
20 #include <vector>
|
cannam@0
|
21
|
Chris@193
|
22 class Filter
|
cannam@0
|
23 {
|
cannam@0
|
24 public:
|
Chris@193
|
25 struct Parameters {
|
Chris@193
|
26 std::vector<double> a;
|
Chris@193
|
27 std::vector<double> b;
|
Chris@193
|
28 };
|
Chris@193
|
29
|
Chris@193
|
30 /**
|
Chris@193
|
31 * Construct an IIR filter with numerators b and denominators
|
Chris@193
|
32 * a. The filter will have order b.size()-1. To make an FIR
|
Chris@193
|
33 * filter, leave the vector a in the param struct empty.
|
Chris@193
|
34 * Otherwise, a and b must have the same number of values.
|
Chris@193
|
35 */
|
Chris@193
|
36 Filter(Parameters params);
|
Chris@193
|
37
|
Chris@193
|
38 ~Filter();
|
cannam@0
|
39
|
cannam@0
|
40 void reset();
|
cannam@0
|
41
|
Chris@193
|
42 /**
|
Chris@193
|
43 * Filter the input sequence \arg in of length \arg n samples, and
|
Chris@193
|
44 * write the resulting \arg n samples into \arg out. There must be
|
Chris@193
|
45 * enough room in \arg out for \arg n samples to be written.
|
Chris@193
|
46 */
|
Chris@209
|
47 void process(const double *const QM_R__ in,
|
Chris@209
|
48 double *const QM_R__ out,
|
Chris@193
|
49 const int n);
|
cannam@0
|
50
|
Chris@193
|
51 int getOrder() const { return m_order; }
|
Chris@193
|
52
|
cannam@0
|
53 private:
|
Chris@193
|
54 int m_order;
|
Chris@193
|
55 int m_sz;
|
Chris@193
|
56 std::vector<double> m_a;
|
Chris@193
|
57 std::vector<double> m_b;
|
Chris@193
|
58 std::vector<double> m_bufa;
|
Chris@193
|
59 std::vector<double> m_bufb;
|
Chris@193
|
60 int m_offa;
|
Chris@193
|
61 int m_offb;
|
Chris@193
|
62 int m_offmax;
|
Chris@193
|
63 bool m_fir;
|
cannam@0
|
64
|
Chris@193
|
65 Filter(const Filter &); // not supplied
|
Chris@193
|
66 Filter &operator=(const Filter &); // not supplied
|
cannam@0
|
67 };
|
Chris@193
|
68
|
cannam@0
|
69 #endif
|