
378
|
Chapter 10, Audio
#75 Build an Audio Waveform Display
HACK
Even better, if you have a custom install program, make it run the JMF and
MP3 installers first. If you don’t have an installer or don’t know which plat-
form the program will be installed on, use the cross-platform versions (also
available from the URLs mentioned in this hack). They are slower but are
completely written in Java so they can run on anything.
H A C K
#75
Build an Audio Waveform Display Hack #75
With a little understanding of audio data formats, you can easily build a basic
graphical audio display.
Representing audio visually is extremely useful. You can use waveform dis-
plays to quickly tell audio files apart, like a file thumbnail, or for non-linear
editing, such as deleting parts of the file and processing.
Figure 10-4 shows a waveform displayed in Audacity, a free, open source
audio editing application. This hack shows you how to build a basic wave-
form display from raw audio data.
The end result of this hack is displayed in Figure 10-5. You’ll start by read-
ing in the entire audio file using an
AudioInputStream. Then you’ll convert
the raw data from the stream into useful audio samples, organized by chan-
nel. With the converted channel audio data, you’ll create a single waveform
Figure 10-4. Audacity with an audio waveform displayed