comparison dsp/mfcc/MFCC.cpp @ 289:befe5aa6b450

* Refactor FFT a little bit so as to separate construction and processing rather than have a single static method -- will make it easier to use a different implementation * pull in KissFFT implementation (not hooked up yet)
author Chris Cannam <c.cannam@qmul.ac.uk>
date Wed, 13 May 2009 09:19:12 +0000
parents 330c2e11f8a9
children d5014ab8b0e5
comparison
equal deleted inserted replaced
288:86c70067c723 289:befe5aa6b450
29 logFilters = 27; 29 logFilters = 27;
30 logSpacing = 1.0711703; 30 logSpacing = 1.0711703;
31 31
32 /* FFT and analysis window sizes */ 32 /* FFT and analysis window sizes */
33 fftSize = config.fftsize; 33 fftSize = config.fftsize;
34 fft = new FFTReal(fftSize);
34 35
35 totalFilters = linearFilters + logFilters; 36 totalFilters = linearFilters + logFilters;
36 logPower = config.logpower; 37 logPower = config.logpower;
37 38
38 samplingRate = config.FS; 39 samplingRate = config.FS;
143 144
144 /* The analysis window */ 145 /* The analysis window */
145 window = new Window<double>(config.window, fftSize); 146 window = new Window<double>(config.window, fftSize);
146 147
147 /* Allocate memory for the FFT */ 148 /* Allocate memory for the FFT */
148 imagIn = (double*)calloc(fftSize, sizeof(double));
149 realOut = (double*)calloc(fftSize, sizeof(double)); 149 realOut = (double*)calloc(fftSize, sizeof(double));
150 imagOut = (double*)calloc(fftSize, sizeof(double)); 150 imagOut = (double*)calloc(fftSize, sizeof(double));
151 151
152 earMag = (double*)calloc(totalFilters, sizeof(double)); 152 earMag = (double*)calloc(totalFilters, sizeof(double));
153 fftMag = (double*)calloc(fftSize/2, sizeof(double)); 153 fftMag = (double*)calloc(fftSize/2, sizeof(double));
183 183
184 free(earMag); 184 free(earMag);
185 free(fftMag); 185 free(fftMag);
186 186
187 /* Free the FFT */ 187 /* Free the FFT */
188 free(imagIn);
189 free(realOut); 188 free(realOut);
190 free(imagOut); 189 free(imagOut);
190
191 delete fft;
191 } 192 }
192 193
193 194
194 /* 195 /*
195 * 196 *
202 for (int i = 0; i < fftSize; ++i) inputData[i] = inframe[i]; 203 for (int i = 0; i < fftSize; ++i) inputData[i] = inframe[i];
203 204
204 window->cut(inputData); 205 window->cut(inputData);
205 206
206 /* Calculate the fft on the input frame */ 207 /* Calculate the fft on the input frame */
207 FFT::process(fftSize, 0, inputData, imagIn, realOut, imagOut); 208 fft->process(0, inputData, realOut, imagOut);
208 209
209 free(inputData); 210 free(inputData);
210 211
211 return process(realOut, imagOut, outceps); 212 return process(realOut, imagOut, outceps);
212 } 213 }