title: How to Read MP3
body: <p>Using <a href="https://stackoverflow.com/questions/938304/how-to-get-audio-data-from-a-mp3" title="this post">this post</a> I was able to find out how to read mp3 files, but I'm still confused as to how to actually use this.</p>
  
  <pre><code>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);
  </code></pre>
  
  <p>After these declarations, how do you use <code>din</code>? I know the loop would look something like this:</p>
  
  <pre><code>while (/*What do I put here??*/){
      int currentByte = din.read();
  }
  </code></pre>
  
  <p>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.</p>