shithub: aubio

Download patch

ref: 0f6f2e61bf6a9ad2e2a8b4fe24491053790fc11a
parent: eebb0e1fce66faaafa201ea5292ad014e743a53e
author: Paul Brossier <piem@piem.org>
date: Mon Oct 5 15:40:45 EDT 2009

src/onset/peakpick.c: use quadint in peakpick to get interpolated peak position, real in the range [0,2] in number of hop size

--- a/src/onset/onset.c
+++ b/src/onset/onset.c
@@ -51,7 +51,7 @@
     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++;
--- a/src/onset/peakpick.c
+++ b/src/onset/peakpick.c
@@ -67,12 +67,13 @@
 /** 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 @@
 		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
--- a/src/onset/peakpick.h
+++ b/src/onset/peakpick.h
@@ -40,7 +40,7 @@
 /** 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 */