I am working on my final project, hence I need to read wav file - I succeed to do it.
When I run the code in java it is take less then 1 sec, but when I try to run the code on Nexus 5, it is take almost 1 minute!!
It is take a lot of time to copy the (sb.get(i))
to original_signal[i]
.
for (int i = 0; i < 1710080; i++) {
original_signal[i] = (sb.get(i));
}
Please, need help, Thanks!!!
public static void jjjj(){
String filepath = Environment.getExternalStorageDirectory().getAbsolutePath() + "/ilia.wav";
Wave wave = new Wave(filepath);
byte[] arr = wave.getBytes();
System.out.println();
wave.length();
ByteBuffer bb = ByteBuffer.wrap(arr);
System.out.println(bb.capacity());
bb.order(ByteOrder.LITTLE_ENDIAN);
ShortBuffer sb = bb.asShortBuffer();
original_signal = new double[1710080];
// double firstSample;
//THIS FOR LOOP TAKE A LOF OF TIME
for (int i = 0; i < 1710080; i++) {
original_signal[i] = (sb.get(i));
}
System.out.println("sss");
}
I solved the issue
Wave wave = new Wave(filepath);
double[] original_signal = wave.getNormalizedAmplitudes();
System.out.println(wave.getWaveHeader());
Parameters.Fs = wave.getWaveHeader().getSampleRate();
return original_signal;