shithub: aubio

Download patch

ref: 63520340a33fc38f966e6a3f39beb55ee4d3f0b7
parent: 2f994276ae594f769c1c4b3b63cd42652885dd8f
author: Paul Brossier <[email protected]>
date: Fri Mar 10 19:12:44 EST 2017

src/onset/onset.c: add logarithmic compression

Using these default parameters with the good old HFC, we reach the
following scores:

mirex-2005 | F  80.393 | P  80.841 | R  79.950 | TP 7616 | FP 1360 | Tot 9526
holzapfel  | F  69.441 | P  77.803 | R  62.702 | TP 1360 | FP  388 | Tot 2169

--- a/src/onset/onset.c
+++ b/src/onset/onset.c
@@ -46,6 +46,8 @@
   uint_t total_frames;          /**< total number of frames processed since the beginning */
   uint_t last_onset;            /**< last detected onset location, in frames */
 
+  uint_t apply_compression;
+  smpl_t lambda_compression;
   uint_t apply_adaptive_whitening;
   aubio_spectral_whitening_t *spectral_whitening;
 };
@@ -58,12 +60,13 @@
   /*
   if (apply_filtering) {
   }
-  if (apply_compression) {
-  }
   */
   if (o->apply_adaptive_whitening) {
     aubio_spectral_whitening_do(o->spectral_whitening, o->fftgrain);
   }
+  if (o->apply_compression) {
+    cvec_logmag(o->fftgrain, o->apply_compression);
+  }
   aubio_specdesc_do (o->od, o->fftgrain, o->desc);
   aubio_peakpicker_do(o->pp, o->desc, onset);
   isonset = onset->data[0];
@@ -259,17 +262,26 @@
   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, 1);
+  aubio_onset_set_adaptive_whitening (o, 0);
 
+  o->apply_compression = 0;
+  o->lambda_compression = 1.;
+
   /* method specific optimisations */
   if (strcmp (onset_mode, "energy") == 0) {
   } else if (strcmp (onset_mode, "hfc") == 0 || strcmp (onset_mode, "default") == 0) {
+    aubio_onset_set_threshold (o, 0.058);
+    o->apply_compression = 1;
+    o->lambda_compression = 1.;
     aubio_onset_set_adaptive_whitening (o, 0);
   } else if (strcmp (onset_mode, "complexdomain") == 0
              || strcmp (onset_mode, "complex") == 0) {
     aubio_onset_set_delay (o, 4.6 * o->hop_size);
     aubio_onset_set_threshold (o, 0.15);
+    o->apply_compression = 1;
+    o->lambda_compression = 1.;
   } else if (strcmp (onset_mode, "phase") == 0) {
+    o->apply_compression = 0;
     aubio_onset_set_adaptive_whitening (o, 0);
   } else if (strcmp (onset_mode, "mkl") == 0) {
     aubio_onset_set_threshold (o, 0.05);