ref: 93579e5338852e2101dbd63fbf1349ab5e1d0022
parent: 25e0b0ef3ece7bc6787900053b549ee896eb65c1
author: Paul Brossier <piem@piem.org>
date: Mon Mar 27 06:37:58 EDT 2017
src/onset/onset.c: avoid start with doubled or negative onset
--- a/src/onset/onset.c
+++ b/src/onset/onset.c
@@ -75,10 +75,17 @@
//AUBIO_DBG ("silent onset, not marking as onset\n");
isonset = 0;
} else {
+ // we have an onset
uint_t new_onset = o->total_frames + (uint_t)ROUND(isonset * o->hop_size);
+ // check if last onset time was more than minioi ago
if (o->last_onset + o->minioi < new_onset) {
- //AUBIO_DBG ("accepted detection, marking as onset\n");
- o->last_onset = new_onset;
+ // start of file: make sure (new_onset - delay) >= 0
+ if (o->last_onset > 0 && o->delay > new_onset) {
+ isonset = 0;
+ } else {
+ //AUBIO_DBG ("accepted detection, marking as onset\n");
+ o->last_onset = MAX(o->delay, new_onset);
+ }
} else {
//AUBIO_DBG ("doubled onset, not marking as onset\n");
isonset = 0;