shithub: aubio

Download patch

ref: 6efdc83c4f9154c1e080c31abbc049668bc6604b
parent: bfe76d43a9472c451273e86db7cea7ef6291c513
author: Paul Brossier <piem@altern.org>
date: Tue Sep 27 15:10:49 EDT 2005

added {set,get}_threshold{,fn} to peakpick
added {set,get}_threshold{,fn} to peakpick


--- a/src/peakpick.c
+++ b/src/peakpick.c
@@ -37,7 +37,7 @@
 	/** pre: median filter window (anti-causal part) [post-1] */
 	uint_t 	win_pre; 				
 	/**	threshfn: name or handle of fn for computing adaptive threshold [@median]  */
-	//aubio_thresholdfn_t thresholdfn;
+	aubio_thresholdfn_t thresholdfn;
 	/**	picker:   name or handle of fn for picking event times [@peakpick] */
 	aubio_pickerfn_t pickerfn;
 
@@ -47,7 +47,7 @@
 	fvec_t * onset_keep;
 	/** modified onsets */
 	fvec_t * onset_proc;
-	/* peak picked window [3] */
+	/** peak picked window [3] */
 	fvec_t * onset_peek;
 	/** scratch pad for biquad and median */
 	fvec_t * scratch;
@@ -97,7 +97,7 @@
 	/* copy to scratch */
 	for (j = 0; j < length; j++)
 		scratch->data[i][j] = onset_proc->data[i][j];
-	median = vec_median(scratch);
+	median = p->thresholdfn(scratch);
 	/* } */
 
 	/* for (i=0;i<onset->channels;i++) { */
@@ -164,8 +164,24 @@
 	return isonset;
 }
 
+void aubio_peakpicker_set_threshold(aubio_pickpeak_t * p, smpl_t threshold) {
+	p->threshold = threshold;
+	return;
+}
 
+smpl_t aubio_peakpicker_get_threshold(aubio_pickpeak_t * p) {
+	return p->threshold;
+}
 
+void aubio_peakpicker_set_thresholdfn(aubio_pickpeak_t * p, aubio_thresholdfn_t thresholdfn) {
+	p->thresholdfn = thresholdfn;
+	return;
+}
+
+aubio_thresholdfn_t aubio_peakpicker_get_thresholdfn(aubio_pickpeak_t * p) {
+	return (aubio_thresholdfn_t) (p->thresholdfn);
+}
+
 aubio_pickpeak_t * new_aubio_peakpicker(smpl_t threshold) {
 	aubio_pickpeak_t * t = AUBIO_NEW(aubio_pickpeak_t);
 	t->threshold = 0.1; /* 0.0668; 0.33; 0.082; 0.033; */
@@ -174,7 +190,7 @@
 	t->win_post  = 5;
 	t->win_pre   = 1;
 
-	//t->thresholdfn = (aubio_thresholdfn_t)(vec_median); /* (vec_mean); */
+	t->thresholdfn = (aubio_thresholdfn_t)(vec_median); /* (vec_mean); */
 	t->pickerfn = (aubio_pickerfn_t)(vec_peakpick);
 
 	t->scratch = new_fvec(t->win_post+t->win_pre+1,1);
--- a/src/peakpick.h
+++ b/src/peakpick.h
@@ -40,6 +40,11 @@
 uint_t aubio_peakpick_pimrt_wt( fvec_t* DF, aubio_pickpeak_t* p, smpl_t* peakval );
 void del_aubio_peakpicker(aubio_pickpeak_t * p);
 
+void aubio_peakpicker_set_threshold(aubio_pickpeak_t * p, smpl_t threshold);
+smpl_t aubio_peakpicker_get_threshold(aubio_pickpeak_t * p);
+void aubio_peakpicker_set_thresholdfn(aubio_pickpeak_t * p, aubio_thresholdfn_t thresholdfn);
+aubio_thresholdfn_t aubio_peakpicker_get_thresholdfn(aubio_pickpeak_t * p);
+
 #ifdef __cplusplus
 }
 #endif