From 897975259f6fdea0ea011c8f3f3f77652b968682 Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Sun, 11 Oct 2009 12:38:43 +0200 Subject: [PATCH] src/spectral/fft.c: 0 and N/2 + 1 phase must carry the sign of respective real components --- src/spectral/fft.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/spectral/fft.c b/src/spectral/fft.c index 2aea246d..c3af6a2d 100644 --- a/src/spectral/fft.c +++ b/src/spectral/fft.c @@ -183,12 +183,20 @@ void aubio_fft_get_realimag(cvec_t * spectrum, fvec_t * compspec) { void aubio_fft_get_phas(fvec_t * compspec, cvec_t * spectrum) { uint_t i, j; for (i = 0; i < spectrum->channels; i++) { - spectrum->phas[i][0] = 0.; + if (compspec->data[i][0] < 0) { + spectrum->phas[i][0] = PI; + } else { + spectrum->phas[i][0] = 0.; + } for (j=1; j < spectrum->length - 1; j++) { spectrum->phas[i][j] = ATAN2(compspec->data[i][compspec->length-j], compspec->data[i][j]); } - spectrum->phas[i][spectrum->length-1] = 0.; + if (compspec->data[i][compspec->length/2] < 0) { + spectrum->phas[i][spectrum->length - 1] = PI; + } else { + spectrum->phas[i][spectrum->length - 1] = 0.; + } } } -- 2.26.2