src/onset/onset.c: quick fix to get very first frame of file
authorPaul Brossier <piem@piem.org>
Fri, 15 Mar 2013 19:41:02 +0000 (14:41 -0500)
committerPaul Brossier <piem@piem.org>
Fri, 15 Mar 2013 19:41:02 +0000 (14:41 -0500)
src/onset/onset.c

index ecf9a4734c1e4f0aceac059d9699ce1143f67d42..34e94fa77dd94fb3f8b4c9ab3fde8460ad9e5518 100644 (file)
@@ -65,6 +65,12 @@ void aubio_onset_do (aubio_onset_t *o, fvec_t * input, fvec_t * onset)
       }
     }
   } else {
+    if (wasonset == -1 && aubio_silence_detection(input, o->silence) == 0) {
+      //AUBIO_MSG("beginning of file is not silent, marking as onset\n",
+      //  wasonset, aubio_silence_detection(input, o->silence));
+      isonset = 4;
+      wasonset = 0;
+    }
     wasonset++;
   }
   o->wasonset->data[0] = wasonset;
@@ -107,6 +113,7 @@ aubio_onset_t * new_aubio_onset (char_t * onset_mode,
   o->minioi    = 4;
   o->silence   = -70;
   o->wasonset  = new_fvec(1);
+  o->wasonset->data[0] = -1.;
   o->samplerate = samplerate;
   o->hop_size = hop_size;
   o->pv = new_aubio_pvoc(buf_size, hop_size);