comparison vamp-sdk/FFT.h @ 460:b409560a805b

Merge from branch vampipe
author Chris Cannam
date Mon, 10 Oct 2016 15:48:35 +0100
parents aadfe19a0e94
children
comparison
equal deleted inserted replaced
442:4101e3f80aa0 460:b409560a805b
42 42
43 namespace Vamp { 43 namespace Vamp {
44 44
45 /** 45 /**
46 * A simple FFT implementation provided for convenience of plugin 46 * A simple FFT implementation provided for convenience of plugin
47 * authors. 47 * authors. This class provides one-shot (i.e. fixed table state is
48 * 48 * recalculated every time) double-precision complex-complex
49 * This class provides double-precision FFTs in power-of-two sizes 49 * transforms. For repeated transforms from real time-domain data, use
50 * only. It is slower than more sophisticated library 50 * an FFTComplex or FFTReal object instead.
51 * implementations. If these requirements aren't suitable, make other 51 *
52 * arrangements. 52 * Note: If the SDK has been compiled with the SINGLE_PRECISION_FFT
53 * 53 * flag, then all FFTs will use single precision internally. The
54 * The inverse transform is scaled by 1/n. 54 * default is double precision. The API uses doubles in either case.
55 * 55 *
56 * The implementation is from Don Cross's public domain FFT code. 56 * The forward transform is unscaled; the inverse transform is scaled
57 * by 1/n.
57 */ 58 */
58 class FFT 59 class FFT
59 { 60 {
60 public: 61 public:
61 /** 62 /**
62 * Calculate a forward transform of size n. 63 * Calculate a one-shot forward transform of size n.
63 * n must be a power of 2, greater than 1. 64 * n must be a multiple of 2.
64 * 65 *
65 * ri and ii must point to the real and imaginary component arrays 66 * ri and ii must point to the real and imaginary component arrays
66 * of the input. For real input, ii may be NULL. 67 * of the input. For real input, ii may be NULL.
67 * 68 *
68 * ro and io must point to enough space to receive the real and 69 * ro and io must point to enough space to receive the real and
73 static void forward(unsigned int n, 74 static void forward(unsigned int n,
74 const double *ri, const double *ii, 75 const double *ri, const double *ii,
75 double *ro, double *io); 76 double *ro, double *io);
76 77
77 /** 78 /**
78 * Calculate an inverse transform of size n. 79 * Calculate a one-shot inverse transform of size n.
79 * n must be a power of 2, greater than 1. 80 * n must be a power of 2, greater than 1.
80 * 81 *
81 * ri and ii must point to the real and imaginary component arrays 82 * ri and ii must point to the real and imaginary component arrays
82 * of the input. For real input, ii may be NULL. 83 * of the input. For real input, ii may be NULL.
83 * 84 *
91 static void inverse(unsigned int n, 92 static void inverse(unsigned int n,
92 const double *ri, const double *ii, 93 const double *ri, const double *ii,
93 double *ro, double *io); 94 double *ro, double *io);
94 }; 95 };
95 96
97 /**
98 * A simple FFT implementation provided for convenience of plugin
99 * authors. This class provides double-precision complex-complex
100 * transforms.
101 *
102 * Note: If the SDK has been compiled with the SINGLE_PRECISION_FFT
103 * flag, then all FFTs will use single precision internally. The
104 * default is double precision. The API uses doubles in either case.
105 *
106 * The forward transform is unscaled; the inverse transform is scaled
107 * by 1/n.
108 */
109 class FFTComplex
110 {
111 public:
112 /**
113 * Prepare to calculate transforms of size n.
114 * n must be a multiple of 2.
115 */
116 FFTComplex(unsigned int n);
117
118 ~FFTComplex();
119
120 /**
121 * Calculate a forward transform of size n.
122 *
123 * ci must point to the interleaved complex input data of size n
124 * (that is, 2n doubles in total).
125 *
126 * co must point to enough space to receive an interleaved complex
127 * output array of size n (that is, 2n doubles in total).
128 */
129 void forward(const double *ci, double *co);
130
131 /**
132 * Calculate an inverse transform of size n.
133 *
134 * ci must point to an interleaved complex input array of size n
135 * (that is, 2n doubles in total).
136 *
137 * co must point to enough space to receive the interleaved
138 * complex output data of size n (that is, 2n doubles in
139 * total). The output is scaled by 1/n.
140 */
141 void inverse(const double *ci, double *co);
142
143 private:
144 class D;
145 D *m_d;
146 };
147
148 /**
149 * A simple FFT implementation provided for convenience of plugin
150 * authors. This class provides transforms between double-precision
151 * real time-domain and double-precision complex frequency-domain
152 * data.
153 *
154 * Note: If the SDK has been compiled with the SINGLE_PRECISION_FFT
155 * flag, then all FFTs will use single precision internally. The
156 * default is double precision. The API uses doubles in either case.
157 *
158 * The forward transform is unscaled; the inverse transform is scaled
159 * by 1/n.
160 */
161 class FFTReal
162 {
163 public:
164 /**
165 * Prepare to calculate transforms of size n.
166 * n must be a multiple of 2.
167 */
168 FFTReal(unsigned int n);
169
170 ~FFTReal();
171
172 /**
173 * Calculate a forward transform of size n.
174 *
175 * ri must point to the real input data of size n.
176 *
177 * co must point to enough space to receive an interleaved complex
178 * output array of size n/2+1 (that is, n+2 doubles in total).
179 */
180 void forward(const double *ri, double *co);
181
182 /**
183 * Calculate an inverse transform of size n.
184 *
185 * ci must point to an interleaved complex input array of size
186 * n/2+1 (that is, n+2 doubles in total).
187 *
188 * ro must point to enough space to receive the real output data
189 * of size n. The output is scaled by 1/n and only the real part
190 * is returned.
191 */
192 void inverse(const double *ci, double *ro);
193
194 private:
195 class D;
196 D *m_d;
197 };
198
96 } 199 }
97 200
98 _VAMP_SDK_PLUGSPACE_END(FFT.h) 201 _VAMP_SDK_PLUGSPACE_END(FFT.h)
99 202
100 #endif 203 #endif