From 0f6f2e61bf6a9ad2e2a8b4fe24491053790fc11a Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Mon, 5 Oct 2009 19:40:45 +0200 Subject: [PATCH] src/onset/peakpick.c: use quadint in peakpick to get interpolated peak position, real in the range [0,2] in number of hop size --- src/onset/onset.c | 2 +- src/onset/peakpick.c | 9 +++++++-- src/onset/peakpick.h | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/onset/onset.c b/src/onset/onset.c index 3b30a7b3..e7dd31ab 100644 --- a/src/onset/onset.c +++ b/src/onset/onset.c @@ -51,7 +51,7 @@ void aubio_onset(aubio_onset_t *o, fvec_t * input, fvec_t * onset) onset->data[0][0] *= onset2->data[0][0]; }*/ isonset = aubio_peakpick_pimrt(o->of,o->pp); - if (isonset) { + if (isonset > 0.) { if (aubio_silence_detection(input, o->silence)==1) { isonset = 0; wasonset++; diff --git a/src/onset/peakpick.c b/src/onset/peakpick.c index 1ed0fe83..9c8551df 100644 --- a/src/onset/peakpick.c +++ b/src/onset/peakpick.c @@ -67,12 +67,13 @@ struct _aubio_pickpeak_t { /** modified version for real time, moving mean adaptive threshold this method * is slightly more permissive than the offline one, and yelds to an increase * of false positives. best */ -uint_t aubio_peakpick_pimrt(fvec_t * onset, aubio_pickpeak_t * p) { +smpl_t aubio_peakpick_pimrt(fvec_t * onset, aubio_pickpeak_t * p) { fvec_t * onset_keep = (fvec_t *)p->onset_keep; fvec_t * onset_proc = (fvec_t *)p->onset_proc; fvec_t * onset_peek = (fvec_t *)p->onset_peek; fvec_t * scratch = (fvec_t *)p->scratch; smpl_t mean = 0., median = 0.; + smpl_t isonset = 0.; uint_t length = p->win_post + p->win_pre + 1; uint_t i = 0, j; @@ -109,7 +110,11 @@ uint_t aubio_peakpick_pimrt(fvec_t * onset, aubio_pickpeak_t * p) { onset_proc->data[i][p->win_post] - median - mean * p->threshold; /* } */ //AUBIO_DBG("%f\n", onset_peek->data[0][2]); - return (p->pickerfn)(onset_peek,1); + isonset = (p->pickerfn)(onset_peek,1); + if (isonset) { //(isonset) { + isonset = fvec_quadint(onset_peek, 1, 1); + } + return isonset; } /** this method returns the current value in the pick peaking buffer diff --git a/src/onset/peakpick.h b/src/onset/peakpick.h index 3d391f48..c28e1089 100644 --- a/src/onset/peakpick.h +++ b/src/onset/peakpick.h @@ -40,7 +40,7 @@ typedef struct _aubio_pickpeak_t aubio_pickpeak_t; /** peak-picker creation function */ aubio_pickpeak_t * new_aubio_peakpicker(smpl_t threshold); /** real time peak picking function */ -uint_t aubio_peakpick_pimrt(fvec_t * DF, aubio_pickpeak_t * p); +smpl_t aubio_peakpick_pimrt(fvec_t * DF, aubio_pickpeak_t * p); /** function added by Miguel Ramirez to return the onset detection amplitude in peakval */ uint_t aubio_peakpick_pimrt_wt( fvec_t* DF, aubio_pickpeak_t* p, smpl_t* peakval ); /** get current peak value */ -- 2.26.2