Changeset e744416 for src


Ignore:
Timestamp:
Nov 26, 2018, 5:21:30 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:
5ad5109
Parents:
d050d02
Message:

[mfcc] remove plain dct ifdefs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/spectral/mfcc.c

    rd050d02 re744416  
    3232#include "spectral/mfcc.h"
    3333
    34 #ifdef HAVE_NOOPT
    35 #define HAVE_SLOW_DCT 1
    36 #endif
    37 
    3834/** Internal structure for mfcc object */
    3935
     
    4642  aubio_filterbank_t *fb;   /** filter bank */
    4743  fvec_t *in_dct;           /** input buffer for dct * [fb->n_filters] */
    48 #if defined(HAVE_SLOW_DCT)
    49   fmat_t *dct_coeffs;       /** DCT transform n_filters * n_coeffs */
    50 #else
    51   aubio_dct_t *dct;
    52   fvec_t *output;
    53 #endif
     44  aubio_dct_t *dct;         /** dct object */
     45  fvec_t *output;           /** dct output */
    5446  smpl_t scale;
    5547};
     
    6355  /* allocate space for mfcc object */
    6456  aubio_mfcc_t *mfcc = AUBIO_NEW (aubio_mfcc_t);
    65 #if defined(HAVE_SLOW_DCT)
    66   smpl_t scaling;
    67 
    68   uint_t i, j;
    69 #endif
    7057
    7158  mfcc->win_s = win_s;
     
    8572  mfcc->in_dct = new_fvec (n_filters);
    8673
    87 #if defined(HAVE_SLOW_DCT)
    88   mfcc->dct_coeffs = new_fmat (n_coefs, n_filters);
    89 
    90   /* compute DCT transform dct_coeffs[j][i] as
    91      cos ( j * (i+.5) * PI / n_filters ) */
    92   scaling = 1. / SQRT (n_filters / 2.);
    93   for (i = 0; i < n_filters; i++) {
    94     for (j = 0; j < n_coefs; j++) {
    95       mfcc->dct_coeffs->data[j][i] =
    96           scaling * COS (j * (i + 0.5) * PI / n_filters);
    97     }
    98     mfcc->dct_coeffs->data[0][i] *= SQRT (2.) / 2.;
    99   }
    100 #else
    10174  mfcc->dct = new_aubio_dct (n_filters);
    10275  mfcc->output = new_fvec (n_filters);
    103 #endif
    10476
    10577  mfcc->scale = 1.;
     
    11789  /* delete buffers */
    11890  del_fvec (mf->in_dct);
    119 #if defined(HAVE_SLOW_DCT)
    120   del_fmat (mf->dct_coeffs);
    121 #else
    12291  del_aubio_dct (mf->dct);
    12392  del_fvec (mf->output);
    124 #endif
    12593
    12694  /* delete mfcc object */
     
    132100aubio_mfcc_do (aubio_mfcc_t * mf, const cvec_t * in, fvec_t * out)
    133101{
    134 #ifndef HAVE_SLOW_DCT
    135102  fvec_t tmp;
    136 #endif
    137103
    138104  /* compute filterbank */
     
    145111
    146112  /* compute mfccs */
    147 #if defined(HAVE_SLOW_DCT)
    148   fmat_vecmul(mf->dct_coeffs, mf->in_dct, out);
    149 #else
    150113  aubio_dct_do(mf->dct, mf->in_dct, mf->output);
    151114  // copy only first n_coeffs elements
     
    154117  tmp.length = out->length;
    155118  fvec_copy(&tmp, out);
    156 #endif
    157119
    158120  return;
Note: See TracChangeset for help on using the changeset viewer.