added {set,get}_threshold{,fn} to peakpick
authorPaul Brossier <piem@altern.org>
Tue, 27 Sep 2005 19:10:49 +0000 (19:10 +0000)
committerPaul Brossier <piem@altern.org>
Tue, 27 Sep 2005 19:10:49 +0000 (19:10 +0000)
added {set,get}_threshold{,fn} to peakpick

src/peakpick.c
src/peakpick.h

index f7aca425ea621aab9c9cb9a3d174a2671325f699..e0f1336f937a38b0e7c8c3662433c8432fac7e3c 100644 (file)
@@ -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;i<onset->channels;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);
index 75ae37842c512716143b0e045bfc7e019a65ff28..0c0426b341d421758ff7cdf955bff874ade3d4ba 100644 (file)
@@ -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