From 8b884ef26f6dd0362468dea95f8d537cd9e3d743 Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Tue, 9 Apr 2013 12:49:36 -0500 Subject: [PATCH] src/onset/: rename get_last_onset to get_last --- python/demos/demo_onset.py | 4 ++-- python/demos/demo_onset_plot.py | 8 +++----- src/onset/onset.c | 12 ++++++------ src/onset/onset.h | 6 +++--- 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/python/demos/demo_onset.py b/python/demos/demo_onset.py index 170326fc..949a6639 100755 --- a/python/demos/demo_onset.py +++ b/python/demos/demo_onset.py @@ -28,8 +28,8 @@ total_frames = 0 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) diff --git a/python/demos/demo_onset_plot.py b/python/demos/demo_onset_plot.py index 246b5b14..a9286558 100755 --- a/python/demos/demo_onset_plot.py +++ b/python/demos/demo_onset_plot.py @@ -33,11 +33,9 @@ downsample = 2 # to plot n samples / hop_s 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]) diff --git a/src/onset/onset.c b/src/onset/onset.c index ad983933..a5ed954e 100644 --- a/src/onset/onset.c +++ b/src/onset/onset.c @@ -58,7 +58,7 @@ void aubio_onset_do (aubio_onset_t *o, fvec_t * input, fvec_t * onset) //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 @@ void aubio_onset_do (aubio_onset_t *o, fvec_t * input, fvec_t * onset) 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) { diff --git a/src/onset/onset.h b/src/onset/onset.h index 83dfff3c..4742d5a0 100644 --- a/src/onset/onset.h +++ b/src/onset/onset.h @@ -91,21 +91,21 @@ void aubio_onset_do (aubio_onset_t *o, fvec_t * input, fvec_t * onset); \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 \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 \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 -- 2.26.2