Changeset 8c4918a


Ignore:
Timestamp:
Sep 15, 2018, 6:27:35 PM (6 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master
Children:
3a8f0bf, 6203a70, d47ad546
Parents:
ad3770f (diff), 3aa60b2 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'feature/fastmfcc'

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/spectral/mfcc.c

    rad3770f r8c4918a  
    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 */
     
    103123aubio_mfcc_do (aubio_mfcc_t * mf, const cvec_t * in, fvec_t * out)
    104124{
     125#ifndef HAVE_SLOW_DCT
     126  fvec_t tmp;
     127#endif
    105128  /* compute filterbank */
    106129  aubio_filterbank_do (mf->fb, in, mf->in_dct);
     
    113136
    114137  /* compute mfccs */
     138#if defined(HAVE_SLOW_DCT)
    115139  fmat_vecmul(mf->dct_coeffs, mf->in_dct, out);
     140#else
     141  aubio_dct_do(mf->dct, mf->in_dct, mf->output);
     142  // copy only first n_coeffs elements
     143  // TODO assert mf->output->length == n_coeffs
     144  tmp.data = mf->output->data;
     145  tmp.length = out->length;
     146  fvec_copy(&tmp, out);
     147#endif
    116148
    117149  return;
Note: See TracChangeset for help on using the changeset viewer.