ref: e149aa905aa5db14ac8fe9506baa1737fc3ab5a1
parent: ee8a57c3905c9ce6bc5286dd0238d4fbc0c5b459
author: Paul Brossier <[email protected]>
date: Fri Mar 10 12:18:25 EST 2017
src/onset/peakpicker.c: simplify using fvec_foo
--- a/src/onset/peakpicker.c
+++ b/src/onset/peakpicker.c
@@ -92,27 +92,21 @@
fvec_t *thresholded = p->thresholded;
fvec_t *scratch = p->scratch;
smpl_t mean = 0., median = 0.;
- uint_t length = p->win_post + p->win_pre + 1;
uint_t j = 0;
- /* store onset in onset_keep */
- /* shift all elements but last, then write last */
- for (j = 0; j < length - 1; j++) {
- onset_keep->data[j] = onset_keep->data[j + 1];
- onset_proc->data[j] = onset_keep->data[j];
- }
- onset_keep->data[length - 1] = onset->data[0];
- onset_proc->data[length - 1] = onset->data[0];
+ /* push new novelty to the end */
+ fvec_push(onset_keep, onset->data[0]);
+ /* store a copy */
+ fvec_copy(onset_keep, onset_proc);
- /* filter onset_proc */
- /** \bug filtfilt calculated post+pre times, should be only once !? */
+ /* filter this copy */
aubio_filter_do_filtfilt (p->biquad, onset_proc, scratch);
/* calculate mean and median for onset_proc */
mean = fvec_mean (onset_proc);
- /* copy to scratch */
- for (j = 0; j < length; j++)
- scratch->data[j] = onset_proc->data[j];
+
+ /* copy to scratch and compute its median */
+ fvec_copy(onset_proc, scratch);
median = p->thresholdfn (scratch);
/* shift peek array */