Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/onset/onset.c

    r078dad8 r6352034  
    2424#include "spectral/specdesc.h"
    2525#include "spectral/phasevoc.h"
     26#include "spectral/awhitening.h"
    2627#include "onset/peakpicker.h"
    2728#include "mathutils.h"
    2829#include "onset/onset.h"
     30
     31void aubio_onset_default_parameters (aubio_onset_t *o, const char_t * method);
    2932
    3033/** structure to store object state */
     
    4346  uint_t total_frames;          /**< total number of frames processed since the beginning */
    4447  uint_t last_onset;            /**< last detected onset location, in frames */
     48
     49  uint_t apply_compression;
     50  smpl_t lambda_compression;
     51  uint_t apply_adaptive_whitening;
     52  aubio_spectral_whitening_t *spectral_whitening;
    4553};
    4654
     
    5058  smpl_t isonset = 0;
    5159  aubio_pvoc_do (o->pv,input, o->fftgrain);
     60  /*
     61  if (apply_filtering) {
     62  }
     63  */
     64  if (o->apply_adaptive_whitening) {
     65    aubio_spectral_whitening_do(o->spectral_whitening, o->fftgrain);
     66  }
     67  if (o->apply_compression) {
     68    cvec_logmag(o->fftgrain, o->apply_compression);
     69  }
    5270  aubio_specdesc_do (o->od, o->fftgrain, o->desc);
    5371  aubio_peakpicker_do(o->pp, o->desc, onset);
     
    100118}
    101119
     120uint_t aubio_onset_set_adaptive_whitening (aubio_onset_t *o, uint_t apply_adaptive_whitening)
     121{
     122  o->apply_adaptive_whitening = apply_adaptive_whitening;
     123  return AUBIO_OK;
     124}
     125
     126uint_t aubio_onset_get_adaptive_whitening (aubio_onset_t *o)
     127{
     128  return o->apply_adaptive_whitening;
     129}
     130
    102131uint_t aubio_onset_set_silence(aubio_onset_t * o, smpl_t silence) {
    103132  o->silence = silence;
     
    210239  o->desc = new_fvec(1);
    211240
    212   /* set some default parameter */
    213   aubio_onset_set_threshold (o, 0.3);
    214   aubio_onset_set_delay(o, 4.3 * hop_size);
    215   aubio_onset_set_minioi_ms(o, 20.);
    216   aubio_onset_set_silence(o, -70.);
     241  o->spectral_whitening = new_aubio_spectral_whitening(buf_size, hop_size, samplerate);
     242
     243  aubio_onset_default_parameters (o, onset_mode);
    217244
    218245  /* initialize internal variables */
     
    229256}
    230257
     258void aubio_onset_default_parameters (aubio_onset_t * o, const char_t * onset_mode)
     259{
     260  /* set some default parameter */
     261  aubio_onset_set_threshold (o, 0.3);
     262  aubio_onset_set_delay (o, 4.3 * o->hop_size);
     263  aubio_onset_set_minioi_ms (o, 50.);
     264  aubio_onset_set_silence (o, -70.);
     265  aubio_onset_set_adaptive_whitening (o, 0);
     266
     267  o->apply_compression = 0;
     268  o->lambda_compression = 1.;
     269
     270  /* method specific optimisations */
     271  if (strcmp (onset_mode, "energy") == 0) {
     272  } else if (strcmp (onset_mode, "hfc") == 0 || strcmp (onset_mode, "default") == 0) {
     273    aubio_onset_set_threshold (o, 0.058);
     274    o->apply_compression = 1;
     275    o->lambda_compression = 1.;
     276    aubio_onset_set_adaptive_whitening (o, 0);
     277  } else if (strcmp (onset_mode, "complexdomain") == 0
     278             || strcmp (onset_mode, "complex") == 0) {
     279    aubio_onset_set_delay (o, 4.6 * o->hop_size);
     280    aubio_onset_set_threshold (o, 0.15);
     281    o->apply_compression = 1;
     282    o->lambda_compression = 1.;
     283  } else if (strcmp (onset_mode, "phase") == 0) {
     284    o->apply_compression = 0;
     285    aubio_onset_set_adaptive_whitening (o, 0);
     286  } else if (strcmp (onset_mode, "mkl") == 0) {
     287    aubio_onset_set_threshold (o, 0.05);
     288  } else if (strcmp (onset_mode, "kl") == 0) {
     289    aubio_onset_set_threshold (o, 0.35);
     290  } else if (strcmp (onset_mode, "specflux") == 0) {
     291    aubio_onset_set_threshold (o, 0.4);
     292  } else if (strcmp (onset_mode, "specdiff") == 0) {
     293  } else {
     294    AUBIO_WRN("onset: unknown spectral descriptor type %s, "
     295               "using default parameters.\n", onset_mode);
     296  }
     297}
     298
    231299void del_aubio_onset (aubio_onset_t *o)
    232300{
     301  del_aubio_spectral_whitening(o->spectral_whitening);
    233302  del_aubio_specdesc(o->od);
    234303  del_aubio_peakpicker(o->pp);
Note: See TracChangeset for help on using the changeset viewer.