annotate vamp-sdk/FFT.h @ 526:459cddd7e64a c++11-mutex

Switch from C++98 to C++11
author Chris Cannam
date Wed, 11 Sep 2019 14:30:14 +0100
parents aadfe19a0e94
children
rev   line source
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@446 50 * an FFTComplex or FFTReal object instead.
Chris@446 51 *
Chris@446 52 * Note: If the SDK has been compiled with the SINGLE_PRECISION_FFT
Chris@446 53 * flag, then all FFTs will use single precision internally. The
Chris@446 54 * default is double precision. The API uses doubles in either case.
Chris@337 55 *
Chris@434 56 * The forward transform is unscaled; the inverse transform is scaled
Chris@434 57 * by 1/n.
Chris@337 58 */
Chris@337 59 class FFT
Chris@337 60 {
Chris@337 61 public:
Chris@337 62 /**
Chris@434 63 * Calculate a one-shot forward transform of size n.
Chris@446 64 * n must be a multiple of 2.
Chris@337 65 *
Chris@337 66 * ri and ii must point to the real and imaginary component arrays
Chris@337 67 * of the input. For real input, ii may be NULL.
Chris@337 68 *
Chris@337 69 * ro and io must point to enough space to receive the real and
Chris@337 70 * imaginary component arrays of the output.
Chris@337 71 *
Chris@337 72 * All input and output arrays are of size n.
Chris@337 73 */
Chris@338 74 static void forward(unsigned int n,
Chris@338 75 const double *ri, const double *ii,
Chris@338 76 double *ro, double *io);
Chris@337 77
Chris@337 78 /**
Chris@434 79 * Calculate a one-shot inverse transform of size n.
Chris@394 80 * n must be a power of 2, greater than 1.
Chris@337 81 *
Chris@337 82 * ri and ii must point to the real and imaginary component arrays
Chris@337 83 * of the input. For real input, ii may be NULL.
Chris@337 84 *
Chris@337 85 * ro and io must point to enough space to receive the real and
Chris@337 86 * imaginary component arrays of the output. The output is scaled
Chris@337 87 * by 1/n. The output pointers may not be NULL, even if the output
Chris@337 88 * is expected to be real.
Chris@337 89 *
Chris@337 90 * All input and output arrays are of size n.
Chris@337 91 */
Chris@338 92 static void inverse(unsigned int n,
Chris@338 93 const double *ri, const double *ii,
Chris@338 94 double *ro, double *io);
Chris@337 95 };
Chris@337 96
Chris@434 97 /**
Chris@434 98 * A simple FFT implementation provided for convenience of plugin
Chris@446 99 * authors. This class provides double-precision complex-complex
Chris@446 100 * transforms.
Chris@446 101 *
Chris@446 102 * Note: If the SDK has been compiled with the SINGLE_PRECISION_FFT
Chris@446 103 * flag, then all FFTs will use single precision internally. The
Chris@446 104 * default is double precision. The API uses doubles in either case.
Chris@446 105 *
Chris@446 106 * The forward transform is unscaled; the inverse transform is scaled
Chris@446 107 * by 1/n.
Chris@446 108 */
Chris@446 109 class FFTComplex
Chris@446 110 {
Chris@448 111 public:
Chris@446 112 /**
Chris@446 113 * Prepare to calculate transforms of size n.
Chris@446 114 * n must be a multiple of 2.
Chris@446 115 */
Chris@446 116 FFTComplex(unsigned int n);
Chris@446 117
Chris@446 118 ~FFTComplex();
Chris@446 119
Chris@446 120 /**
Chris@446 121 * Calculate a forward transform of size n.
Chris@446 122 *
Chris@446 123 * ci must point to the interleaved complex input data of size n
Chris@446 124 * (that is, 2n doubles in total).
Chris@446 125 *
Chris@446 126 * co must point to enough space to receive an interleaved complex
Chris@446 127 * output array of size n (that is, 2n doubles in total).
Chris@446 128 */
Chris@446 129 void forward(const double *ci, double *co);
Chris@446 130
Chris@446 131 /**
Chris@446 132 * Calculate an inverse transform of size n.
Chris@446 133 *
Chris@446 134 * ci must point to an interleaved complex input array of size n
Chris@446 135 * (that is, 2n doubles in total).
Chris@446 136 *
Chris@446 137 * co must point to enough space to receive the interleaved
Chris@446 138 * complex output data of size n (that is, 2n doubles in
Chris@446 139 * total). The output is scaled by 1/n.
Chris@446 140 */
Chris@446 141 void inverse(const double *ci, double *co);
Chris@446 142
Chris@446 143 private:
Chris@446 144 class D;
Chris@446 145 D *m_d;
Chris@446 146 };
Chris@446 147
Chris@446 148 /**
Chris@446 149 * A simple FFT implementation provided for convenience of plugin
Chris@445 150 * authors. This class provides transforms between double-precision
Chris@445 151 * real time-domain and double-precision complex frequency-domain
Chris@445 152 * data.
Chris@434 153 *
Chris@446 154 * Note: If the SDK has been compiled with the SINGLE_PRECISION_FFT
Chris@446 155 * flag, then all FFTs will use single precision internally. The
Chris@446 156 * default is double precision. The API uses doubles in either case.
Chris@446 157 *
Chris@434 158 * The forward transform is unscaled; the inverse transform is scaled
Chris@434 159 * by 1/n.
Chris@434 160 */
Chris@434 161 class FFTReal
Chris@434 162 {
Chris@448 163 public:
Chris@434 164 /**
Chris@434 165 * Prepare to calculate transforms of size n.
Chris@446 166 * n must be a multiple of 2.
Chris@434 167 */
Chris@434 168 FFTReal(unsigned int n);
Chris@434 169
Chris@434 170 ~FFTReal();
Chris@434 171
Chris@434 172 /**
Chris@434 173 * Calculate a forward transform of size n.
Chris@434 174 *
Chris@434 175 * ri must point to the real input data of size n.
Chris@434 176 *
Chris@434 177 * co must point to enough space to receive an interleaved complex
Chris@446 178 * output array of size n/2+1 (that is, n+2 doubles in total).
Chris@434 179 */
Chris@445 180 void forward(const double *ri, double *co);
Chris@434 181
Chris@434 182 /**
Chris@434 183 * Calculate an inverse transform of size n.
Chris@434 184 *
Chris@446 185 * ci must point to an interleaved complex input array of size
Chris@446 186 * n/2+1 (that is, n+2 doubles in total).
Chris@434 187 *
Chris@434 188 * ro must point to enough space to receive the real output data
Chris@434 189 * of size n. The output is scaled by 1/n and only the real part
Chris@434 190 * is returned.
Chris@434 191 */
Chris@445 192 void inverse(const double *ci, double *ro);
Chris@434 193
Chris@434 194 private:
Chris@434 195 class D;
Chris@434 196 D *m_d;
Chris@434 197 };
Chris@434 198
Chris@337 199 }
Chris@337 200
Chris@337 201 _VAMP_SDK_PLUGSPACE_END(FFT.h)
Chris@337 202
Chris@337 203 #endif