Java Sound APIを使用して、InputStream
含まれているデータを MP3 ファイルからに変換しようとしています。AudioInputStream
しかし、Exception
そうしようとすると、遭遇し続けます。
問題を引き起こす方法は次のとおりです。
public static int[][] getAmpFromInputStream(InputStream is) throws Exception{
BufferedInputStream bs = new BufferedInputStream(is);
AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(bs);
byte[] bytes = new byte[(int) (audioInputStream.getFrameLength()) * (audioInputStream.getFormat().getFrameSize())];
audioInputStream.read(bytes);
// Get amplitude values for each audio channel in an array.
return getUnscaledAmplitude(bytes, 1);
}
Exception
スローされるのは次のとおりです。
javax.sound.sampled.UnsupportedAudioFileException: could not get audio input stream from input stream
at javax.sound.sampled.AudioSystem.getAudioInputStream(Unknown Source)
at PitchChanger.getAmpFromInputStream(PitchChanger.java:27)
at GUI$PlayMP3Thread.silly(GUI.java:128)
at GUI$PlayMP3Thread.run(GUI.java:115)
at java.lang.Thread.run(Unknown Source)
しかし、これは私を混乱させます.同じものを使っInputStream
てJavazoom.jl.player.Player
.
では、なぜ をInputStream
に変換できないのAudioInputStream
でしょうか。
Java Sound は MP3 ファイル形式をサポートしていませんか?