src/spectral/mfcc.c: swap dct_coeffs matrix to prepare for fmat_vecmul
authorPaul Brossier <piem@piem.org>
Tue, 16 Feb 2016 20:50:08 +0000 (21:50 +0100)
committerPaul Brossier <piem@piem.org>
Tue, 16 Feb 2016 20:50:08 +0000 (21:50 +0100)
src/spectral/mfcc.c

index a0e35be..ed99811 100644 (file)
@@ -67,17 +67,17 @@ new_aubio_mfcc (uint_t win_s, uint_t n_filters, uint_t n_coefs,
   /* allocating buffers */
   mfcc->in_dct = new_fvec (n_filters);
 
-  mfcc->dct_coeffs = new_fmat (n_filters, n_coefs);
+  mfcc->dct_coeffs = new_fmat (n_coefs, n_filters);
 
-  /* compute DCT transform dct_coeffs[i][j] as
+  /* compute DCT transform dct_coeffs[j][i] as
      cos ( j * (i+.5) * PI / n_filters ) */
   scaling = 1. / SQRT (n_filters / 2.);
   for (i = 0; i < n_filters; i++) {
     for (j = 0; j < n_coefs; j++) {
-      mfcc->dct_coeffs->data[i][j] =
+      mfcc->dct_coeffs->data[j][i] =
           scaling * COS (j * (i + 0.5) * PI / n_filters);
     }
-    mfcc->dct_coeffs->data[i][0] *= SQRT (2.) / 2.;
+    mfcc->dct_coeffs->data[0][i] *= SQRT (2.) / 2.;
   }
 
   return mfcc;
@@ -120,7 +120,7 @@ aubio_mfcc_do (aubio_mfcc_t * mf, cvec_t * in, fvec_t * out)
   for (j = 0; j < mf->n_filters; j++) {
     for (k = 0; k < mf->n_coefs; k++) {
       out->data[k] += mf->in_dct->data[j]
-          * mf->dct_coeffs->data[j][k];
+          * mf->dct_coeffs->data[k][j];
     }
   }