From d53a3b571cd8b545b3bba1d08868f8522894484d Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Mon, 21 Sep 2009 18:15:05 +0200 Subject: [PATCH] src/spectral/fft.c: fix horrible bug where norm[0] and norm[n/2+1] could be negative --- src/spectral/fft.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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]); } } -- 2.26.2