Mercurial > hg > qm-dsp
comparison dsp/mfcc/MFCC.cpp @ 254:52c1a295d775
...
author | Chris Cannam <c.cannam@qmul.ac.uk> |
---|---|
date | Wed, 16 Jan 2008 18:02:31 +0000 |
parents | c3600d3cfe5c |
children | 9edaa3ce62e8 |
comparison
equal
deleted
inserted
replaced
253:501b1c09734d | 254:52c1a295d775 |
---|---|
122 | 122 |
123 /* | 123 /* |
124 * We calculate now mfccDCT matrix | 124 * We calculate now mfccDCT matrix |
125 * NB: +1 because of the DC component | 125 * NB: +1 because of the DC component |
126 */ | 126 */ |
127 | |
128 const double pi = 3.14159265358979323846264338327950288; | |
127 | 129 |
128 for (i=0; i<nceps+1; i++) { | 130 for (i=0; i<nceps+1; i++) { |
129 for (j=0; j<totalFilters; j++) { | 131 for (j=0; j<totalFilters; j++) { |
130 mfccDCTMatrix[i][j] = (1./sqrt((double) totalFilters / 2.)) | 132 mfccDCTMatrix[i][j] = (1./sqrt((double) totalFilters / 2.)) |
131 * cos((double) i * ((double) j + 0.5) / (double) totalFilters * M_PI); | 133 * cos((double) i * ((double) j + 0.5) / (double) totalFilters * pi); |
132 } | 134 } |
133 } | 135 } |
134 | 136 |
135 for (j=0;j<totalFilters;j++){ | 137 for (j=0;j<totalFilters;j++){ |
136 mfccDCTMatrix[0][j] = (sqrt(2.)/2.) * mfccDCTMatrix[0][j]; | 138 mfccDCTMatrix[0][j] = (sqrt(2.)/2.) * mfccDCTMatrix[0][j]; |
203 fftMag = (double*)calloc(fftSize, sizeof(double)); | 205 fftMag = (double*)calloc(fftSize, sizeof(double)); |
204 | 206 |
205 /* Zero-pad if needed */ | 207 /* Zero-pad if needed */ |
206 memcpy(inputData, inframe, length*sizeof(double)); | 208 memcpy(inputData, inframe, length*sizeof(double)); |
207 | 209 |
208 window->cut(inputData); | 210 //!!! window->cut(inputData); |
209 | 211 |
210 /* Calculate the fft on the input frame */ | 212 /* Calculate the fft on the input frame */ |
211 FFT::process(fftSize, 0, inputData, imagIn, realOut, imagOut); | 213 FFT::process(fftSize, 0, inputData, imagIn, realOut, imagOut); |
212 | 214 |
213 for (i = 0; i < fftSize; ++i) { | 215 for (i = 0; i < fftSize; ++i) { |