shithub: aubio

Download patch

ref: fa3edc6951e7cfbd3741697a5e8999ff5e13ad05
parent: fa0ef3b8148db015592182b899d44f5071464cbf
author: Paul Brossier <piem@piem.org>
date: Sun Mar 26 12:28:54 EDT 2017

src/onset/onset.h: add _reset and _set_default_parameters

--- a/src/onset/onset.c
+++ b/src/onset/onset.c
@@ -237,14 +237,12 @@
   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 @@
   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 @@
   } 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)
--- a/src/onset/onset.h
+++ b/src/onset/onset.h
@@ -291,6 +291,27 @@
 */
 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