Chris@337
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
Chris@337
|
2
|
Chris@337
|
3 /*
|
Chris@337
|
4 Vamp
|
Chris@337
|
5
|
Chris@337
|
6 An API for audio analysis and feature extraction plugins.
|
Chris@337
|
7
|
Chris@337
|
8 Centre for Digital Music, Queen Mary, University of London.
|
Chris@337
|
9 Copyright 2006-2012 Chris Cannam and QMUL.
|
Chris@337
|
10
|
Chris@337
|
11 Permission is hereby granted, free of charge, to any person
|
Chris@337
|
12 obtaining a copy of this software and associated documentation
|
Chris@337
|
13 files (the "Software"), to deal in the Software without
|
Chris@337
|
14 restriction, including without limitation the rights to use, copy,
|
Chris@337
|
15 modify, merge, publish, distribute, sublicense, and/or sell copies
|
Chris@337
|
16 of the Software, and to permit persons to whom the Software is
|
Chris@337
|
17 furnished to do so, subject to the following conditions:
|
Chris@337
|
18
|
Chris@337
|
19 The above copyright notice and this permission notice shall be
|
Chris@337
|
20 included in all copies or substantial portions of the Software.
|
Chris@337
|
21
|
Chris@337
|
22 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
Chris@337
|
23 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
Chris@337
|
24 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
Chris@337
|
25 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
|
Chris@337
|
26 ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
Chris@337
|
27 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
Chris@337
|
28 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
Chris@337
|
29
|
Chris@337
|
30 Except as contained in this notice, the names of the Centre for
|
Chris@337
|
31 Digital Music; Queen Mary, University of London; and Chris Cannam
|
Chris@337
|
32 shall not be used in advertising or otherwise to promote the sale,
|
Chris@337
|
33 use or other dealings in this Software without prior written
|
Chris@337
|
34 authorization.
|
Chris@337
|
35 */
|
Chris@337
|
36
|
Chris@337
|
37 #ifndef _VAMP_FFT_H_
|
Chris@337
|
38 #define _VAMP_FFT_H_
|
Chris@337
|
39
|
Chris@337
|
40 #include "plugguard.h"
|
Chris@337
|
41 _VAMP_SDK_PLUGSPACE_BEGIN(FFT.h)
|
Chris@337
|
42
|
Chris@337
|
43 namespace Vamp {
|
Chris@337
|
44
|
Chris@337
|
45 /**
|
Chris@337
|
46 * A simple FFT implementation provided for convenience of plugin
|
Chris@434
|
47 * authors. This class provides one-shot (i.e. fixed table state is
|
Chris@445
|
48 * recalculated every time) double-precision complex-complex
|
Chris@434
|
49 * transforms. For repeated transforms from real time-domain data, use
|
Chris@445
|
50 * an FFTReal object instead.
|
Chris@337
|
51 *
|
Chris@434
|
52 * The forward transform is unscaled; the inverse transform is scaled
|
Chris@434
|
53 * by 1/n.
|
Chris@337
|
54 */
|
Chris@337
|
55 class FFT
|
Chris@337
|
56 {
|
Chris@337
|
57 public:
|
Chris@337
|
58 /**
|
Chris@434
|
59 * Calculate a one-shot forward transform of size n.
|
Chris@394
|
60 * n must be a power of 2, greater than 1.
|
Chris@337
|
61 *
|
Chris@337
|
62 * ri and ii must point to the real and imaginary component arrays
|
Chris@337
|
63 * of the input. For real input, ii may be NULL.
|
Chris@337
|
64 *
|
Chris@337
|
65 * ro and io must point to enough space to receive the real and
|
Chris@337
|
66 * imaginary component arrays of the output.
|
Chris@337
|
67 *
|
Chris@337
|
68 * All input and output arrays are of size n.
|
Chris@337
|
69 */
|
Chris@338
|
70 static void forward(unsigned int n,
|
Chris@338
|
71 const double *ri, const double *ii,
|
Chris@338
|
72 double *ro, double *io);
|
Chris@337
|
73
|
Chris@337
|
74 /**
|
Chris@434
|
75 * Calculate a one-shot inverse transform of size n.
|
Chris@394
|
76 * n must be a power of 2, greater than 1.
|
Chris@337
|
77 *
|
Chris@337
|
78 * ri and ii must point to the real and imaginary component arrays
|
Chris@337
|
79 * of the input. For real input, ii may be NULL.
|
Chris@337
|
80 *
|
Chris@337
|
81 * ro and io must point to enough space to receive the real and
|
Chris@337
|
82 * imaginary component arrays of the output. The output is scaled
|
Chris@337
|
83 * by 1/n. The output pointers may not be NULL, even if the output
|
Chris@337
|
84 * is expected to be real.
|
Chris@337
|
85 *
|
Chris@337
|
86 * All input and output arrays are of size n.
|
Chris@337
|
87 */
|
Chris@338
|
88 static void inverse(unsigned int n,
|
Chris@338
|
89 const double *ri, const double *ii,
|
Chris@338
|
90 double *ro, double *io);
|
Chris@337
|
91 };
|
Chris@337
|
92
|
Chris@434
|
93 /**
|
Chris@434
|
94 * A simple FFT implementation provided for convenience of plugin
|
Chris@445
|
95 * authors. This class provides transforms between double-precision
|
Chris@445
|
96 * real time-domain and double-precision complex frequency-domain
|
Chris@445
|
97 * data.
|
Chris@434
|
98 *
|
Chris@434
|
99 * The forward transform is unscaled; the inverse transform is scaled
|
Chris@434
|
100 * by 1/n.
|
Chris@434
|
101 */
|
Chris@434
|
102 class FFTReal
|
Chris@434
|
103 {
|
Chris@434
|
104 /**
|
Chris@434
|
105 * Prepare to calculate transforms of size n.
|
Chris@434
|
106 * n must be a power of 2, greater than 1.
|
Chris@434
|
107 */
|
Chris@434
|
108 FFTReal(unsigned int n);
|
Chris@434
|
109
|
Chris@434
|
110 ~FFTReal();
|
Chris@434
|
111
|
Chris@434
|
112 /**
|
Chris@434
|
113 * Calculate a forward transform of size n.
|
Chris@434
|
114 *
|
Chris@434
|
115 * ri must point to the real input data of size n.
|
Chris@434
|
116 *
|
Chris@434
|
117 * co must point to enough space to receive an interleaved complex
|
Chris@434
|
118 * output array of size n/2+1.
|
Chris@434
|
119 */
|
Chris@445
|
120 void forward(const double *ri, double *co);
|
Chris@434
|
121
|
Chris@434
|
122 /**
|
Chris@434
|
123 * Calculate an inverse transform of size n.
|
Chris@434
|
124 *
|
Chris@434
|
125 * ci must point to an interleaved complex input array of size n/2+1.
|
Chris@434
|
126 *
|
Chris@434
|
127 * ro must point to enough space to receive the real output data
|
Chris@434
|
128 * of size n. The output is scaled by 1/n and only the real part
|
Chris@434
|
129 * is returned.
|
Chris@434
|
130 */
|
Chris@445
|
131 void inverse(const double *ci, double *ro);
|
Chris@434
|
132
|
Chris@434
|
133 private:
|
Chris@434
|
134 class D;
|
Chris@434
|
135 D *m_d;
|
Chris@434
|
136 };
|
Chris@434
|
137
|
Chris@337
|
138 }
|
Chris@337
|
139
|
Chris@337
|
140 _VAMP_SDK_PLUGSPACE_END(FFT.h)
|
Chris@337
|
141
|
Chris@337
|
142 #endif
|