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 QM DSP Library
|
cannam@0
|
4
|
cannam@0
|
5 Centre for Digital Music, Queen Mary, University of London.
|
Chris@84
|
6
|
Chris@84
|
7 This program is free software; you can redistribute it and/or
|
Chris@84
|
8 modify it under the terms of the GNU General Public License as
|
Chris@84
|
9 published by the Free Software Foundation; either version 2 of the
|
Chris@84
|
10 License, or (at your option) any later version. See the file
|
Chris@84
|
11 COPYING included with this distribution for more information.
|
cannam@0
|
12 */
|
cannam@0
|
13
|
Chris@155
|
14 #ifndef DECIMATORB_H
|
Chris@155
|
15 #define DECIMATORB_H
|
Chris@155
|
16
|
Chris@155
|
17 #include <vector>
|
cannam@0
|
18
|
Chris@150
|
19 /**
|
Chris@155
|
20 * DecimatorB carries out a fast downsample by a power-of-two
|
Chris@155
|
21 * factor. It only knows how to decimate by a factor of 2, and will
|
Chris@155
|
22 * use repeated decimation for higher factors. A Butterworth filter of
|
Chris@155
|
23 * order 6 is used for the lowpass filter.
|
Chris@150
|
24 */
|
Chris@155
|
25 class DecimatorB
|
cannam@0
|
26 {
|
cannam@0
|
27 public:
|
cannam@22
|
28 void process( const double* src, double* dst );
|
cannam@55
|
29 void process( const float* src, float* dst );
|
cannam@0
|
30
|
cannam@54
|
31 /**
|
Chris@155
|
32 * Construct a DecimatorB to operate on input blocks of length
|
cannam@54
|
33 * inLength, with decimation factor decFactor. inLength should be
|
cannam@54
|
34 * a multiple of decFactor. Output blocks will be of length
|
cannam@54
|
35 * inLength / decFactor.
|
cannam@54
|
36 *
|
Chris@155
|
37 * decFactor must be a power of two.
|
cannam@54
|
38 */
|
Chris@155
|
39 DecimatorB(int inLength, int decFactor);
|
Chris@155
|
40 virtual ~DecimatorB();
|
cannam@0
|
41
|
cannam@22
|
42 int getFactor() const { return m_decFactor; }
|
cannam@22
|
43
|
cannam@0
|
44 private:
|
cannam@0
|
45 void deInitialise();
|
Chris@155
|
46 void initialise(int inLength, int decFactor);
|
Chris@155
|
47 void doAntiAlias(const double* src, double* dst, int length, int filteridx);
|
Chris@155
|
48 void doProcess();
|
cannam@0
|
49
|
Chris@155
|
50 int m_inputLength;
|
Chris@155
|
51 int m_outputLength;
|
Chris@155
|
52 int m_decFactor;
|
cannam@0
|
53
|
Chris@155
|
54 std::vector<std::vector<double> > m_o;
|
cannam@0
|
55
|
Chris@155
|
56 double m_a[7];
|
Chris@155
|
57 double m_b[7];
|
cannam@0
|
58
|
Chris@155
|
59 double *m_aaBuffer;
|
Chris@155
|
60 double *m_tmpBuffer;
|
cannam@0
|
61 };
|
cannam@0
|
62
|
Chris@155
|
63 #endif
|
Chris@155
|
64
|