shithub: aubio

Download patch

ref: 8b884ef26f6dd0362468dea95f8d537cd9e3d743
parent: dee41640230a506657873f5a38e5ba4c2cd03d84
author: Paul Brossier <piem@piem.org>
date: Tue Apr 9 08:49:36 EDT 2013

src/onset/: rename get_last_onset to get_last

--- a/python/demos/demo_onset.py
+++ b/python/demos/demo_onset.py
@@ -28,8 +28,8 @@
 while True:
     samples, read = s()
     if o(samples):
-        print "%f" % o.get_last_onset_s()
-        onsets.append(o.get_last_onset())
+        print "%f" % o.get_last_s()
+        onsets.append(o.get_last())
     total_frames += read
     if read < hop_s: break
 #print len(onsets)
--- a/python/demos/demo_onset_plot.py
+++ b/python/demos/demo_onset_plot.py
@@ -33,11 +33,9 @@
 total_frames = 0
 while True:
     samples, read = s()
-    is_onset = o(samples)
-    if is_onset:
-        this_onset = o.get_last_onset()
-        print "%f" % (this_onset / float(samplerate))
-        onsets.append(this_onset)
+    if o(samples):
+        print "%f" % (o.get_last_s())
+        onsets.append(o.get_last())
     # keep some data to plot it later
     new_maxes = (abs(samples.reshape(hop_s/downsample, downsample))).max(axis=0)
     allsamples_max = hstack([allsamples_max, new_maxes])
--- a/src/onset/onset.c
+++ b/src/onset/onset.c
@@ -58,7 +58,7 @@
       //AUBIO_DBG ("silent onset, not marking as onset\n");
       isonset  = 0;
     } else {
-      uint_t new_onset = o->total_frames + isonset * o->hop_size;
+      uint_t new_onset = o->total_frames + (uint_t)ROUND(isonset * o->hop_size);
       if (o->last_onset + o->minioi < new_onset) {
         //AUBIO_DBG ("accepted detection, marking as onset\n");
         o->last_onset = new_onset;
@@ -80,19 +80,19 @@
   return;
 }
 
-smpl_t aubio_onset_get_last_onset (aubio_onset_t *o)
+uint_t aubio_onset_get_last (aubio_onset_t *o)
 {
   return o->last_onset - o->delay;
 }
 
-smpl_t aubio_onset_get_last_onset_s (aubio_onset_t *o)
+smpl_t aubio_onset_get_last_s (aubio_onset_t *o)
 {
-  return aubio_onset_get_last_onset (o) / (smpl_t) (o->samplerate);
+  return aubio_onset_get_last (o) / (smpl_t) (o->samplerate);
 }
 
-smpl_t aubio_onset_get_last_onset_ms (aubio_onset_t *o)
+smpl_t aubio_onset_get_last_ms (aubio_onset_t *o)
 {
-  return aubio_onset_get_last_onset_s (o) / 1000.;
+  return aubio_onset_get_last_s (o) / 1000.;
 }
 
 uint_t aubio_onset_set_silence(aubio_onset_t * o, smpl_t silence) {
--- a/src/onset/onset.h
+++ b/src/onset/onset.h
@@ -91,7 +91,7 @@
   \param o onset detection object as returned by ::new_aubio_onset
 
 */
-smpl_t aubio_onset_get_last_onset (aubio_onset_t *o);
+uint_t aubio_onset_get_last (aubio_onset_t *o);
 
 /** get the time of the latest onset detected, in seconds
 
@@ -98,7 +98,7 @@
   \param o onset detection object as returned by ::new_aubio_onset
 
 */
-smpl_t aubio_onset_get_last_onset_s (aubio_onset_t *o);
+smpl_t aubio_onset_get_last_s (aubio_onset_t *o);
 
 /** get the time of the latest onset detected, in milliseconds
 
@@ -105,7 +105,7 @@
   \param o onset detection object as returned by ::new_aubio_onset
 
 */
-smpl_t aubio_onset_get_last_onset_ms (aubio_onset_t *o);
+smpl_t aubio_onset_get_last_ms (aubio_onset_t *o);
 
 /** set onset detection silence threshold