Changeset c03d191 for src/spectral


Ignore:
Timestamp:
Nov 17, 2018, 10:19:27 PM (6 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/constantq
Children:
d1d4ad4
Parents:
088760e (diff), a114fe0 (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 'master' into feature/constantq

Location:
src/spectral
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • src/spectral/fft.c

    r088760e rc03d191  
    9090#define aubio_vDSP_vsadd               vDSP_vsadd
    9191#define aubio_vDSP_vsmul               vDSP_vsmul
    92 #define aubio_vDSP_create_fftsetup     vDSP_create_fftsetup
    93 #define aubio_vDSP_destroy_fftsetup    vDSP_destroy_fftsetup
    9492#define aubio_DSPComplex               DSPComplex
    9593#define aubio_DSPSplitComplex          DSPSplitComplex
    96 #define aubio_FFTSetup                 FFTSetup
     94#define aubio_vDSP_DFT_Setup           vDSP_DFT_Setup
     95#define aubio_vDSP_DFT_zrop_CreateSetup vDSP_DFT_zrop_CreateSetup
     96#define aubio_vDSP_DFT_Execute         vDSP_DFT_Execute
     97#define aubio_vDSP_DFT_DestroySetup    vDSP_DFT_DestroySetup
    9798#define aubio_vvsqrt                   vvsqrtf
    9899#else
     
    104105#define aubio_vDSP_vsadd               vDSP_vsaddD
    105106#define aubio_vDSP_vsmul               vDSP_vsmulD
    106 #define aubio_vDSP_create_fftsetup     vDSP_create_fftsetupD
    107 #define aubio_vDSP_destroy_fftsetup    vDSP_destroy_fftsetupD
    108107#define aubio_DSPComplex               DSPDoubleComplex
    109108#define aubio_DSPSplitComplex          DSPDoubleSplitComplex
    110 #define aubio_FFTSetup                 FFTSetupD
     109#define aubio_vDSP_DFT_Setup           vDSP_DFT_SetupD
     110#define aubio_vDSP_DFT_zrop_CreateSetup vDSP_DFT_zrop_CreateSetupD
     111#define aubio_vDSP_DFT_Execute         vDSP_DFT_ExecuteD
     112#define aubio_vDSP_DFT_DestroySetup    vDSP_DFT_DestroySetupD
    111113#define aubio_vvsqrt                   vvsqrt
    112114#endif /* HAVE_AUBIO_DOUBLE */
     
    153155
    154156#elif defined HAVE_ACCELERATE  // using ACCELERATE
    155   int log2fftsize;
    156   aubio_FFTSetup fftSetup;
     157  aubio_vDSP_DFT_Setup fftSetupFwd;
     158  aubio_vDSP_DFT_Setup fftSetupBwd;
    157159  aubio_DSPSplitComplex spec;
    158160  smpl_t *in, *out;
     
    211213
    212214#elif defined HAVE_ACCELERATE  // using ACCELERATE
     215  {
     216    uint_t radix = winsize;
     217    uint_t order = 0;
     218    while ((radix / 2) * 2 == radix) {
     219      radix /= 2;
     220      order++;
     221    }
     222    if (order < 4 || (radix != 1 && radix != 3 && radix != 5 && radix != 15)) {
     223      AUBIO_ERR("fft: vDSP/Accelerate supports FFT with sizes = "
     224          "f * 2 ** n, where n > 4 and f in [1, 3, 5, 15], but requested %d. "
     225          "Use the closest power of two, or try recompiling aubio with "
     226          "--enable-fftw3.\n", winsize);
     227      goto beach;
     228    }
     229  }
    213230  s->winsize = winsize;
    214231  s->fft_size = winsize;
    215232  s->compspec = new_fvec(winsize);
    216   s->log2fftsize = aubio_power_of_two_order(s->fft_size);
    217233  s->in = AUBIO_ARRAY(smpl_t, s->fft_size);
    218234  s->out = AUBIO_ARRAY(smpl_t, s->fft_size);
    219235  s->spec.realp = AUBIO_ARRAY(smpl_t, s->fft_size/2);
    220236  s->spec.imagp = AUBIO_ARRAY(smpl_t, s->fft_size/2);
    221   s->fftSetup = aubio_vDSP_create_fftsetup(s->log2fftsize, FFT_RADIX2);
     237  s->fftSetupFwd = aubio_vDSP_DFT_zrop_CreateSetup(NULL,
     238      s->fft_size, vDSP_DFT_FORWARD);
     239  s->fftSetupBwd = aubio_vDSP_DFT_zrop_CreateSetup(s->fftSetupFwd,
     240      s->fft_size, vDSP_DFT_INVERSE);
    222241
    223242#elif defined HAVE_INTEL_IPP  // using Intel IPP
     
    293312  AUBIO_FREE(s->spec.realp);
    294313  AUBIO_FREE(s->spec.imagp);
    295   aubio_vDSP_destroy_fftsetup(s->fftSetup);
     314  aubio_vDSP_DFT_DestroySetup(s->fftSetupBwd);
     315  aubio_vDSP_DFT_DestroySetup(s->fftSetupFwd);
    296316
    297317#elif defined HAVE_INTEL_IPP  // using Intel IPP
     
    351371  aubio_vDSP_ctoz((aubio_DSPComplex*)s->in, 2, &s->spec, 1, s->fft_size/2);
    352372  // compute the FFT
    353   aubio_vDSP_fft_zrip(s->fftSetup, &s->spec, 1, s->log2fftsize, FFT_FORWARD);
     373  aubio_vDSP_DFT_Execute(s->fftSetupFwd, s->spec.realp, s->spec.imagp,
     374      s->spec.realp, s->spec.imagp);
    354375  // convert from vDSP complex split to [ r0, r1, ..., rN, iN-1, .., i2, i1]
    355376  compspec->data[0] = s->spec.realp[0];
     
    419440  aubio_vDSP_ctoz((aubio_DSPComplex*)s->out, 2, &s->spec, 1, s->fft_size/2);
    420441  // compute the FFT
    421   aubio_vDSP_fft_zrip(s->fftSetup, &s->spec, 1, s->log2fftsize, FFT_INVERSE);
     442  aubio_vDSP_DFT_Execute(s->fftSetupBwd, s->spec.realp, s->spec.imagp,
     443      s->spec.realp, s->spec.imagp);
    422444  // convert result to real output
    423445  aubio_vDSP_ztoc(&s->spec, 1, (aubio_DSPComplex*)output->data, 2, s->fft_size/2);
     
    494516  }
    495517#endif
    496   if (compspec->data[compspec->length/2] < 0) {
    497     spectrum->phas[spectrum->length - 1] = PI;
     518#ifdef HAVE_FFTW3
     519  // for even length only, make sure last element is 0 or PI
     520  if (2 * (compspec->length / 2) == compspec->length) {
     521#endif
     522    if (compspec->data[compspec->length/2] < 0) {
     523      spectrum->phas[spectrum->length - 1] = PI;
     524    } else {
     525      spectrum->phas[spectrum->length - 1] = 0.;
     526    }
     527#ifdef HAVE_FFTW3
    498528  } else {
    499     spectrum->phas[spectrum->length - 1] = 0.;
    500   }
     529    i = spectrum->length - 1;
     530    spectrum->phas[i] = ATAN2(compspec->data[compspec->length-i],
     531        compspec->data[i]);
     532  }
     533#endif
    501534}
    502535
     
    508541        + SQR(compspec->data[compspec->length - i]) );
    509542  }
    510   spectrum->norm[spectrum->length-1] =
    511     ABS(compspec->data[compspec->length/2]);
     543#ifdef HAVE_FFTW3
     544  // for even length, make sure last element is > 0
     545  if (2 * (compspec->length / 2) == compspec->length) {
     546#endif
     547    spectrum->norm[spectrum->length-1] =
     548      ABS(compspec->data[compspec->length/2]);
     549#ifdef HAVE_FFTW3
     550  } else {
     551    i = spectrum->length - 1;
     552    spectrum->norm[i] = SQRT(SQR(compspec->data[i])
     553        + SQR(compspec->data[compspec->length - i]) );
     554  }
     555#endif
    512556}
    513557
  • src/spectral/filterbank.c

    r088760e rc03d191  
    2424#include "fmat.h"
    2525#include "cvec.h"
     26#include "vecutils.h"
    2627#include "spectral/filterbank.h"
    2728#include "mathutils.h"
     
    3334  uint_t n_filters;
    3435  fmat_t *filters;
     36  smpl_t norm;
     37  smpl_t power;
    3538};
    3639
     
    4548  /* allocate filter tables, a matrix of length win_s and of height n_filters */
    4649  fb->filters = new_fmat (n_filters, win_s / 2 + 1);
     50
     51  fb->norm = 1;
     52
     53  fb->power = 1;
    4754
    4855  return fb;
     
    6875  tmp.data = in->norm;
    6976
     77  if (f->power != 1.) fvec_pow(&tmp, f->power);
     78
    7079  fmat_vecmul(f->filters, &tmp, out);
    7180
     
    8594  return 0;
    8695}
     96
     97uint_t
     98aubio_filterbank_set_norm (aubio_filterbank_t *f, smpl_t norm)
     99{
     100  if (norm != 0 && norm != 1) return AUBIO_FAIL;
     101  f->norm = norm;
     102  return AUBIO_OK;
     103}
     104
     105smpl_t
     106aubio_filterbank_get_norm (aubio_filterbank_t *f)
     107{
     108  return f->norm;
     109}
     110
     111uint_t
     112aubio_filterbank_set_power (aubio_filterbank_t *f, smpl_t power)
     113{
     114  f->power = power;
     115  return AUBIO_OK;
     116}
     117
     118smpl_t
     119aubio_filterbank_get_power (aubio_filterbank_t *f)
     120{
     121  return f->norm;
     122}
  • src/spectral/filterbank.h

    r088760e rc03d191  
    8484uint_t aubio_filterbank_set_coeffs (aubio_filterbank_t * f, const fmat_t * filters);
    8585
     86/** set norm parameter
     87
     88  \param f filterbank object, as returned by new_aubio_filterbank()
     89  \param norm `1` to norm the filters, `0` otherwise.
     90
     91  If set to `0`, the filters will not be normalized. If set to `1`,
     92  each filter will be normalized to one. Defaults to `1`.
     93
     94  This function should be called *before* setting the filters with one of
     95  aubio_filterbank_set_triangle_bands(), aubio_filterbank_set_mel_coeffs(),
     96  aubio_filterbank_set_mel_coeffs_htk(), or
     97  aubio_filterbank_set_mel_coeffs_slaney().
     98
     99 */
     100uint_t aubio_filterbank_set_norm (aubio_filterbank_t *f, smpl_t norm);
     101
     102/** get norm parameter
     103
     104  \param f filterbank object, as returned by new_aubio_filterbank()
     105  \returns `1` if norm is set, `0` otherwise. Defaults to `1`.
     106
     107 */
     108smpl_t aubio_filterbank_get_norm (aubio_filterbank_t *f);
     109
     110/** set power parameter
     111
     112  \param f filterbank object, as returned by new_aubio_filterbank()
     113  \param power Raise norm of the input spectrum norm to this power before
     114  computing filterbank.  Defaults to `1`.
     115
     116 */
     117uint_t aubio_filterbank_set_power (aubio_filterbank_t *f, smpl_t power);
     118
     119/** get power parameter
     120
     121  \param f filterbank object, as returned by new_aubio_filterbank()
     122  \return current power parameter. Defaults to `1`.
     123
     124 */
     125smpl_t aubio_filterbank_get_power (aubio_filterbank_t *f);
     126
    86127#ifdef __cplusplus
    87128}
  • src/spectral/filterbank_mel.c

    r088760e rc03d191  
    5555  }
    5656
    57   if (freqs->data[freqs->length - 1] > samplerate / 2) {
    58     AUBIO_WRN ("Nyquist frequency is %fHz, but highest frequency band ends at \
    59 %fHz\n", samplerate / 2, freqs->data[freqs->length - 1]);
     57  for (fn = 0; fn < freqs->length; fn++) {
     58    if (freqs->data[fn] < 0) {
     59      AUBIO_ERR("filterbank_mel: freqs must contain only positive values.\n");
     60      return AUBIO_FAIL;
     61    } else if (freqs->data[fn] > samplerate / 2) {
     62      AUBIO_WRN("filterbank_mel: freqs should contain only "
     63          "values < samplerate / 2.\n");
     64    } else if (fn > 0 && freqs->data[fn] < freqs->data[fn-1]) {
     65      AUBIO_ERR("filterbank_mel: freqs should be a list of frequencies "
     66          "sorted from low to high, but freq[%d] < freq[%d-1]\n", fn, fn);
     67      return AUBIO_FAIL;
     68    } else if (fn > 0 && freqs->data[fn] == freqs->data[fn-1]) {
     69      AUBIO_WRN("filterbank_mel: set_triangle_bands received a list "
     70          "with twice the frequency %f\n", freqs->data[fn]);
     71    }
    6072  }
    6173
     
    7991
    8092  /* compute triangle heights so that each triangle has unit area */
    81   for (fn = 0; fn < n_filters; fn++) {
    82     triangle_heights->data[fn] =
    83         2. / (upper_freqs->data[fn] - lower_freqs->data[fn]);
     93  if (aubio_filterbank_get_norm(fb)) {
     94    for (fn = 0; fn < n_filters; fn++) {
     95      triangle_heights->data[fn] =
     96          2. / (upper_freqs->data[fn] - lower_freqs->data[fn]);
     97    }
     98  } else {
     99    fvec_ones (triangle_heights);
    84100  }
    85101
     
    92108  /* zeroing of all filters */
    93109  fmat_zeros (filters);
    94 
    95   if (fft_freqs->data[1] >= lower_freqs->data[0]) {
    96     /* - 1 to make sure we don't miss the smallest power of two */
    97     uint_t min_win_s =
    98         (uint_t) FLOOR (samplerate / lower_freqs->data[0]) - 1;
    99     AUBIO_WRN ("Lowest frequency bin (%.2fHz) is higher than lowest frequency \
    100 band (%.2f-%.2fHz). Consider increasing the window size from %d to %d.\n",
    101         fft_freqs->data[1], lower_freqs->data[0],
    102         upper_freqs->data[0], (win_s - 1) * 2,
    103         aubio_next_power_of_two (min_win_s));
    104   }
    105110
    106111  /* building each filter table */
     
    117122
    118123    /* compute positive slope step size */
    119     riseInc =
    120         triangle_heights->data[fn] /
    121         (center_freqs->data[fn] - lower_freqs->data[fn]);
     124    riseInc = triangle_heights->data[fn]
     125      / (center_freqs->data[fn] - lower_freqs->data[fn]);
    122126
    123127    /* compute coefficients in positive slope */
     
    133137
    134138    /* compute negative slope step size */
    135     downInc =
    136         triangle_heights->data[fn] /
    137         (upper_freqs->data[fn] - center_freqs->data[fn]);
     139    downInc = triangle_heights->data[fn]
     140      / (upper_freqs->data[fn] - center_freqs->data[fn]);
    138141
    139142    /* compute coefficents in negative slope */
     
    161164  del_fvec (fft_freqs);
    162165
    163   return 0;
     166  return AUBIO_OK;
    164167}
    165168
     
    168171    smpl_t samplerate)
    169172{
    170   uint_t retval;
    171 
    172173  /* Malcolm Slaney parameters */
    173   smpl_t lowestFrequency = 133.3333;
    174   smpl_t linearSpacing = 66.66666666;
    175   smpl_t logSpacing = 1.0711703;
    176 
    177   uint_t linearFilters = 13;
    178   uint_t logFilters = 27;
    179   uint_t n_filters = linearFilters + logFilters;
    180 
    181   uint_t fn;                    /* filter counter */
    182 
     174  const smpl_t lowestFrequency = 133.3333;
     175  const smpl_t linearSpacing = 66.66666666;
     176  const smpl_t logSpacing = 1.0711703;
     177
     178  const uint_t linearFilters = 13;
     179  const uint_t logFilters = 27;
     180  const uint_t n_filters = linearFilters + logFilters;
     181
     182  uint_t fn, retval;
    183183  smpl_t lastlinearCF;
    184184
    185185  /* buffers to compute filter frequencies */
    186   fvec_t *freqs = new_fvec (n_filters + 2);
     186  fvec_t *freqs;
     187
     188  if (samplerate <= 0) {
     189    AUBIO_ERR("filterbank: set_mel_coeffs_slaney samplerate should be > 0\n");
     190    return AUBIO_FAIL;
     191  }
     192
     193  freqs = new_fvec (n_filters + 2);
    187194
    188195  /* first step: fill all the linear filter frequencies */
     
    206213  return retval;
    207214}
     215
     216static uint_t aubio_filterbank_check_freqs (aubio_filterbank_t *fb UNUSED,
     217    smpl_t samplerate, smpl_t *freq_min, smpl_t *freq_max)
     218{
     219  if (samplerate <= 0) {
     220    AUBIO_ERR("filterbank: set_mel_coeffs samplerate should be > 0\n");
     221    return AUBIO_FAIL;
     222  }
     223  if (*freq_max < 0) {
     224    AUBIO_ERR("filterbank: set_mel_coeffs freq_max should be > 0\n");
     225    return AUBIO_FAIL;
     226  } else if (*freq_max == 0) {
     227    *freq_max = samplerate / 2.;
     228  }
     229  if (*freq_min < 0) {
     230    AUBIO_ERR("filterbank: set_mel_coeffs freq_min should be > 0\n");
     231    return AUBIO_FAIL;
     232  }
     233  return AUBIO_OK;
     234}
     235
     236uint_t
     237aubio_filterbank_set_mel_coeffs (aubio_filterbank_t * fb, smpl_t samplerate,
     238    smpl_t freq_min, smpl_t freq_max)
     239{
     240  uint_t m, retval;
     241  smpl_t start = freq_min, end = freq_max, step;
     242  fvec_t *freqs;
     243  fmat_t *coeffs = aubio_filterbank_get_coeffs(fb);
     244  uint_t n_bands = coeffs->height;
     245
     246  if (aubio_filterbank_check_freqs(fb, samplerate, &start, &end)) {
     247    return AUBIO_FAIL;
     248  }
     249
     250  start = aubio_hztomel(start);
     251  end = aubio_hztomel(end);
     252
     253  freqs = new_fvec(n_bands + 2);
     254  step = (end - start) / (n_bands + 1);
     255
     256  for (m = 0; m < n_bands + 2; m++)
     257  {
     258    freqs->data[m] = MIN(aubio_meltohz(start + step * m), samplerate/2.);
     259  }
     260
     261  retval = aubio_filterbank_set_triangle_bands (fb, freqs, samplerate);
     262
     263  /* destroy vector used to store frequency limits */
     264  del_fvec (freqs);
     265  return retval;
     266}
     267
     268uint_t
     269aubio_filterbank_set_mel_coeffs_htk (aubio_filterbank_t * fb, smpl_t samplerate,
     270    smpl_t freq_min, smpl_t freq_max)
     271{
     272  uint_t m, retval;
     273  smpl_t start = freq_min, end = freq_max, step;
     274  fvec_t *freqs;
     275  fmat_t *coeffs = aubio_filterbank_get_coeffs(fb);
     276  uint_t n_bands = coeffs->height;
     277
     278  if (aubio_filterbank_check_freqs(fb, samplerate, &start, &end)) {
     279    return AUBIO_FAIL;
     280  }
     281
     282  start = aubio_hztomel_htk(start);
     283  end = aubio_hztomel_htk(end);
     284
     285  freqs = new_fvec (n_bands + 2);
     286  step = (end - start) / (n_bands + 1);
     287
     288  for (m = 0; m < n_bands + 2; m++)
     289  {
     290    freqs->data[m] = MIN(aubio_meltohz_htk(start + step * m), samplerate/2.);
     291  }
     292
     293  retval = aubio_filterbank_set_triangle_bands (fb, freqs, samplerate);
     294
     295  /* destroy vector used to store frequency limits */
     296  del_fvec (freqs);
     297  return retval;
     298}
  • src/spectral/filterbank_mel.h

    r088760e rc03d191  
    5656
    5757  \param fb filterbank object
    58   \param samplerate audio sampling rate
     58  \param samplerate audio sampling rate, in Hz
    5959
    60   The filter coefficients are built according to Malcolm Slaney's Auditory
    61   Toolbox, available online at the following address (see file mfcc.m):
     60  The filter coefficients are built to match exactly Malcolm Slaney's Auditory
     61  Toolbox implementation (see file mfcc.m). The number of filters should be 40.
    6262
     63  References
     64  ----------
     65
     66  Malcolm Slaney, *Auditory Toolbox Version 2, Technical Report #1998-010*
    6367  https://engineering.purdue.edu/~malcolm/interval/1998-010/
    6468
     
    6771    smpl_t samplerate);
    6872
     73/** Mel filterbank initialization
     74
     75  \param fb filterbank object
     76  \param samplerate audio sampling rate
     77  \param fmin start frequency, in Hz
     78  \param fmax end frequency, in Hz
     79
     80  The filterbank will be initialized with bands linearly spaced in the mel
     81  scale, from `fmin` to `fmax`.
     82
     83  References
     84  ----------
     85
     86  Malcolm Slaney, *Auditory Toolbox Version 2, Technical Report #1998-010*
     87  https://engineering.purdue.edu/~malcolm/interval/1998-010/
     88
     89*/
     90uint_t aubio_filterbank_set_mel_coeffs(aubio_filterbank_t * fb,
     91    smpl_t samplerate, smpl_t fmin, smpl_t fmax);
     92
     93/** Mel filterbank initialization
     94
     95  \param fb filterbank object
     96  \param samplerate audio sampling rate
     97  \param fmin start frequency, in Hz
     98  \param fmax end frequency, in Hz
     99
     100  The bank of filters will be initalized to to cover linearly spaced bands in
     101  the Htk mel scale, from `fmin` to `fmax`.
     102
     103  References
     104  ----------
     105
     106  Douglas O'Shaughnessy (1987). *Speech communication: human and machine*.
     107  Addison-Wesley. p. 150. ISBN 978-0-201-16520-3.
     108
     109  HTK Speech Recognition Toolkit: http://htk.eng.cam.ac.uk/
     110
     111*/
     112uint_t aubio_filterbank_set_mel_coeffs_htk(aubio_filterbank_t * fb,
     113    smpl_t samplerate, smpl_t fmin, smpl_t fmax);
     114
    69115#ifdef __cplusplus
    70116}
  • src/spectral/mfcc.c

    r088760e rc03d191  
    5252  fvec_t *output;
    5353#endif
     54  smpl_t scale;
    5455};
    5556
     
    7576  /* filterbank allocation */
    7677  mfcc->fb = new_aubio_filterbank (n_filters, mfcc->win_s);
    77   aubio_filterbank_set_mel_coeffs_slaney (mfcc->fb, samplerate);
     78  if (n_filters == 40)
     79    aubio_filterbank_set_mel_coeffs_slaney (mfcc->fb, samplerate);
     80  else
     81    aubio_filterbank_set_mel_coeffs(mfcc->fb, samplerate,
     82        0, samplerate/2.);
    7883
    7984  /* allocating buffers */
     
    97102  mfcc->output = new_fvec (n_filters);
    98103#endif
     104
     105  mfcc->scale = 1.;
    99106
    100107  return mfcc;
     
    128135  fvec_t tmp;
    129136#endif
     137
    130138  /* compute filterbank */
    131139  aubio_filterbank_do (mf->fb, in, mf->in_dct);
     
    134142  fvec_log10 (mf->in_dct);
    135143
    136   /* raise power */
    137   //fvec_pow (mf->in_dct, 3.);
     144  if (mf->scale != 1) fvec_mul (mf->in_dct, mf->scale);
    138145
    139146  /* compute mfccs */
     
    151158  return;
    152159}
     160
     161uint_t aubio_mfcc_set_power (aubio_mfcc_t *mf, smpl_t power)
     162{
     163  return aubio_filterbank_set_power(mf->fb, power);
     164}
     165
     166uint_t aubio_mfcc_get_power (aubio_mfcc_t *mf)
     167{
     168  return aubio_filterbank_get_power(mf->fb);
     169}
     170
     171uint_t aubio_mfcc_set_scale (aubio_mfcc_t *mf, smpl_t scale)
     172{
     173  mf->scale = scale;
     174  return AUBIO_OK;
     175}
     176
     177uint_t aubio_mfcc_get_scale (aubio_mfcc_t *mf)
     178{
     179  return mf->scale;
     180}
     181
     182uint_t aubio_mfcc_set_mel_coeffs (aubio_mfcc_t *mf, smpl_t freq_min,
     183    smpl_t freq_max)
     184{
     185  return aubio_filterbank_set_mel_coeffs(mf->fb, mf->samplerate,
     186      freq_min, freq_max);
     187}
     188
     189uint_t aubio_mfcc_set_mel_coeffs_htk (aubio_mfcc_t *mf, smpl_t freq_min,
     190    smpl_t freq_max)
     191{
     192  return aubio_filterbank_set_mel_coeffs_htk(mf->fb, mf->samplerate,
     193      freq_min, freq_max);
     194}
     195
     196uint_t aubio_mfcc_set_mel_coeffs_slaney (aubio_mfcc_t *mf)
     197{
     198  return aubio_filterbank_set_mel_coeffs_slaney (mf->fb, mf->samplerate);
     199}
  • src/spectral/mfcc.h

    r088760e rc03d191  
    7474void aubio_mfcc_do (aubio_mfcc_t * mf, const cvec_t * in, fvec_t * out);
    7575
     76/** set power parameter
     77
     78  \param mf mfcc object, as returned by new_aubio_mfcc()
     79  \param power Raise norm of the input spectrum norm to this power before
     80  computing filterbank.  Defaults to `1`.
     81
     82  See aubio_filterbank_set_power().
     83
     84 */
     85uint_t aubio_mfcc_set_power (aubio_mfcc_t *mf, smpl_t power);
     86
     87/** get power parameter
     88
     89  \param mf mfcc object, as returned by new_aubio_mfcc()
     90  \return current power parameter. Defaults to `1`.
     91
     92  See aubio_filterbank_get_power().
     93
     94 */
     95uint_t aubio_mfcc_get_power (aubio_mfcc_t *mf);
     96
     97/** set scaling parameter
     98
     99  \param mf mfcc object, as returned by new_aubio_mfcc()
     100  \param scale Scaling value to apply.
     101
     102  Scales the output of the filterbank after taking its logarithm and before
     103  computing the DCT. Defaults to `1`.
     104
     105*/
     106uint_t aubio_mfcc_set_scale (aubio_mfcc_t *mf, smpl_t scale);
     107
     108/** get scaling parameter
     109
     110  \param mf mfcc object, as returned by new_aubio_mfcc()
     111  \return current scaling parameter. Defaults to `1`.
     112
     113 */
     114uint_t aubio_mfcc_get_scale (aubio_mfcc_t *mf);
     115
     116/** Mel filterbank initialization
     117
     118  \param mf mfcc object
     119  \param fmin start frequency, in Hz
     120  \param fmax end frequency, in Hz
     121
     122  The filterbank will be initialized with bands linearly spaced in the mel
     123  scale, from `fmin` to `fmax`.
     124
     125  See also
     126  --------
     127
     128  aubio_filterbank_set_mel_coeffs()
     129
     130*/
     131uint_t aubio_mfcc_set_mel_coeffs (aubio_mfcc_t *mf,
     132        smpl_t fmin, smpl_t fmax);
     133
     134/** Mel filterbank initialization
     135
     136  \param mf mfcc object
     137  \param fmin start frequency, in Hz
     138  \param fmax end frequency, in Hz
     139
     140  The bank of filters will be initalized to to cover linearly spaced bands in
     141  the Htk mel scale, from `fmin` to `fmax`.
     142
     143  See also
     144  --------
     145
     146  aubio_filterbank_set_mel_coeffs_htk()
     147
     148*/
     149uint_t aubio_mfcc_set_mel_coeffs_htk (aubio_mfcc_t *mf,
     150        smpl_t fmin, smpl_t fmax);
     151
     152/** Mel filterbank initialization (Auditory Toolbox's parameters)
     153
     154  \param mf mfcc object
     155  \param samplerate audio sampling rate, in Hz
     156
     157  The filter coefficients are built to match exactly Malcolm Slaney's Auditory
     158  Toolbox implementation. The number of filters should be 40.
     159
     160  This is the default filterbank when `mf` was created with `n_filters = 40`.
     161
     162  See also
     163  --------
     164
     165  aubio_filterbank_set_mel_coeffs_slaney()
     166
     167*/
     168uint_t aubio_mfcc_set_mel_coeffs_slaney (aubio_mfcc_t *mf);
     169
    76170#ifdef __cplusplus
    77171}
Note: See TracChangeset for help on using the changeset viewer.