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 This file 2005-2006 Christian Landone.
|
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 DECIMATOR_H
|
cannam@0
|
16 #define DECIMATOR_H
|
cannam@0
|
17
|
Chris@150
|
18 /**
|
Chris@150
|
19 * Decimator carries out a fast downsample by a power-of-two
|
Chris@150
|
20 * factor. Only a limited number of factors are supported, from two to
|
Chris@150
|
21 * whatever getHighestSupportedFactor() returns. This is much faster
|
Chris@150
|
22 * than Resampler but has a worse signal-noise ratio.
|
Chris@150
|
23 */
|
cannam@0
|
24 class Decimator
|
cannam@0
|
25 {
|
cannam@0
|
26 public:
|
cannam@22
|
27 void process( const double* src, double* dst );
|
cannam@55
|
28 void process( const float* src, float* dst );
|
cannam@0
|
29
|
cannam@54
|
30 /**
|
cannam@54
|
31 * Construct a Decimator to operate on input blocks of length
|
cannam@54
|
32 * inLength, with decimation factor decFactor. inLength should be
|
cannam@54
|
33 * a multiple of decFactor. Output blocks will be of length
|
cannam@54
|
34 * inLength / decFactor.
|
cannam@54
|
35 *
|
cannam@54
|
36 * decFactor must be a power of two. The highest supported factor
|
cannam@54
|
37 * is obtained through getHighestSupportedFactor(); for higher
|
cannam@54
|
38 * factors, you will need to chain more than one decimator.
|
cannam@54
|
39 */
|
cannam@0
|
40 Decimator( unsigned int inLength, unsigned int decFactor );
|
cannam@0
|
41 virtual ~Decimator();
|
cannam@0
|
42
|
cannam@22
|
43 int getFactor() const { return m_decFactor; }
|
cannam@22
|
44 static int getHighestSupportedFactor() { return 8; }
|
cannam@22
|
45
|
cannam@0
|
46 private:
|
cannam@0
|
47 void resetFilter();
|
cannam@0
|
48 void deInitialise();
|
cannam@0
|
49 void initialise( unsigned int inLength, unsigned int decFactor );
|
cannam@55
|
50 void doAntiAlias( const double* src, double* dst, unsigned int length );
|
cannam@55
|
51 void doAntiAlias( const float* src, double* dst, unsigned int length );
|
cannam@0
|
52
|
cannam@0
|
53 unsigned int m_inputLength;
|
cannam@0
|
54 unsigned int m_outputLength;
|
cannam@0
|
55 unsigned int m_decFactor;
|
cannam@0
|
56
|
cannam@0
|
57 double Input;
|
cannam@0
|
58 double Output ;
|
cannam@0
|
59
|
cannam@0
|
60 double o1,o2,o3,o4,o5,o6,o7;
|
cannam@0
|
61
|
cannam@0
|
62 double a[ 9 ];
|
cannam@0
|
63 double b[ 9 ];
|
cannam@0
|
64
|
cannam@0
|
65 double* decBuffer;
|
cannam@0
|
66 };
|
cannam@0
|
67
|
cannam@0
|
68 #endif //
|