Mercurial > hg > vamp-plugin-sdk
comparison vamp-sdk/FFT.h @ 446:d132b92ec65d vampipe
Add FFTComplex class by analogy to FFTReal
author | Chris Cannam |
---|---|
date | Thu, 18 Aug 2016 16:04:25 +0100 |
parents | 7f7a10bcaff1 |
children | aadfe19a0e94 |
comparison
equal
deleted
inserted
replaced
445:7f7a10bcaff1 | 446:d132b92ec65d |
---|---|
45 /** | 45 /** |
46 * A simple FFT implementation provided for convenience of plugin | 46 * A simple FFT implementation provided for convenience of plugin |
47 * authors. This class provides one-shot (i.e. fixed table state is | 47 * authors. This class provides one-shot (i.e. fixed table state is |
48 * recalculated every time) double-precision complex-complex | 48 * recalculated every time) double-precision complex-complex |
49 * transforms. For repeated transforms from real time-domain data, use | 49 * transforms. For repeated transforms from real time-domain data, use |
50 * an FFTReal object instead. | 50 * an FFTComplex or FFTReal object instead. |
51 * | |
52 * Note: If the SDK has been compiled with the SINGLE_PRECISION_FFT | |
53 * flag, then all FFTs will use single precision internally. The | |
54 * default is double precision. The API uses doubles in either case. | |
51 * | 55 * |
52 * The forward transform is unscaled; the inverse transform is scaled | 56 * The forward transform is unscaled; the inverse transform is scaled |
53 * by 1/n. | 57 * by 1/n. |
54 */ | 58 */ |
55 class FFT | 59 class FFT |
56 { | 60 { |
57 public: | 61 public: |
58 /** | 62 /** |
59 * Calculate a one-shot forward transform of size n. | 63 * Calculate a one-shot forward transform of size n. |
60 * n must be a power of 2, greater than 1. | 64 * n must be a multiple of 2. |
61 * | 65 * |
62 * 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 |
63 * of the input. For real input, ii may be NULL. | 67 * of the input. For real input, ii may be NULL. |
64 * | 68 * |
65 * 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 |
86 * All input and output arrays are of size n. | 90 * All input and output arrays are of size n. |
87 */ | 91 */ |
88 static void inverse(unsigned int n, | 92 static void inverse(unsigned int n, |
89 const double *ri, const double *ii, | 93 const double *ri, const double *ii, |
90 double *ro, double *io); | 94 double *ro, double *io); |
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 /** | |
112 * Prepare to calculate transforms of size n. | |
113 * n must be a multiple of 2. | |
114 */ | |
115 FFTComplex(unsigned int n); | |
116 | |
117 ~FFTComplex(); | |
118 | |
119 /** | |
120 * Calculate a forward transform of size n. | |
121 * | |
122 * ci must point to the interleaved complex input data of size n | |
123 * (that is, 2n doubles in total). | |
124 * | |
125 * co must point to enough space to receive an interleaved complex | |
126 * output array of size n (that is, 2n doubles in total). | |
127 */ | |
128 void forward(const double *ci, double *co); | |
129 | |
130 /** | |
131 * Calculate an inverse transform of size n. | |
132 * | |
133 * ci must point to an interleaved complex input array of size n | |
134 * (that is, 2n doubles in total). | |
135 * | |
136 * co must point to enough space to receive the interleaved | |
137 * complex output data of size n (that is, 2n doubles in | |
138 * total). The output is scaled by 1/n. | |
139 */ | |
140 void inverse(const double *ci, double *co); | |
141 | |
142 private: | |
143 class D; | |
144 D *m_d; | |
91 }; | 145 }; |
92 | 146 |
93 /** | 147 /** |
94 * A simple FFT implementation provided for convenience of plugin | 148 * A simple FFT implementation provided for convenience of plugin |
95 * authors. This class provides transforms between double-precision | 149 * authors. This class provides transforms between double-precision |
96 * real time-domain and double-precision complex frequency-domain | 150 * real time-domain and double-precision complex frequency-domain |
97 * data. | 151 * data. |
98 * | 152 * |
153 * Note: If the SDK has been compiled with the SINGLE_PRECISION_FFT | |
154 * flag, then all FFTs will use single precision internally. The | |
155 * default is double precision. The API uses doubles in either case. | |
156 * | |
99 * The forward transform is unscaled; the inverse transform is scaled | 157 * The forward transform is unscaled; the inverse transform is scaled |
100 * by 1/n. | 158 * by 1/n. |
101 */ | 159 */ |
102 class FFTReal | 160 class FFTReal |
103 { | 161 { |
104 /** | 162 /** |
105 * Prepare to calculate transforms of size n. | 163 * Prepare to calculate transforms of size n. |
106 * n must be a power of 2, greater than 1. | 164 * n must be a multiple of 2. |
107 */ | 165 */ |
108 FFTReal(unsigned int n); | 166 FFTReal(unsigned int n); |
109 | 167 |
110 ~FFTReal(); | 168 ~FFTReal(); |
111 | 169 |
113 * Calculate a forward transform of size n. | 171 * Calculate a forward transform of size n. |
114 * | 172 * |
115 * ri must point to the real input data of size n. | 173 * ri must point to the real input data of size n. |
116 * | 174 * |
117 * co must point to enough space to receive an interleaved complex | 175 * co must point to enough space to receive an interleaved complex |
118 * output array of size n/2+1. | 176 * output array of size n/2+1 (that is, n+2 doubles in total). |
119 */ | 177 */ |
120 void forward(const double *ri, double *co); | 178 void forward(const double *ri, double *co); |
121 | 179 |
122 /** | 180 /** |
123 * Calculate an inverse transform of size n. | 181 * Calculate an inverse transform of size n. |
124 * | 182 * |
125 * ci must point to an interleaved complex input array of size n/2+1. | 183 * ci must point to an interleaved complex input array of size |
184 * n/2+1 (that is, n+2 doubles in total). | |
126 * | 185 * |
127 * ro must point to enough space to receive the real output data | 186 * ro must point to enough space to receive the real output data |
128 * of size n. The output is scaled by 1/n and only the real part | 187 * of size n. The output is scaled by 1/n and only the real part |
129 * is returned. | 188 * is returned. |
130 */ | 189 */ |