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