
Show Audio Information While Playing Sound #77
Chapter 10, Audio
|
395
HACK
Testing It Out
Launch the DataLineGUI application and you’ll get a file-selection dialog.
Choose a suitable AIFF or WAV, and you’ll see the GUI shown in
Figure 10-8.
This is all well and good for a simple GUI, but there’s one problem: where
the heck is our level meter?! It should be between the filename and the text
area, but it’s totally not there!
Initially, I suspected my repaint code was hosed, but it all seemed correct.
So, right after figuring out the meter width, I added a sanity-check debug
line:
System.out.println ("level = " + level);
And when I ran it, I got a result that I really didn’t want to see:
[aeris:HacksBook/Media/x11] cadamson% java DataLineInfoGUI
got PCM format
got info
got line
opened line
level = 0.0
level = 0.0
level = 0.0
level = 0.0
level = 0.0
And that was on a really loud song, so it wasn’t just a slow fade in. I looked
around to see if there was something special you have to do for
getLevel( )
to work, but there wasn’t.
Figure 10-8. Audio player display with format information