简体   繁体   中英

Display sound (.wav/.mp3) as graph in Java

I need to display a graph of a sound file - ie a wave form as displayed by audio editors such as Audacity.

How should I go about this? Is there anything in the Java Sound API that can help me?

In Java Sound API poke around AudioSystem.getAudioInputStream which will return AudioInputStream which shows you how to open audio files form within Java. It is good enough to read .wav files, but not quite so for mp3s.

It lets you read bytes one by one directly. Also getAudioFormat will return object that has sample rate, bit/sample, etc. After reading your waveform you can draw it in your favorite way on the screen (Swing, AWT, png file on the web, etc.).

最后,我发现代码在Swing Hacks一书的第10章中完全符合我的要求。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM