From 56ef7e1e2d47981012ffa6f5fa94691d90729ffa Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Sun, 18 Oct 2009 15:08:59 +0200 Subject: [PATCH] Change peakpicker to match API specs, make quadint per channel * src/mathutils.c - add per channel mean and median - update moving thres and adapt_thres accordingly - change quadint unused span argument to a channel argument * src/onset/onset.c: - make wasonset a vector for multi channel, use new peakpicker * src/onset/peakpick.c: - update peakpicker do for multi channeling * src/pitch/: update use to fvec_quadint * src/tempo/beattracking.c: update calls to fvec_quadint * src/tempo/tempo.c: update peakpicker usage * tests/src/test-peakpick.c: update peakpicker usage --- src/mathutils.c | 44 +++++++++------ src/mathutils.h | 22 ++++++-- src/onset/onset.c | 23 +++++--- src/onset/peakpick.c | 113 +++++++++++++++++++------------------- src/onset/peakpick.h | 6 +- src/pitch/pitchmcomb.c | 4 +- src/pitch/pitchyin.c | 4 +- src/pitch/pitchyinfft.c | 6 +- src/tempo/beattracking.c | 8 +-- src/tempo/tempo.c | 12 +++- tests/src/test-peakpick.c | 12 ++-- 11 files changed, 146 insertions(+), 108 deletions(-) diff --git a/src/mathutils.c b/src/mathutils.c index 3178df0b..9e5505a3 100644 --- a/src/mathutils.c +++ b/src/mathutils.c @@ -140,6 +140,16 @@ fvec_mean (fvec_t * s) return tmp / (smpl_t) (s->length); } +smpl_t +fvec_mean_channel (fvec_t * s, uint_t i) +{ + uint_t j; + smpl_t tmp = 0.0; + for (j = 0; j < s->length; j++) + tmp += s->data[i][j]; + return tmp / (smpl_t) (s->length); +} + smpl_t fvec_sum (fvec_t * s) { @@ -288,19 +298,19 @@ fvec_add (fvec_t * o, smpl_t val) } void fvec_adapt_thres(fvec_t * vec, fvec_t * tmp, - uint_t post, uint_t pre) { - uint_t length = vec->length, i=0, j; + uint_t post, uint_t pre, uint_t channel) { + uint_t length = vec->length, i=channel, j; for (j=0;jdata[i][j] -= fvec_moving_thres(vec, tmp, post, pre, j); + vec->data[i][j] -= fvec_moving_thres(vec, tmp, post, pre, j, i); } } smpl_t fvec_moving_thres (fvec_t * vec, fvec_t * tmpvec, - uint_t post, uint_t pre, uint_t pos) + uint_t post, uint_t pre, uint_t pos, uint_t channel) { - smpl_t *medar = (smpl_t *) tmpvec->data[0]; - uint_t k; + uint_t i = channel, k; + smpl_t *medar = (smpl_t *) tmpvec->data[i]; uint_t win_length = post + pre + 1; uint_t length = vec->length; /* post part of the buffer does not exist */ @@ -320,12 +330,12 @@ fvec_moving_thres (fvec_t * vec, fvec_t * tmpvec, for (k = length - pos + post; k < win_length; k++) medar[k] = 0.; /* 0-padding at the end */ } - return fvec_median (tmpvec); + return fvec_median_channel (tmpvec, i); } -smpl_t fvec_median(fvec_t * input) { +smpl_t fvec_median_channel (fvec_t * input, uint_t channel) { uint_t n = input->length; - smpl_t * arr = (smpl_t *) input->data[0]; + smpl_t * arr = (smpl_t *) input->data[channel]; uint_t low, high ; uint_t median; uint_t middle, ll, hh; @@ -374,15 +384,15 @@ smpl_t fvec_median(fvec_t * input) { } } -smpl_t fvec_quadint(fvec_t * x,uint_t pos, uint_t span) { +smpl_t fvec_quadint (fvec_t * x, uint_t pos, uint_t i) { smpl_t s0, s1, s2; - uint_t x0 = (pos < span) ? pos : pos - span; - uint_t x2 = (pos + span < x->length) ? pos + span : pos; - if (x0 == pos) return (x->data[0][pos] <= x->data[0][x2]) ? pos : x2; - if (x2 == pos) return (x->data[0][pos] <= x->data[0][x0]) ? pos : x0; - s0 = x->data[0][x0]; - s1 = x->data[0][pos]; - s2 = x->data[0][x2]; + uint_t x0 = (pos < 1) ? pos : pos - 1; + uint_t x2 = (pos + 1 < x->length) ? pos + 1 : pos; + if (x0 == pos) return (x->data[i][pos] <= x->data[i][x2]) ? pos : x2; + if (x2 == pos) return (x->data[i][pos] <= x->data[i][x0]) ? pos : x0; + s0 = x->data[i][x0]; + s1 = x->data[i][pos]; + s2 = x->data[i][x2]; return pos + 0.5 * (s2 - s0 ) / (s2 - 2.* s1 + s0); } diff --git a/src/mathutils.h b/src/mathutils.h index be1b465f..31cf8b78 100644 --- a/src/mathutils.h +++ b/src/mathutils.h @@ -59,13 +59,23 @@ smpl_t aubio_unwrap2pi (smpl_t phase); /** compute the mean of a vector - \param s vector to compute norm from + \param s vector to compute mean from \return the mean of v */ smpl_t fvec_mean (fvec_t * s); +/** compute the mean of a vector channel + + \param s vector to compute mean from + \param i channel to compute mean from + + \return the mean of v + +*/ +smpl_t fvec_mean_channel (fvec_t * s, uint_t i); + /** find the max of a vector \param s vector to get the max from @@ -219,7 +229,7 @@ pre elements after pos. */ smpl_t fvec_moving_thres (fvec_t * v, fvec_t * tmp, uint_t post, uint_t pre, - uint_t pos); + uint_t pos, uint_t channel); /** apply adaptive threshold to a vector @@ -232,7 +242,8 @@ moving median threshold computed at p. \param pre length of anti-causal part to take after pos */ -void fvec_adapt_thres (fvec_t * v, fvec_t * tmp, uint_t post, uint_t pre); +void fvec_adapt_thres (fvec_t * v, fvec_t * tmp, uint_t post, uint_t pre, + uint_t channel); /** returns the median of a vector @@ -245,14 +256,15 @@ Devillard's implementation, available at http://ndevilla.free.fr/median/median/ and in the Public Domain. \param v vector to get median from + \param channel channel to get median from \return the median of v */ -smpl_t fvec_median (fvec_t * v); +smpl_t fvec_median_channel (fvec_t * v, uint_t channel); /** finds exact peak index by quadratic interpolation*/ -smpl_t fvec_quadint (fvec_t * x, uint_t pos, uint_t span); +smpl_t fvec_quadint (fvec_t * x, uint_t pos, uint_t channel); /** Quadratic interpolation using Lagrange polynomial. diff --git a/src/onset/onset.c b/src/onset/onset.c index 43af04cc..5b0f952e 100644 --- a/src/onset/onset.c +++ b/src/onset/onset.c @@ -36,22 +36,26 @@ struct _aubio_onset_t { smpl_t threshold; /**< onset peak picking threshold */ smpl_t silence; /**< silence threhsold */ uint_t minioi; /**< minimum inter onset interval */ - uint_t wasonset; /**< number of frames since last onset */ + fvec_t * wasonset; /**< number of frames since last onset */ uint_t samplerate; /**< sampling rate of the input signal */ }; /* execute onset detection function on iput buffer */ void aubio_onset_do (aubio_onset_t *o, fvec_t * input, fvec_t * onset) { - uint_t isonset = 0; - uint_t wasonset = o->wasonset; + smpl_t isonset = 0; + smpl_t wasonset = 0; + uint_t i; aubio_pvoc_do (o->pv,input, o->fftgrain); aubio_onsetdetection_do (o->od,o->fftgrain, o->of); /*if (usedoubled) { aubio_onsetdetection_do (o2,fftgrain, onset2); onset->data[0][0] *= onset2->data[0][0]; }*/ - isonset = aubio_peakpicker_do(o->pp, o->of); + aubio_peakpicker_do(o->pp, o->of, onset); + for (i = 0; i < input->channels; i++) { + isonset = onset->data[i][0]; + wasonset = o->wasonset->data[i][0]; if (isonset > 0.) { if (aubio_silence_detection(input, o->silence)==1) { isonset = 0; @@ -67,8 +71,9 @@ void aubio_onset_do (aubio_onset_t *o, fvec_t * input, fvec_t * onset) } else { wasonset++; } - o->wasonset = wasonset; - onset->data[0][0] = isonset; + o->wasonset->data[i][0] = wasonset; + onset->data[i][0] = isonset; + } return; } @@ -97,10 +102,11 @@ aubio_onset_t * new_aubio_onset (char_t * onset_mode, o->threshold = 0.3; o->minioi = 4; o->silence = -70; - o->wasonset = 0; + o->wasonset = new_fvec(1, channels); o->samplerate = samplerate; o->pv = new_aubio_pvoc(buf_size, hop_size, channels); - o->pp = new_aubio_peakpicker(o->threshold); + o->pp = new_aubio_peakpicker(channels); + aubio_peakpicker_set_threshold (o->pp, o->threshold); o->od = new_aubio_onsetdetection(onset_mode,buf_size,channels); o->fftgrain = new_cvec(buf_size,channels); o->of = new_fvec(1, channels); @@ -117,6 +123,7 @@ void del_aubio_onset (aubio_onset_t *o) del_aubio_peakpicker(o->pp); del_aubio_pvoc(o->pv); del_fvec(o->of); + del_fvec(o->wasonset); del_cvec(o->fftgrain); AUBIO_FREE(o); } diff --git a/src/onset/peakpick.c b/src/onset/peakpick.c index 029f7d2f..17b9a6a6 100644 --- a/src/onset/peakpick.c +++ b/src/onset/peakpick.c @@ -52,6 +52,9 @@ struct _aubio_peakpicker_t { /** scratch pad for biquad and median */ fvec_t * scratch; + /** number of channels to analyse */ + uint_t channels; + /** \bug should be used to calculate filter coefficients */ /* cutoff: low-pass filter cutoff [0.34, 1] */ /* smpl_t cutoff; */ @@ -67,54 +70,51 @@ struct _aubio_peakpicker_t { /** modified version for real time, moving mean adaptive threshold this method * is slightly more permissive than the offline one, and yelds to an increase * of false positives. best */ -smpl_t aubio_peakpicker_do(aubio_peakpicker_t * p, fvec_t * onset) { - fvec_t * onset_keep = (fvec_t *)p->onset_keep; - fvec_t * onset_proc = (fvec_t *)p->onset_proc; - fvec_t * onset_peek = (fvec_t *)p->onset_peek; - fvec_t * scratch = (fvec_t *)p->scratch; - smpl_t mean = 0., median = 0.; - smpl_t isonset = 0.; - uint_t length = p->win_post + p->win_pre + 1; - uint_t i = 0, j; - - /* store onset in onset_keep */ - /* shift all elements but last, then write last */ - /* for (i=0;idata[i][j] = onset_keep->data[i][j+1]; - onset_proc->data[i][j] = onset_keep->data[i][j]; - } - onset_keep->data[i][length-1] = onset->data[i][0]; - onset_proc->data[i][length-1] = onset->data[i][0]; - /* } */ - - /* filter onset_proc */ - /** \bug filtfilt calculated post+pre times, should be only once !? */ - aubio_biquad_do_filtfilt(p->biquad,onset_proc,scratch); - - /* calculate mean and median for onset_proc */ - /* for (i=0;ichannels;i++) { */ - mean = fvec_mean(onset_proc); - /* copy to scratch */ - for (j = 0; j < length; j++) - scratch->data[i][j] = onset_proc->data[i][j]; - median = p->thresholdfn(scratch); - /* } */ - - /* for (i=0;ichannels;i++) { */ - /* shift peek array */ - for (j=0;j<3-1;j++) - onset_peek->data[i][j] = onset_peek->data[i][j+1]; - /* calculate new peek value */ - onset_peek->data[i][2] = - onset_proc->data[i][p->win_post] - median - mean * p->threshold; - /* } */ - //AUBIO_DBG("%f\n", onset_peek->data[0][2]); - isonset = (p->pickerfn)(onset_peek,1); - if (isonset) { //(isonset) { - isonset = fvec_quadint(onset_peek, 1, 1); +void +aubio_peakpicker_do (aubio_peakpicker_t * p, fvec_t * onset, fvec_t * out) +{ + fvec_t *onset_keep = p->onset_keep; + fvec_t *onset_proc = p->onset_proc; + fvec_t *onset_peek = p->onset_peek; + fvec_t *scratch = p->scratch; + smpl_t mean = 0., median = 0.; + uint_t length = p->win_post + p->win_pre + 1; + uint_t i, j = 0; + + for (i = 0; i < p->channels; i++) { + /* store onset in onset_keep */ + /* shift all elements but last, then write last */ + for (j = 0; j < length - 1; j++) { + onset_keep->data[i][j] = onset_keep->data[i][j + 1]; + onset_proc->data[i][j] = onset_keep->data[i][j]; + } + onset_keep->data[i][length - 1] = onset->data[i][0]; + onset_proc->data[i][length - 1] = onset->data[i][0]; + } + + /* filter onset_proc */ + /** \bug filtfilt calculated post+pre times, should be only once !? */ + //aubio_biquad_do_filtfilt(p->biquad,onset_proc,scratch); + + for (i = 0; i < p->channels; i++) { + /* calculate mean and median for onset_proc */ + mean = fvec_mean_channel (onset_proc, i); + /* copy to scratch */ + for (j = 0; j < length; j++) + scratch->data[i][j] = onset_proc->data[i][j]; + median = p->thresholdfn (scratch, i); + + /* shift peek array */ + for (j = 0; j < 3 - 1; j++) + onset_peek->data[i][j] = onset_peek->data[i][j + 1]; + /* calculate new peek value */ + onset_peek->data[i][2] = + onset_proc->data[i][p->win_post] - median - mean * p->threshold; + out->data[i][0] = (p->pickerfn) (onset_peek, 1); + if (out->data[i][0]) { + out->data[i][0] = fvec_quadint (onset_peek, 1, i); + } } - return isonset; } /** this method returns the current value in the pick peaking buffer @@ -125,9 +125,8 @@ smpl_t aubio_peakpicker_get_thresholded_input(aubio_peakpicker_t * p) return p->onset_peek->data[0][1]; } -/** function added by Miguel Ramirez to return the onset detection amplitude in peakval */ uint_t aubio_peakpicker_set_threshold(aubio_peakpicker_t * p, smpl_t threshold) { - p->threshold = threshold; + p->threshold = threshold; return AUBIO_OK; } @@ -144,21 +143,21 @@ aubio_thresholdfn_t aubio_peakpicker_get_thresholdfn(aubio_peakpicker_t * p) { return (aubio_thresholdfn_t) (p->thresholdfn); } -aubio_peakpicker_t * new_aubio_peakpicker(smpl_t threshold) { +aubio_peakpicker_t * new_aubio_peakpicker(uint_t channels) { aubio_peakpicker_t * t = AUBIO_NEW(aubio_peakpicker_t); t->threshold = 0.1; /* 0.0668; 0.33; 0.082; 0.033; */ - if (threshold > 0. && threshold < 10.) - t->threshold = threshold; t->win_post = 5; t->win_pre = 1; + //channels = 1; + t->channels = channels; - t->thresholdfn = (aubio_thresholdfn_t)(fvec_median); /* (fvec_mean); */ + t->thresholdfn = (aubio_thresholdfn_t)(fvec_median_channel); /* (fvec_mean); */ t->pickerfn = (aubio_pickerfn_t)(fvec_peakpick); - t->scratch = new_fvec(t->win_post+t->win_pre+1,1); - t->onset_keep = new_fvec(t->win_post+t->win_pre+1,1); - t->onset_proc = new_fvec(t->win_post+t->win_pre+1,1); - t->onset_peek = new_fvec(3,1); + t->scratch = new_fvec(t->win_post+t->win_pre+1, channels); + t->onset_keep = new_fvec(t->win_post+t->win_pre+1, channels); + t->onset_proc = new_fvec(t->win_post+t->win_pre+1, channels); + t->onset_peek = new_fvec(3, channels); /* cutoff: low-pass filter cutoff [0.34, 1] */ /* t->cutoff=0.34; */ diff --git a/src/onset/peakpick.h b/src/onset/peakpick.h index 4c15eaf3..897ece4b 100644 --- a/src/onset/peakpick.h +++ b/src/onset/peakpick.h @@ -31,16 +31,16 @@ extern "C" { #endif /** function pointer to thresholding function */ -typedef smpl_t (*aubio_thresholdfn_t)(fvec_t *input); +typedef smpl_t (*aubio_thresholdfn_t)(fvec_t *input, uint_t channel); /** function pointer to peak-picking function */ typedef uint_t (*aubio_pickerfn_t)(fvec_t *input, uint_t pos); /** peak-picker structure */ typedef struct _aubio_peakpicker_t aubio_peakpicker_t; /** peak-picker creation function */ -aubio_peakpicker_t * new_aubio_peakpicker(smpl_t threshold); +aubio_peakpicker_t * new_aubio_peakpicker(uint_t channels); /** real time peak picking function */ -smpl_t aubio_peakpicker_do(aubio_peakpicker_t * p, fvec_t * DF); +void aubio_peakpicker_do(aubio_peakpicker_t * p, fvec_t * in, fvec_t * out); /** get current peak value */ smpl_t aubio_peakpicker_get_thresholded_input(aubio_peakpicker_t * p); /** destroy peak picker structure */ diff --git a/src/pitch/pitchmcomb.c b/src/pitch/pitchmcomb.c index 9e2f8dd2..d5c8f1b0 100644 --- a/src/pitch/pitchmcomb.c +++ b/src/pitch/pitchmcomb.c @@ -166,7 +166,7 @@ void aubio_pitchmcomb_spectral_pp(aubio_pitchmcomb_t * p, fvec_t * newmag) { fvec_alpha_normalise(mag,p->alpha); /* alpha normalisation */ /* skipped */ /* low pass filtering */ /** \bug fvec_moving_thres may write out of bounds */ - fvec_adapt_thres(mag,tmp,p->win_post,p->win_pre); /* adaptative threshold */ + fvec_adapt_thres(mag,tmp,p->win_post,p->win_pre,i); /* adaptative threshold */ fvec_add(mag,-p->threshold); /* fixed threshold */ { aubio_spectralpeak_t * peaks = (aubio_spectralpeak_t *)p->peaks; @@ -276,7 +276,7 @@ uint_t aubio_pitchmcomb_quadpick(aubio_spectralpeak_t * spectral_peaks, fvec_t * if (ispeak) { count += ispeak; spectral_peaks[count-1].bin = j; - spectral_peaks[count-1].ebin = fvec_quadint(X, j, 1) - 1.; + spectral_peaks[count-1].ebin = fvec_quadint(X, j, i) - 1.; } } return count; diff --git a/src/pitch/pitchyin.c b/src/pitch/pitchyin.c index 90891c6a..c80517cb 100644 --- a/src/pitch/pitchyin.c +++ b/src/pitch/pitchyin.c @@ -148,11 +148,11 @@ void aubio_pitchyin_do(aubio_pitchyin_t *o, fvec_t * input, fvec_t * out){ period = tau-3; if(tau > 4 && (yin->data[c][period] < tol) && (yin->data[c][period] < yin->data[c][period+1])) { - out->data[c][0] = fvec_quadint(yin,period,1); + out->data[c][0] = fvec_quadint(yin,period,c); goto beach; } } - out->data[c][0] = fvec_quadint(yin,fvec_min_elem(yin),1); + out->data[c][0] = fvec_quadint(yin,fvec_min_elem(yin),c); beach: continue; } diff --git a/src/pitch/pitchyinfft.c b/src/pitch/pitchyinfft.c index a4ab4065..4b70098e 100644 --- a/src/pitch/pitchyinfft.c +++ b/src/pitch/pitchyinfft.c @@ -131,14 +131,14 @@ void aubio_pitchyinfft_do (aubio_pitchyinfft_t * p, fvec_t * input, fvec_t * out //return fvec_quadint_min(yin,tau,1); /* additional check for (unlikely) octave doubling in higher frequencies */ if (tau>35) { - output->data[i][0] = fvec_quadint(yin,tau,1); + output->data[i][0] = fvec_quadint(yin,tau,i); } else { /* should compare the minimum value of each interpolated peaks */ halfperiod = FLOOR(tau/2+.5); if (yin->data[0][halfperiod] < p->tol) - output->data[i][0] = fvec_quadint(yin,halfperiod,1); + output->data[i][0] = fvec_quadint(yin,halfperiod,i); else - output->data[i][0] = fvec_quadint(yin,tau,1); + output->data[i][0] = fvec_quadint(yin,tau,i); } } else { output->data[i][0] = 0.; diff --git a/src/tempo/beattracking.c b/src/tempo/beattracking.c index 4dd1d999..78c4b49e 100644 --- a/src/tempo/beattracking.c +++ b/src/tempo/beattracking.c @@ -169,7 +169,7 @@ aubio_beattracking_do (aubio_beattracking_t * bt, fvec_t * dfframe, /* find non-zero Rayleigh period */ maxindex = fvec_max_elem (bt->acfout); - bt->rp = maxindex ? fvec_quadint (bt->acfout, maxindex, 1) : 1; + bt->rp = maxindex ? fvec_quadint (bt->acfout, maxindex, 0) : 1; //rp = (maxindex==127) ? 43 : maxindex; //rayparam bt->rp = (maxindex == bt->acfout->length - 1) ? bt->rayparam : maxindex; //rayparam @@ -202,7 +202,7 @@ aubio_beattracking_do (aubio_beattracking_t * bt, fvec_t * dfframe, #endif /* AUBIO_BEAT_WARNINGS */ phase = step - bt->lastbeat; } else { - phase = fvec_quadint (bt->phout, maxindex, 1); + phase = fvec_quadint (bt->phout, maxindex, 0); } /* take back one frame delay */ phase += 1.; @@ -304,7 +304,7 @@ aubio_beattracking_checkstate (aubio_beattracking_t * bt) } } fvec_weight (acfout, bt->gwv); - gp = fvec_quadint (acfout, fvec_max_elem (acfout), 1); + gp = fvec_quadint (acfout, fvec_max_elem (acfout), 0); /* while(gp<32) gp =gp*2; while(gp>64) gp = gp/2; @@ -408,7 +408,7 @@ smpl_t aubio_beattracking_get_bpm (aubio_beattracking_t * bt) { if (bt->timesig != 0 && bt->counter == 0 && bt->flagstep == 0) { - return 5168. / fvec_quadint (bt->acfout, bt->bp, 1); + return 5168. / fvec_quadint (bt->acfout, bt->bp, 0); } else { return 0.; } diff --git a/src/tempo/tempo.c b/src/tempo/tempo.c index af091908..acba1948 100644 --- a/src/tempo/tempo.c +++ b/src/tempo/tempo.c @@ -37,6 +37,8 @@ struct _aubio_tempo_t { fvec_t * of; /** onset detection function value */ fvec_t * dfframe; /** peak picked detection function buffer */ fvec_t * out; /** beat tactus candidates */ + fvec_t * onset; /** onset results */ + fvec_t * peek; /** thresholded onset function */ smpl_t silence; /** silence parameter */ smpl_t threshold; /** peak picking threshold */ sint_t blockpos; /** current position in dfframe */ @@ -69,7 +71,8 @@ void aubio_tempo_do(aubio_tempo_t *o, fvec_t * input, fvec_t * tempo) o->blockpos = -1; } o->blockpos++; - tempo->data[0][1] = aubio_peakpicker_do (o->pp, o->of); + aubio_peakpicker_do (o->pp, o->of, o->onset); + tempo->data[0][1] = o->onset->data[0][0]; o->dfframe->data[0][winlen - step + o->blockpos] = aubio_peakpicker_get_thresholded_input(o->pp); /* end of second level loop */ @@ -114,10 +117,13 @@ aubio_tempo_t * new_aubio_tempo (char_t * onset_mode, o->fftgrain = new_cvec(buf_size, channels); o->out = new_fvec(o->step,channels); o->pv = new_aubio_pvoc(buf_size, hop_size, channels); - o->pp = new_aubio_peakpicker(o->threshold); + o->pp = new_aubio_peakpicker(channels); + aubio_peakpicker_set_threshold (o->pp, o->threshold); o->od = new_aubio_onsetdetection(onset_mode,buf_size,channels); o->of = new_fvec(1, channels); o->bt = new_aubio_beattracking(o->winlen,channels); + o->onset = new_fvec(1, channels); + o->peek = new_fvec(3, channels); /*if (usedoubled) { o2 = new_aubio_onsetdetection(type_onset2,buffer_size,channels); onset2 = new_fvec(1 , channels); @@ -143,6 +149,8 @@ void del_aubio_tempo (aubio_tempo_t *o) del_fvec(o->of); del_cvec(o->fftgrain); del_fvec(o->dfframe); + del_fvec(o->onset); + del_fvec(o->peek); AUBIO_FREE(o); return; } diff --git a/tests/src/test-peakpick.c b/tests/src/test-peakpick.c index 81c8e7fc..7cf0deb5 100644 --- a/tests/src/test-peakpick.c +++ b/tests/src/test-peakpick.c @@ -5,12 +5,14 @@ int main(){ uint_t win_s = 1024; /* window size */ uint_t channels = 1; /* number of channel */ fvec_t * in = new_fvec (win_s, channels); /* input buffer */ - aubio_peakpicker_t * o = new_aubio_peakpicker(0.3); + fvec_t * out = new_fvec (1, channels); /* input buffer */ + aubio_peakpicker_t * o = new_aubio_peakpicker(1); + aubio_peakpicker_set_threshold (o, 0.3); - aubio_peakpicker_do(o, in); - aubio_peakpicker_do(o, in); - aubio_peakpicker_do(o, in); - aubio_peakpicker_do(o, in); + aubio_peakpicker_do(o, in, out); + aubio_peakpicker_do(o, in, out); + aubio_peakpicker_do(o, in, out); + aubio_peakpicker_do(o, in, out); del_aubio_peakpicker(o); del_fvec(in); -- 2.26.2