From 6efdc83c4f9154c1e080c31abbc049668bc6604b Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Tue, 27 Sep 2005 19:10:49 +0000 Subject: [PATCH] added {set,get}_threshold{,fn} to peakpick added {set,get}_threshold{,fn} to peakpick --- src/peakpick.c | 24 ++++++++++++++++++++---- src/peakpick.h | 5 +++++ 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/peakpick.c b/src/peakpick.c index f7aca425..e0f1336f 100644 --- a/src/peakpick.c +++ b/src/peakpick.c @@ -37,7 +37,7 @@ struct _aubio_pickpeak_t { /** 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 @@ struct _aubio_pickpeak_t { 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 @@ uint_t aubio_peakpick_pimrt(fvec_t * onset, aubio_pickpeak_t * p) { /* 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;ichannels;i++) { */ @@ -164,7 +164,23 @@ uint_t aubio_peakpick_pimrt_wt(fvec_t * onset, aubio_pickpeak_t * p, smpl_t* pe 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); @@ -174,7 +190,7 @@ aubio_pickpeak_t * new_aubio_peakpicker(smpl_t threshold) { 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); diff --git a/src/peakpick.h b/src/peakpick.h index 75ae3784..0c0426b3 100644 --- a/src/peakpick.h +++ b/src/peakpick.h @@ -40,6 +40,11 @@ uint_t aubio_peakpick_pimrt(fvec_t * DF, aubio_pickpeak_t * p); 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 -- 2.26.2