# FFT “Brick Wall” Low Pass Filter Not Smoothing Output

I'll try to be as brief as possible. I have very limited signal processing experience. I have a data set that consists of essentially a big old sine function (with deviations from ideality), and lots of high-frequency noise (what I don't want). I desiced on a low pass filter because it doesn't change amplitude much or significantly shift peak/band locations.

I played around with QTIplot (scientific plotting soft-ware) and found I can smooth the dataset quite well by simply doing a FFT Low pass filter with a 1Hz cut-off (seem image below). So I looked at the source code in QTI plot to get an idea of how they implemented it. It turns out it's a brick wall algorithm. Their code goes like this -

//(C) 2007 - 2008 by Ion Vasilief, Knut Franke

double df = 1.0/(double)(d_n*(x-x));//Sampling frequency
gsl_fft_real_workspace *work = gsl_fft_real_workspace_alloc(d_n);
gsl_fft_real_wavetable *real = gsl_fft_real_wavetable_alloc(d_n);
gsl_fft_real_transform (y, 1, d_n, real, work);//FFT forward
gsl_fft_real_wavetable_free (real);
...
//Brick wall
for (int i = 0; i < d_n && ((i+1)/2)*df < d_low_freq; i++)
y[i] = 0;
break;
gsl_fft_halfcomplex_wavetable *hc = gsl_fft_halfcomplex_wavetable_alloc(d_n);
gsl_fft_halfcomplex_inverse (y, 1, d_n, hc, work);
gsl_fft_halfcomplex_wavetable_free (hc);
gsl_fft_real_workspace_free (work);


So I borrowed from their code but translated it into JAVA and decided on using the JTransforms FFT library. The JTransforms FFT library leaves the first two index positions for storage of the transform and the rest of the indices are alternating Re, Im components ("Bins").

    int size = recievedData.size();
DoubleFFT_1D fftDo = new DoubleFFT_1D(recievedData.size());
double fft[] = new double[size*2];
fftDo.realForwardFull(fft);
double df = 1.0/(((double)size)*(0.027413951));
for(int i = 2; i < 2*size && (((double)i+1.00)/2.00)*df < cutOffFreq; i++){
fft[i] = 0.0;
}
fftDo.complexInverse(fft, false);


Now when I run my code I see no real noise reduction. Sometimes I see the minima of my signals increase to some weird baseline, if I allow the FFTinverse to scale my code sometimes I see all blocks. Ultimately it seems the code does little to nothing to my signal, while the QTIPlot code is exactly what I want.

So a couple questions: - What am I doing wrong in my code? Or is it the library differences (GSL vs JTransforms)? - Is there a better way to do this kind of filtering? If so can you take me to a resource to learn how it's implemented. I read about using masks everywhere but could not find a single example of them that wasn't "hard-coded", IE: my data may be dynamic. Seems most people who did masks like to show pictures but not detail how to implement them even in lecture powerpoints from universities.

Also this is not for homework or anything I'm just playing around with an electronics project.