I am using Java in android studio to write my application. I have a file path to an audio file (in .wav format), What would be the best method to read the .wav file into a byte array? I am using the following conversion method:
public void open_audio_file(Uri filePath){
try{
in = new BufferedInputStream(getContext().getContentResolver().openInputStream(filePath));
int read;
byte[] buff = new byte[1024];
while ((read = in.read(buff)) > 0)
{
out.write(buff, 0, read);
}
out.flush();
}catch(Exception e){
throw new RuntimeException(e);
}
//Todo : Change the audio file to a float pointer
audioBytes = out.toByteArray();
Log.i(LOG_TAG,"The audio file is " + audioBytes.toString());
}
However, this method produces a lot of jargon values that are not read by my function. For example, the output of dog.wav www.beaniebestbuy.com/sounds/dog5.wav was [B@d25663f . There are jargon values attached to the beginning of the array.
Update 1 : I tried to use the AudioSystem library, but it is not supported in Android studio.