From 1cd8565fb32daaaa0841d7dc14c809932c1b9b46 Mon Sep 17 00:00:00 2001 From: "Charles J. Cliffe" Date: Fri, 31 Oct 2014 20:41:49 -0400 Subject: [PATCH] Experiment to remove DC / other spikes Seemed logical to use the repeating parts of the forward/back FFT results to overlap and cancel out spikes -- seems to work? --- src/PrimaryGLContext.cpp | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/src/PrimaryGLContext.cpp b/src/PrimaryGLContext.cpp index 86ff2cf..984c842 100644 --- a/src/PrimaryGLContext.cpp +++ b/src/PrimaryGLContext.cpp @@ -153,7 +153,6 @@ void TestGLCanvas::setData(std::vector *data) { in[i][1] = (double) (*data)[i * 2 + 1] / 127.0f; } - fftw_execute(plan[0]); fftw_execute(plan[1]); @@ -162,10 +161,14 @@ void TestGLCanvas::setData(std::vector *data) { for (int j = 0; j < 2; j++) { for (int i = 0, iMax = FFT_SIZE / 2; i < iMax; i++) { - double a = out[j][i][0]; - double b = out[j][i][1]; - + double a = out[j][j?i:((iMax-1)-i)][0]; + double b = out[j][j?i:((iMax-1)-i)][1]; double c = sqrt(a * a + b * b); + + double x = out[j?0:1][j?((FFT_SIZE-1)-i):((FFT_SIZE/2)+i)][0]; + double y = out[j?0:1][j?((FFT_SIZE-1)-i):((FFT_SIZE/2)+i)][1]; + double z = sqrt(x * x + y * y); + if (i == 1) { fft_floor = fft_ceil = c; } else if (i < FFT_SIZE - 1) { @@ -178,20 +181,10 @@ void TestGLCanvas::setData(std::vector *data) { } if (!j) { - result[((FFT_SIZE/2)-1) - i] = c; + result[i] = (c