shithub: aubio

Download patch

ref: 763a7f1538d91c03fe3d5fde6d2e95379199c099
parent: 7b2d7402b3a3660d4ed2b32ae5378230ab5058fe
author: Paul Brossier <piem@piem.org>
date: Thu Aug 13 14:39:40 EDT 2015

src/onset/onset.c: simplify selection of first onset

--- a/src/onset/onset.c
+++ b/src/onset/onset.c
@@ -67,11 +67,16 @@
       }
     }
   } else {
-    // we are at the beginning of the file, and we don't find silence
-    if (o->total_frames <= o->delay && o->last_onset < o ->minioi && aubio_silence_detection(input, o->silence) == 0) {
-      //AUBIO_DBG ("beginning of file is not silent, marking as onset\n");
-      isonset = o->delay / o->hop_size;
-      o->last_onset = o->delay;
+    // we are at the beginning of the file
+    if (o->total_frames <= o->delay) {
+      // and we don't find silence
+      if (aubio_silence_detection(input, o->silence) == 0) {
+        uint_t new_onset = o->total_frames;
+        if (o->total_frames == 0 || o->last_onset + o->minioi < new_onset) {
+          isonset = o->delay / o->hop_size;
+          o->last_onset = o->total_frames + o->delay;
+        }
+      }
     }
   }
   onset->data[0] = isonset;