- Timestamp:
- Nov 5, 2009, 11:17:56 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:
- e5b9a46
- Parents:
- 48b6a52
- Location:
- src/onset
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/onset/peakpick.c
r48b6a52 r6e57c2e 26 26 #include "temporal/biquad.h" 27 27 #include "onset/peakpick.h" 28 29 /** function pointer to thresholding function */ 30 typedef smpl_t (*aubio_thresholdfn_t)(fvec_t *input, uint_t channel); 31 /** function pointer to peak-picking function */ 32 typedef uint_t (*aubio_pickerfn_t)(fvec_t *input, uint_t pos); 33 34 /** set peak picker thresholding function */ 35 uint_t aubio_peakpicker_set_thresholdfn(aubio_peakpicker_t * p, aubio_thresholdfn_t thresholdfn); 36 /** get peak picker thresholding function */ 37 aubio_thresholdfn_t aubio_peakpicker_get_thresholdfn(aubio_peakpicker_t * p); 28 38 29 39 /* peak picking parameters, default values in brackets … … 54 64 /** peak picked window [3] */ 55 65 fvec_t *onset_peek; 66 /** thresholded function */ 67 fvec_t *thresholded; 56 68 /** scratch pad for biquad and median */ 57 69 fvec_t *scratch; … … 81 93 fvec_t *onset_proc = p->onset_proc; 82 94 fvec_t *onset_peek = p->onset_peek; 95 fvec_t *thresholded = p->thresholded; 83 96 fvec_t *scratch = p->scratch; 84 97 smpl_t mean = 0., median = 0.; … … 112 125 for (j = 0; j < 3 - 1; j++) 113 126 onset_peek->data[i][j] = onset_peek->data[i][j + 1]; 114 /* calculate new peekvalue */115 onset_peek->data[i][2] =127 /* calculate new tresholded value */ 128 thresholded->data[i][0] = 116 129 onset_proc->data[i][p->win_post] - median - mean * p->threshold; 130 onset_peek->data[i][2] = thresholded->data[i][0]; 117 131 out->data[i][0] = (p->pickerfn) (onset_peek, 1); 118 132 if (out->data[i][0]) { … … 125 139 * after smoothing 126 140 */ 127 smpl_t 141 fvec_t * 128 142 aubio_peakpicker_get_thresholded_input (aubio_peakpicker_t * p) 129 143 { 130 return p-> onset_peek->data[0][1];144 return p->thresholded; 131 145 } 132 146 … … 175 189 t->onset_proc = new_fvec (t->win_post + t->win_pre + 1, channels); 176 190 t->onset_peek = new_fvec (3, channels); 191 t->thresholded = new_fvec (1, channels); 177 192 178 193 /* cutoff: low-pass filter with cutoff reduced frequency at 0.34 … … 192 207 del_fvec (p->onset_proc); 193 208 del_fvec (p->onset_peek); 209 del_fvec (p->thresholded); 194 210 del_fvec (p->scratch); 195 211 AUBIO_FREE (p); -
src/onset/peakpick.h
r48b6a52 r6e57c2e 32 32 #endif 33 33 34 /** function pointer to thresholding function */35 typedef smpl_t (*aubio_thresholdfn_t)(fvec_t *input, uint_t channel);36 /** function pointer to peak-picking function */37 typedef uint_t (*aubio_pickerfn_t)(fvec_t *input, uint_t pos);38 34 /** peak-picker structure */ 39 35 typedef struct _aubio_peakpicker_t aubio_peakpicker_t; … … 43 39 /** real time peak picking function */ 44 40 void aubio_peakpicker_do(aubio_peakpicker_t * p, fvec_t * in, fvec_t * out); 45 /** get current peak value */46 smpl_t aubio_peakpicker_get_thresholded_input(aubio_peakpicker_t * p);47 41 /** destroy peak picker structure */ 48 42 void del_aubio_peakpicker(aubio_peakpicker_t * p); 49 43 44 /** get current peak value */ 45 fvec_t *aubio_peakpicker_get_thresholded_input (aubio_peakpicker_t * p); 50 46 /** set peak picking threshold */ 51 47 uint_t aubio_peakpicker_set_threshold(aubio_peakpicker_t * p, smpl_t threshold); 52 48 /** get peak picking threshold */ 53 49 smpl_t aubio_peakpicker_get_threshold(aubio_peakpicker_t * p); 54 /** set peak picker thresholding function */55 uint_t aubio_peakpicker_set_thresholdfn(aubio_peakpicker_t * p, aubio_thresholdfn_t thresholdfn);56 /** get peak picker thresholding function */57 aubio_thresholdfn_t aubio_peakpicker_get_thresholdfn(aubio_peakpicker_t * p);58 50 59 51 #ifdef __cplusplus
Note: See TracChangeset
for help on using the changeset viewer.