Changes in / [ad3770f:c9ca2608]


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/spectral/mfcc.c

    rad3770f rc9ca2608  
    2929#include "spectral/filterbank.h"
    3030#include "spectral/filterbank_mel.h"
     31#include "spectral/dct.h"
    3132#include "spectral/mfcc.h"
     33
     34#undef HAVE_SLOW_DCT
    3235
    3336/** Internal structure for mfcc object */
     
    4144  aubio_filterbank_t *fb;   /** filter bank */
    4245  fvec_t *in_dct;           /** input buffer for dct * [fb->n_filters] */
     46#if defined(HAVE_SLOW_DCT)
    4347  fmat_t *dct_coeffs;       /** DCT transform n_filters * n_coeffs */
     48#else
     49  aubio_dct_t *dct;
     50  fvec_t *output;
     51#endif
    4452};
    4553
     
    5260  /* allocate space for mfcc object */
    5361  aubio_mfcc_t *mfcc = AUBIO_NEW (aubio_mfcc_t);
     62#if defined(HAVE_SLOW_DCT)
    5463  smpl_t scaling;
    5564
    5665  uint_t i, j;
     66#endif
    5767
    5868  mfcc->win_s = win_s;
     
    6878  mfcc->in_dct = new_fvec (n_filters);
    6979
     80#if defined(HAVE_SLOW_DCT)
    7081  mfcc->dct_coeffs = new_fmat (n_coefs, n_filters);
    7182
     
    8091    mfcc->dct_coeffs->data[0][i] *= SQRT (2.) / 2.;
    8192  }
     93#else
     94  mfcc->dct = new_aubio_dct (n_filters);
     95  mfcc->output = new_fvec (n_filters);
     96#endif
    8297
    8398  return mfcc;
     
    93108  /* delete buffers */
    94109  del_fvec (mf->in_dct);
     110#if defined(HAVE_SLOW_DCT)
    95111  del_fmat (mf->dct_coeffs);
     112#else
     113  del_aubio_dct (mf->dct);
     114  del_fvec (mf->output);
     115#endif
    96116
    97117  /* delete mfcc object */
     
    113133
    114134  /* compute mfccs */
     135#if defined(HAVE_SLOW_DCT)
    115136  fmat_vecmul(mf->dct_coeffs, mf->in_dct, out);
     137#else
     138  aubio_dct_do(mf->dct, mf->in_dct, mf->output);
     139  // copy only first n_coeffs elements
     140  // TODO assert mf->output->length == n_coeffs
     141  fvec_t tmp;
     142  tmp.data = mf->output->data;
     143  tmp.length = out->length;
     144  fvec_copy(&tmp, out);
     145#endif
    116146
    117147  return;
Note: See TracChangeset for help on using the changeset viewer.