}
// Get an input stream from an audio file
public static AudioInputStream openInputStream(String filename, AudioFormat format) throws IOException, UnsupportedAudioFileException
{
AudioInputStream stream = null;
stream = AudioSystem.getAudioInputStream(new File(filename));
//System.out.println(stream.getFormat());
AudioFormat baseFormat = stream.getFormat();
AudioFormat decodedFormat =
new AudioFormat(AudioFormat.Encoding.PCM_SIGNED,
baseFormat.getSampleRate(),
16,
baseFormat.getChannels(),
baseFormat.getChannels() * 2,
baseFormat.getSampleRate(),
bigEndian);
stream = AudioSystem.getAudioInputStream(decodedFormat, stream);
//System.out.println(stream.getFormat());
// convert to stereo PCM before converting to mono -
// without this line the conversion process will crap out
// on stereo MP3s. But the conversion from mono to stereo
// is unsupported for some reason...
if(stream.getFormat().getChannels() >= 2)
//stream = AudioSystem.getAudioInputStream(MEAPUtil.stereo, stream);
stream = AudioSystem.getAudioInputStream(
new AudioFormat(format.getSampleRate(), bitsPerSamp, 2,
signed, bigEndian),
stream);