From: Paul Brossier Date: Sat, 24 Nov 2007 16:44:49 +0000 (+0100) Subject: pitchmcomb.c: make sure all variables are initialised X-Git-Tag: bzr2git~444 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=9638f84d04e7bcb586509f9219f03fb97c14df14;p=aubio.git pitchmcomb.c: make sure all variables are initialised --- diff --git a/src/pitchmcomb.c b/src/pitchmcomb.c index b0cfa997..20120025 100644 --- a/src/pitchmcomb.c +++ b/src/pitchmcomb.c @@ -191,7 +191,7 @@ void aubio_pitchmcomb_combdet(aubio_pitchmcomb_t * p, fvec_t * newmag) { uint_t k; uint_t l; uint_t d; - uint_t curlen; + uint_t curlen = 0; smpl_t delta2; smpl_t xx; @@ -213,7 +213,8 @@ void aubio_pitchmcomb_combdet(aubio_pitchmcomb_t * p, fvec_t * newmag) { candidate[l]->len = 0.; candidate[l]->ebin=scaler*peaks[root_peak].ebin; /* if less than N peaks available, curlen < N */ - curlen = (uint_t)FLOOR(length/(candidate[l]->ebin)); + if (candidate[l]->ebin != 0.) + curlen = (uint_t)FLOOR(length/(candidate[l]->ebin)); curlen = (N < curlen )? N : curlen; /* fill candidate[l]->ecomb[k] with (k+1)*candidate[l]->ebin */ for (k=0;k post+pre+1 */ - uint_t i; + uint_t i, j; uint_t spec_size; p->spec_partition = 4; p->ncand = 5; @@ -352,11 +353,22 @@ aubio_pitchmcomb_t * new_aubio_pitchmcomb(uint_t bufsize, uint_t hopsize, uint_t p->scratch2 = new_fvec(p->win_post+p->win_pre+1,channels); /* array of spectral peaks */ p->peaks = AUBIO_ARRAY(aubio_spectralpeak_t,spec_size); + for (i = 0; i < spec_size; i++) { + p->peaks[i].bin = 0.; + p->peaks[i].ebin = 0.; + p->peaks[i].mag = 0.; + } /* array of pointers to spectral candidates */ p->candidates = AUBIO_ARRAY(aubio_spectralcandidate_t *,p->ncand); for (i=0;incand;i++) { p->candidates[i] = AUBIO_NEW(aubio_spectralcandidate_t); p->candidates[i]->ecomb = AUBIO_ARRAY(smpl_t, spec_size); + for (j=0; j < spec_size; j++) { + p->candidates[i]->ecomb[j] = 0.; + } + p->candidates[i]->ene = 0.; + p->candidates[i]->ebin = 0.; + p->candidates[i]->len = 0.; } return p; } @@ -370,6 +382,7 @@ void del_aubio_pitchmcomb (aubio_pitchmcomb_t *p) { del_fvec(p->scratch2); AUBIO_FREE(p->peaks); for (i=0;incand;i++) { + AUBIO_FREE(p->candidates[i]->ecomb); AUBIO_FREE(p->candidates[i]); } AUBIO_FREE(p->candidates);