Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/onset/onset.c

    r6352034 r078dad8  
    2424#include "spectral/specdesc.h"
    2525#include "spectral/phasevoc.h"
    26 #include "spectral/awhitening.h"
    2726#include "onset/peakpicker.h"
    2827#include "mathutils.h"
    2928#include "onset/onset.h"
    30 
    31 void aubio_onset_default_parameters (aubio_onset_t *o, const char_t * method);
    3229
    3330/** structure to store object state */
     
    4643  uint_t total_frames;          /**< total number of frames processed since the beginning */
    4744  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;
    5345};
    5446
     
    5850  smpl_t isonset = 0;
    5951  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   }
    7052  aubio_specdesc_do (o->od, o->fftgrain, o->desc);
    7153  aubio_peakpicker_do(o->pp, o->desc, onset);
     
    118100}
    119101
    120 uint_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 
    126 uint_t aubio_onset_get_adaptive_whitening (aubio_onset_t *o)
    127 {
    128   return o->apply_adaptive_whitening;
    129 }
    130 
    131102uint_t aubio_onset_set_silence(aubio_onset_t * o, smpl_t silence) {
    132103  o->silence = silence;
     
    239210  o->desc = new_fvec(1);
    240211
    241   o->spectral_whitening = new_aubio_spectral_whitening(buf_size, hop_size, samplerate);
    242 
    243   aubio_onset_default_parameters (o, onset_mode);
     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.);
    244217
    245218  /* initialize internal variables */
     
    256229}
    257230
    258 void 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 
    299231void del_aubio_onset (aubio_onset_t *o)
    300232{
    301   del_aubio_spectral_whitening(o->spectral_whitening);
    302233  del_aubio_specdesc(o->od);
    303234  del_aubio_peakpicker(o->pp);
Note: See TracChangeset for help on using the changeset viewer.