fft.c: if real part is zero, have phase = 0
authorPaul Brossier <piem@piem.org>
Sat, 1 Dec 2007 18:16:56 +0000 (19:16 +0100)
committerPaul Brossier <piem@piem.org>
Sat, 1 Dec 2007 18:16:56 +0000 (19:16 +0100)
src/spectral/fft.c

index 8bff6ac192d6c4b9afcade2689b169b04255a1d8..6c8c578a2fce07f6d26182dd33e3b7e2bac62be9 100644 (file)
@@ -154,6 +154,8 @@ void aubio_fft_get_phas(fvec_t * compspec, cvec_t * spectrum) {
   for (i = 0; i < spectrum->channels; i++) {
     spectrum->phas[i][0] = 0.;
     for (j=1; j < spectrum->length - 1; j++) {
+      if (compspec->data[i][j] == 0.) spectrum->phas[i][j] = 0;
+      else
       spectrum->phas[i][j] = atan2f(compspec->data[i][compspec->length-j],
           compspec->data[i][j]);
     }