shithub: aubio

Download patch

ref: 40ed6a70a16ef7e8d262980dd4a6ec32d8cf5c02
parent: fa3edc6951e7cfbd3741697a5e8999ff5e13ad05
author: Paul Brossier <piem@piem.org>
date: Sun Mar 26 13:38:09 EDT 2017

src/onset/onset.h: rename to awhitening, add logmap_compression

--- a/src/onset/onset.c
+++ b/src/onset/onset.c
@@ -48,7 +48,7 @@
 
   uint_t apply_compression;
   smpl_t lambda_compression;
-  uint_t apply_adaptive_whitening;
+  uint_t apply_awhitening;      /**< apply adaptive spectral whitening */
   aubio_spectral_whitening_t *spectral_whitening;
 };
 
@@ -61,11 +61,11 @@
   if (apply_filtering) {
   }
   */
-  if (o->apply_adaptive_whitening) {
+  if (o->apply_awhitening) {
     aubio_spectral_whitening_do(o->spectral_whitening, o->fftgrain);
   }
   if (o->apply_compression) {
-    cvec_logmag(o->fftgrain, o->apply_compression);
+    cvec_logmag(o->fftgrain, o->lambda_compression);
   }
   aubio_specdesc_do (o->od, o->fftgrain, o->desc);
   aubio_peakpicker_do(o->pp, o->desc, onset);
@@ -117,17 +117,32 @@
   return aubio_onset_get_last_s (o) * 1000.;
 }
 
-uint_t aubio_onset_set_adaptive_whitening (aubio_onset_t *o, uint_t apply_adaptive_whitening)
+uint_t aubio_onset_set_awhitening (aubio_onset_t *o, uint_t enable)
 {
-  o->apply_adaptive_whitening = apply_adaptive_whitening;
+  o->apply_awhitening = enable == 1 ? 1 : 0;
   return AUBIO_OK;
 }
 
-uint_t aubio_onset_get_adaptive_whitening (aubio_onset_t *o)
+smpl_t aubio_onset_get_awhitening (aubio_onset_t *o)
 {
-  return o->apply_adaptive_whitening;
+  return o->apply_awhitening;
 }
 
+uint_t aubio_onset_set_logmag_compression (aubio_onset_t *o, smpl_t lambda)
+{
+  if (lambda < 0.) {
+    return AUBIO_FAIL;
+  }
+  o->lambda_compression = lambda;
+  o->apply_compression = (o->lambda_compression > 0.) ? 1 : 0;
+  return AUBIO_OK;
+}
+
+smpl_t aubio_onset_get_logmag_compression (aubio_onset_t *o)
+{
+  return o->apply_compression ? o->lambda_compression : 0;
+}
+
 uint_t aubio_onset_set_silence(aubio_onset_t * o, smpl_t silence) {
   o->silence = silence;
   return AUBIO_OK;
@@ -266,10 +281,10 @@
   aubio_onset_set_delay (o, 4.3 * o->hop_size);
   aubio_onset_set_minioi_ms (o, 50.);
   aubio_onset_set_silence (o, -70.);
-  aubio_onset_set_adaptive_whitening (o, 0);
-
-  o->apply_compression = 0;
-  o->lambda_compression = 1.;
+  // disable spectral whitening
+  aubio_onset_set_awhitening (o, 0);
+  // disable logarithmic magnitude
+  aubio_onset_set_logmag_compression (o, 0.);
 
   /* method specific optimisations */
   if (strcmp (onset_mode, "energy") == 0) {
--- a/src/onset/onset.h
+++ b/src/onset/onset.h
@@ -120,19 +120,35 @@
 /** set onset detection adaptive whitening
 
   \param o onset detection object as returned by new_aubio_onset()
-  \param apply_adaptive_whitening 1 to enable, 0 to disable
+  \param enable 1 to enable, 0 to disable
 
+  \return 0 if successful, 1 otherwise
+
 */
-uint_t aubio_onset_set_adaptive_whitening(aubio_onset_t * o, uint_t apply_adaptive_whitening);
+uint_t aubio_onset_set_awhitening(aubio_onset_t * o, uint_t enable);
 
-/** get onset detection silence threshold
+/** get onset detection adaptive whitening
 
   \param o onset detection object as returned by new_aubio_onset()
 
-  \return adaptive whitening mode, 1 if enabled, 0 otherwise
+  \return 1 if enabled, 0 otherwise
 
 */
-uint_t aubio_onset_get_adaptive_whitening(aubio_onset_t * o);
+smpl_t aubio_onset_get_awhitening(aubio_onset_t * o);
+
+/** set or disable log compression
+
+  \param o onset detection object as returned by new_aubio_onset()
+  \param lambda logarithmic compression factor
+
+  \return 0 if successful, 1 otherwise
+
+ */
+uint_t aubio_onset_set_logmag_compression(aubio_onset_t *o, smpl_t lambda);
+
+/** get onset detection log compression
+ */
+smpl_t aubio_onset_get_logmag_compression(aubio_onset_t *o);
 
 /** set onset detection silence threshold