title: Calculating the DFT with Jtransform's DoubleFFT_1D() for android
body: <p>I have been searching everywhere to find a reliable method to calculate the FFT of an audio byte stream received by a native function in android SDK (through eclipse IDE). I have come across the libgdx fft and Jtransform. Jtransform Found here
  <a href="http://sites.google.com/site/piotrwendykier/software/jtransforms" rel="nofollow">JTransform</a>
  .
  I have downloaded them all and added the .jar files to a created libs folder in the root directory for the project. I have then linked the project to the new .jar files through project properties > java Build Path > Libraries. </p>
  
  <p>My src java file looks like this attempting to use Jtransform.</p>
  
  <pre><code>package com.spectrum;
  import android.app.Activity;
  import android.graphics.Bitmap;
  import android.graphics.BitmapFactory;
  import android.media.AudioFormat;
  import android.media.AudioManager;
  import android.media.AudioTrack;
  import android.media.MediaPlayer;
  import android.os.Bundle;
  import android.widget.LinearLayout;
  import android.widget.TextView;
  import android.view.View;
  
  import com.badlogic.gdx.audio.analysis.*;
  import edu.emory.mathcs.jtransforms.fft.*;
  import edu.emory.mathcs.utils.*; 
  
  public class spectrum extends Activity {
  static byte [] sin = null;
  static int f = 2000;
  static int fs = 44100;
  double buf;
  
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      //initialize(new SpectrumDesktop(), false);
  
      sin = playsin(f,fs);
      buf = bytearray2double(sin);
      public DoubleFFT_1D(512);        //&lt;Undefined&gt;
      public void complexForward(sin)  //&lt;Undefined&gt;
      playsound(sin);
  
  }
  public static double bytearray2double(byte[] b) {  
            ByteBuffer buf = ByteBuffer.wrap(b);  
            return buf.getDouble();  
        }  
  
   private void playsound(byte[] sin2){
  
  int intSize = android.media.AudioTrack.getMinBufferSize(44100,     AudioFormat.CHANNEL_CONFIGURATION_STEREO,
              AudioFormat.ENCODING_PCM_16BIT);
  
  AudioTrack at = new AudioTrack(AudioManager.STREAM_MUSIC, 44100, AudioFormat.CHANNEL_CONFIGURATION_STEREO,
              AudioFormat.ENCODING_PCM_16BIT, intSize, AudioTrack.MODE_STREAM);
  
  at.play();
  at.write(sin2, 0, sin2.length ); 
  at.stop();
  at.release();
  
  }
  
  @Override
  protected void onDestroy() {
      super.onDestroy();
      // TODO Auto-generated method stub
      if (mMediaPlayer != null) {
          mMediaPlayer.release();
          mMediaPlayer = null;
      }
  
  }
  
   public native byte[] playsin(int f,int fs);
  
   /** Load jni .so on initialisation */
   static {
     System.loadLibrary("SPL");
  }
  }
  </code></pre>
  
  <p>In this example I am only using the Jtransform packages, however I have been getting the same compile error for the lingdx packages. The compiler says that DoubleFFT_1D and complexForward are undefined.
  So there is something I am missing, like not linking my libraries correctly, I am not sure.
  Any help would be greatly appreciated. Am I meant to declare an instance of DoubleFFT_1D and complexForward before onCreate or something?</p>
  
  <p>I know this is a noob question, but I am new to object oriented languages and learning java on the go. Thanks :)</p>