From: Paul Brossier Date: Sun, 11 Oct 2009 10:38:43 +0000 (+0200) Subject: src/spectral/fft.c: 0 and N/2 + 1 phase must carry the sign of respective real components X-Git-Tag: bzr2git~142 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=897975259f6fdea0ea011c8f3f3f77652b968682;p=aubio.git src/spectral/fft.c: 0 and N/2 + 1 phase must carry the sign of respective real components --- 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.; + } } }