comparison vamp-sdk/FFT.h @ 434:e979a9c4ffb6 vampipe

Switch from Cross FFT with option of FFTW build, to KissFFT only (code bundled). This is much faster than the default build and simpler than managing two options.
author Chris Cannam
date Tue, 16 Aug 2016 16:04:09 +0100
parents a69901aa85d2
children 7f7a10bcaff1
comparison
equal deleted inserted replaced
432:8dea61e4a7be 434:e979a9c4ffb6
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 * a FFTReal object instead.
51 * implementations. If these requirements aren't suitable, make other
52 * arrangements.
53 * 51 *
54 * The inverse transform is scaled by 1/n. 52 * The forward transform is unscaled; the inverse transform is scaled
55 * 53 * by 1/n.
56 * The implementation is from Don Cross's public domain FFT code.
57 */ 54 */
58 class FFT 55 class FFT
59 { 56 {
60 public: 57 public:
61 /** 58 /**
62 * Calculate a forward transform of size n. 59 * Calculate a one-shot forward transform of size n.
63 * n must be a power of 2, greater than 1. 60 * n must be a power of 2, greater than 1.
64 * 61 *
65 * ri and ii must point to the real and imaginary component arrays 62 * ri and ii must point to the real and imaginary component arrays
66 * of the input. For real input, ii may be NULL. 63 * of the input. For real input, ii may be NULL.
67 * 64 *
73 static void forward(unsigned int n, 70 static void forward(unsigned int n,
74 const double *ri, const double *ii, 71 const double *ri, const double *ii,
75 double *ro, double *io); 72 double *ro, double *io);
76 73
77 /** 74 /**
78 * Calculate an inverse transform of size n. 75 * Calculate a one-shot inverse transform of size n.
79 * n must be a power of 2, greater than 1. 76 * n must be a power of 2, greater than 1.
80 * 77 *
81 * ri and ii must point to the real and imaginary component arrays 78 * ri and ii must point to the real and imaginary component arrays
82 * of the input. For real input, ii may be NULL. 79 * of the input. For real input, ii may be NULL.
83 * 80 *
91 static void inverse(unsigned int n, 88 static void inverse(unsigned int n,
92 const double *ri, const double *ii, 89 const double *ri, const double *ii,
93 double *ro, double *io); 90 double *ro, double *io);
94 }; 91 };
95 92
93 /**
94 * A simple FFT implementation provided for convenience of plugin
95 * authors. This class provides transforms between real
96 * single-precision time-domain and complex single-precision
97 * frequency-domain data.
98 *
99 * The forward transform is unscaled; the inverse transform is scaled
100 * by 1/n.
101 */
102 class FFTReal
103 {
104 /**
105 * Prepare to calculate transforms of size n.
106 * n must be a power of 2, greater than 1.
107 */
108 FFTReal(unsigned int n);
109
110 ~FFTReal();
111
112 /**
113 * Calculate a forward transform of size n.
114 *
115 * ri must point to the real input data of size n.
116 *
117 * co must point to enough space to receive an interleaved complex
118 * output array of size n/2+1.
119 */
120 void forward(const float *ri, float *co);
121
122 /**
123 * Calculate an inverse transform of size n.
124 *
125 * ci must point to an interleaved complex input array of size n/2+1.
126 *
127 * 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
129 * is returned.
130 */
131 void inverse(const float *ci, float *ro);
132
133 private:
134 class D;
135 D *m_d;
136 };
137
96 } 138 }
97 139
98 _VAMP_SDK_PLUGSPACE_END(FFT.h) 140 _VAMP_SDK_PLUGSPACE_END(FFT.h)
99 141
100 #endif 142 #endif