Calculating the DFT With Jtransform

Share Embed Donate


Short Description

Download Calculating the DFT With Jtransform...

Description

Calculating the DFT with Jtransform's DoubleFFT_1D() for android 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 JTransform . 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. My src java file looks like this attempting to use Jtransform. 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); // public void complexForward(sin) // 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");

} }

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? I know this is a noob question, but I am new to object oriented languages and learning java on the go. Thanks :)

View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF