From fa3edc6951e7cfbd3741697a5e8999ff5e13ad05 Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Sun, 26 Mar 2017 16:28:54 +0200 Subject: [PATCH] src/onset/onset.h: add _reset and _set_default_parameters --- src/onset/onset.c | 18 ++++++++++++------ src/onset/onset.h | 21 +++++++++++++++++++++ 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/src/onset/onset.c b/src/onset/onset.c index fa612617..f6a43238 100644 --- a/src/onset/onset.c +++ b/src/onset/onset.c @@ -237,14 +237,12 @@ aubio_onset_t * new_aubio_onset (const char_t * onset_mode, if (o->od == NULL) goto beach_specdesc; o->fftgrain = new_cvec(buf_size); o->desc = new_fvec(1); - o->spectral_whitening = new_aubio_spectral_whitening(buf_size, hop_size, samplerate); - aubio_onset_default_parameters (o, onset_mode); - /* initialize internal variables */ - o->last_onset = 0; - o->total_frames = 0; + aubio_onset_set_default_parameters (o, onset_mode); + + aubio_onset_reset(o); return o; beach_specdesc: @@ -255,8 +253,14 @@ beach: return NULL; } -void aubio_onset_default_parameters (aubio_onset_t * o, const char_t * onset_mode) +void aubio_onset_reset (aubio_onset_t *o) { + o->last_onset = 0; + o->total_frames = 0; +} + +uint_t aubio_onset_set_default_parameters (aubio_onset_t * o, const char_t * onset_mode) { + uint_t ret = AUBIO_OK; /* set some default parameter */ aubio_onset_set_threshold (o, 0.3); aubio_onset_set_delay (o, 4.3 * o->hop_size); @@ -293,7 +297,9 @@ void aubio_onset_default_parameters (aubio_onset_t * o, const char_t * onset_mod } else { AUBIO_WRN("onset: unknown spectral descriptor type %s, " "using default parameters.\n", onset_mode); + ret = AUBIO_FAIL; } + return ret; } void del_aubio_onset (aubio_onset_t *o) diff --git a/src/onset/onset.h b/src/onset/onset.h index 17d061c5..6532e867 100644 --- a/src/onset/onset.h +++ b/src/onset/onset.h @@ -291,6 +291,27 @@ smpl_t aubio_onset_get_delay_ms(const aubio_onset_t * o); */ smpl_t aubio_onset_get_threshold(const aubio_onset_t * o); +/** set default parameters + + \param o onset detection object as returned by new_aubio_onset() + \param onset_mode detection mode to adjust + + This function is called at the end of new_aubio_onset(). + + */ +uint_t aubio_onset_set_default_parameters (aubio_onset_t * o, const char_t * onset_mode); + +/** reset onset detection + + \param o onset detection object as returned by new_aubio_onset() + + Reset current time and last onset to 0. + + This function is called at the end of new_aubio_onset(). + + */ +void aubio_onset_reset(aubio_onset_t * o); + /** delete onset detection object \param o onset detection object to delete -- 2.11.0