title: Java/Android - Distorted Audio using FFT in realtime
body: <p>this question is most relevant for users with experience using the <a href="http://sites.google.com/site/piotrwendykier/software/jtransforms" rel="nofollow" title="JTransform">JTransform</a> package for Fast Fourier Transforms. I'm attempting to eventually create an equalizer as part of a larger realtime audio project. Right now I was simply attempting to apply the Fourier transform, then use the inverse method to get back the original data, then output that audio. What I'm getting is highly distorted audio. I wonder if anyone has any experience doing this sort of thing?</p>
  
  <p>I apply the transform in a callback method after sampling the audio input.</p>
  
  <pre><code>public void onMarkerReached(AudioRecord recorder)
   double[] input = new double[buffers[ix].length];
  for(int i=0;i&lt;input.length;i++)
              {
                  input[i] = (double)buffers[ix][i];
              }
  DoubleFFT_1D ft = new DoubleFFT_1D(input.length);
              ft.realForward(input);
              //some filtering here
              ft.realInverse(input, false);
              for(int i=0;i&lt;input.length;i++)
              {
                  buffers[ix][i] = (short)input[i];
              }
  
  
                  player.write(buffers[ix], 0,
                          buffers[ix].length);
  }
  }
  </code></pre>
  
  <p>Am I losing part of the signal as a result of only keeping the real part of the transform? Since it's only audio data the input should be real-only, right? Not sure what I'm doing wrong here, any input would be greatly appreciated!</p>