From: Paul Brossier Date: Mon, 21 Sep 2009 16:15:05 +0000 (+0200) Subject: src/spectral/fft.c: fix horrible bug where norm[0] and norm[n/2+1] could be negative X-Git-Tag: bzr2git~334 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=d53a3b571cd8b545b3bba1d08868f8522894484d;p=aubio.git src/spectral/fft.c: fix horrible bug where norm[0] and norm[n/2+1] could be negative --- diff --git a/src/spectral/fft.c b/src/spectral/fft.c index 31159a56..7c770832 100644 --- a/src/spectral/fft.c +++ b/src/spectral/fft.c @@ -169,12 +169,13 @@ void aubio_fft_get_phas(fvec_t * compspec, cvec_t * spectrum) { void aubio_fft_get_norm(fvec_t * compspec, cvec_t * spectrum) { uint_t i, j = 0; for (i = 0; i < spectrum->channels; i++) { - spectrum->norm[i][0] = compspec->data[i][0]; + spectrum->norm[i][0] = ABS(compspec->data[i][0]); for (j=1; j < spectrum->length - 1; j++) { spectrum->norm[i][j] = SQRT(SQR(compspec->data[i][j]) + SQR(compspec->data[i][compspec->length - j]) ); } - spectrum->norm[i][spectrum->length-1] = compspec->data[i][compspec->length/2]; + spectrum->norm[i][spectrum->length-1] = + ABS(compspec->data[i][compspec->length/2]); } }