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

后端 未结 2 1608
半阙折子戏
半阙折子戏 2021-02-10 04:34

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

How should I go about this? Is there anything in the Java So

2条回答
  •  耶瑟儿~
    2021-02-10 04:52

    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.).

提交回复
热议问题