Changeset 349e455 for src/onset/peakpick.c
- Timestamp:
- Nov 4, 2009, 10:39:45 PM (15 years ago)
- Branches:
- feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
- Children:
- b9c3cd2
- Parents:
- 554e286
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/onset/peakpick.c
r554e286 r349e455 29 29 /* peak picking parameters, default values in brackets 30 30 * 31 * 32 * 33 * 31 * [<----post----|--pre-->] 32 * .................|............. 33 * time-> ^now 34 34 */ 35 struct _aubio_peakpicker_t { 36 /** thresh: offset threshold [0.033 or 0.01] */ 37 smpl_t threshold; 38 /** win_post: median filter window length (causal part) [8] */ 39 uint_t win_post; 40 /** pre: median filter window (anti-causal part) [post-1] */ 41 uint_t win_pre; 42 /** threshfn: name or handle of fn for computing adaptive threshold [median] */ 43 aubio_thresholdfn_t thresholdfn; 44 /** picker: name or handle of fn for picking event times [peakpick] */ 45 aubio_pickerfn_t pickerfn; 35 struct _aubio_peakpicker_t 36 { 37 /** thresh: offset threshold [0.033 or 0.01] */ 38 smpl_t threshold; 39 /** win_post: median filter window length (causal part) [8] */ 40 uint_t win_post; 41 /** pre: median filter window (anti-causal part) [post-1] */ 42 uint_t win_pre; 43 /** threshfn: name or handle of fn for computing adaptive threshold [median] */ 44 aubio_thresholdfn_t thresholdfn; 45 /** picker: name or handle of fn for picking event times [peakpick] */ 46 aubio_pickerfn_t pickerfn; 46 47 47 48 aubio_filter_t *biquad;49 50 fvec_t *onset_keep;51 52 fvec_t *onset_proc;53 54 fvec_t *onset_peek;55 56 fvec_t *scratch;48 /** biquad lowpass filter */ 49 aubio_filter_t *biquad; 50 /** original onsets */ 51 fvec_t *onset_keep; 52 /** modified onsets */ 53 fvec_t *onset_proc; 54 /** peak picked window [3] */ 55 fvec_t *onset_peek; 56 /** scratch pad for biquad and median */ 57 fvec_t *scratch; 57 58 58 59 /** number of channels to analyse */ 59 60 uint_t channels; 60 61 61 62 63 62 /** \bug should be used to calculate filter coefficients */ 63 /* cutoff: low-pass filter cutoff [0.34, 1] */ 64 /* smpl_t cutoff; */ 64 65 65 66 67 68 69 66 /* not used anymore */ 67 /* time precision [512/44100 winlength/samplerate, fs/buffer_size */ 68 /* smpl_t tau; */ 69 /* alpha: normalisation exponent [9] */ 70 /* smpl_t alpha; */ 70 71 }; 71 72 … … 124 125 * after smoothing 125 126 */ 126 smpl_t aubio_peakpicker_get_thresholded_input(aubio_peakpicker_t * p) 127 smpl_t 128 aubio_peakpicker_get_thresholded_input (aubio_peakpicker_t * p) 127 129 { 128 130 return p->onset_peek->data[0][1]; 129 131 } 130 132 131 uint_t aubio_peakpicker_set_threshold(aubio_peakpicker_t * p, smpl_t threshold) { 132 p->threshold = threshold; 133 return AUBIO_OK; 133 uint_t 134 aubio_peakpicker_set_threshold (aubio_peakpicker_t * p, smpl_t threshold) 135 { 136 p->threshold = threshold; 137 return AUBIO_OK; 134 138 } 135 139 136 smpl_t aubio_peakpicker_get_threshold(aubio_peakpicker_t * p) { 137 return p->threshold; 140 smpl_t 141 aubio_peakpicker_get_threshold (aubio_peakpicker_t * p) 142 { 143 return p->threshold; 138 144 } 139 145 140 uint_t aubio_peakpicker_set_thresholdfn(aubio_peakpicker_t * p, aubio_thresholdfn_t thresholdfn) { 141 p->thresholdfn = thresholdfn; 142 return AUBIO_OK; 146 uint_t 147 aubio_peakpicker_set_thresholdfn (aubio_peakpicker_t * p, 148 aubio_thresholdfn_t thresholdfn) 149 { 150 p->thresholdfn = thresholdfn; 151 return AUBIO_OK; 143 152 } 144 153 145 aubio_thresholdfn_t aubio_peakpicker_get_thresholdfn(aubio_peakpicker_t * p) { 146 return (aubio_thresholdfn_t) (p->thresholdfn); 154 aubio_thresholdfn_t 155 aubio_peakpicker_get_thresholdfn (aubio_peakpicker_t * p) 156 { 157 return (aubio_thresholdfn_t) (p->thresholdfn); 147 158 } 148 159 149 aubio_peakpicker_t * new_aubio_peakpicker(uint_t channels) { 150 aubio_peakpicker_t * t = AUBIO_NEW(aubio_peakpicker_t); 151 t->threshold = 0.1; /* 0.0668; 0.33; 0.082; 0.033; */ 152 t->win_post = 5; 153 t->win_pre = 1; 160 aubio_peakpicker_t * 161 new_aubio_peakpicker (uint_t channels) 162 { 163 aubio_peakpicker_t *t = AUBIO_NEW (aubio_peakpicker_t); 164 t->threshold = 0.1; /* 0.0668; 0.33; 0.082; 0.033; */ 165 t->win_post = 5; 166 t->win_pre = 1; 154 167 //channels = 1; 155 168 t->channels = channels; 156 169 157 t->thresholdfn = (aubio_thresholdfn_t)(fvec_median_channel); /* (fvec_mean); */158 t->pickerfn = (aubio_pickerfn_t)(fvec_peakpick);170 t->thresholdfn = (aubio_thresholdfn_t) (fvec_median_channel); /* (fvec_mean); */ 171 t->pickerfn = (aubio_pickerfn_t) (fvec_peakpick); 159 172 160 t->scratch = new_fvec(t->win_post+t->win_pre+1, channels);161 t->onset_keep = new_fvec(t->win_post+t->win_pre+1, channels);162 t->onset_proc = new_fvec(t->win_post+t->win_pre+1, channels);163 t->onset_peek = new_fvec(3, channels);173 t->scratch = new_fvec (t->win_post + t->win_pre + 1, channels); 174 t->onset_keep = new_fvec (t->win_post + t->win_pre + 1, channels); 175 t->onset_proc = new_fvec (t->win_post + t->win_pre + 1, channels); 176 t->onset_peek = new_fvec (3, channels); 164 177 165 166 generated with octave butter function: [b,a] = butter(2, 0.34);178 /* cutoff: low-pass filter with cutoff reduced frequency at 0.34 179 generated with octave butter function: [b,a] = butter(2, 0.34); 167 180 */ 168 181 t->biquad = new_aubio_filter_biquad (0.15998789, 0.31997577, 0.15998789, 169 -0.59488894, 0.23484048, channels);182 -0.59488894, 0.23484048, channels); 170 183 171 184 return t; 172 185 } 173 186 174 void del_aubio_peakpicker(aubio_peakpicker_t * p) { 175 del_aubio_filter(p->biquad); 176 del_fvec(p->onset_keep); 177 del_fvec(p->onset_proc); 178 del_fvec(p->onset_peek); 179 del_fvec(p->scratch); 180 AUBIO_FREE(p); 187 void 188 del_aubio_peakpicker (aubio_peakpicker_t * p) 189 { 190 del_aubio_filter (p->biquad); 191 del_fvec (p->onset_keep); 192 del_fvec (p->onset_proc); 193 del_fvec (p->onset_peek); 194 del_fvec (p->scratch); 195 AUBIO_FREE (p); 181 196 }
Note: See TracChangeset
for help on using the changeset viewer.