Using this post I was able to find out how to read mp3 files, but I'm still confused as to how to actually use this.
File file = new File(filename);
AudioInputStream in= AudioSystem.getAudioInputStream(file);
AudioInputStream din = null;
AudioFormat baseFormat = in.getFormat();
AudioFormat decodedFormat = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED,
baseFormat.getSampleRate(),
16,
baseFormat.getChannels(),
baseFormat.getChannels() * 2,
baseFormat.getSampleRate(),
false);
din = AudioSystem.getAudioInputStream(decodedFormat, in);
After these declarations, how do you use din
? I know the loop would look something like this:
while (/*What do I put here??*/){
int currentByte = din.read();
}
In other words, I'm just asking how to read the entire array of bytes from the mp3 file, inspecting them one at a time in a loop.