11
Before, I asked question about Get frequency wav audio using FFT and Complex class ,
There, I need to calculate FFT value from AudioRecord input --> from microphone , I somehow managed to get the FFT value...
Now I need to calculate FFT value from *.wav audio file that I saved before, I saved the audio in 'raw' folder inside 'res' folder from my project
I still using the same FFT Class: http://www.cs.princeton.edu/introcs/97data/FFT.java
The complex class to go with it: http://introcs.cs.princeton.edu/java/97data/Complex.java.html
I use this method to read audio file from my raw foldern, then I call method calculateFFT to go with it
private static final int RECORDER_BPP = 16;
private static final int RECORDER_SAMPLERATE = 44100;
private static final int RECORDER_CHANNELS = AudioFormat.CHANNEL_IN_STEREO;
private static final int RECORDER_AUDIO_ENCODING = AudioFormat.ENCODING_PCM_16BIT;
private void asli(){
int counter = 0;
int data;
InputStream inputStream = getResources().openRawResource(R.raw.b1);
DataInputStream dataInputStream = new DataInputStream(inputStream);
List<Integer> content = new ArrayList<Integer>();
try {
while ((data = dataInputStream.read()) != -1) {
content.add(data);
counter++; }
} catch (IOException e) {
e.printStackTrace();}
int[] b = new int[content.size()];
int cont = 0;
byte[] audio = convertArray(b);
}
Method to convert to byte
public