Chapter 10, Audio
#77 Show Audio Information While Playing Sound
Then I Googled, and found this post to the javasound-interest mailing list
from February 2003:
Date: Mon, 17 Feb 2003 22:31:21 -0800
Reply-To: Discussion list for JavaSound API
Sender: Discussion list for JavaSound API
From: Florian Bomers <Florian.Bomers@SUN.COM>
Organization: Sun Microsystems Inc.
Subject: Re: DataLine.getLevel( )?
Comments: To: email@example.com
Content-Type: text/plain; charset=us-ascii
Unfortunately, it is not implemented. (actually, in my private opinion, it
is a questionable method anyway: usually soundcard drivers do not provide
such a primitive, so the Java Sound implementation has to calculate this
"level" on its own. But there are many different algorithms to do so, suited
depending for what the "level" is needed for, and it would possibly eat
unnecessarily processor resources. So I guess it's best if everybody does
the calculation of the "level" on his own on the buffers received by the TDL
or written to the SDL, respectively. Easy and fast algorithms are maximum,
moving average,block average, power).
Knute Johnson wrote:
> Anybody know if DataLine.getLevel( ) is implemented? All I get is 0.0
> on SourceDataLines and -1.0 on TargetDataLines.
> Knute Johnson
In fact, a little further research shows that the fact that DataLine.getLevel( )
always returns UNKNOWN_LEVEL was filed as bug 4297101 in the Java Bug
Parade on December 6, 1999. Five years later, it’s still not fixed, though it
looks like there was at least an attempt to fix it for Tiger (J2SE 5.0)—a fix
that was abandoned in August 2003.
By the way, wouldn’t it have saved a lot of people a lot of
time if they disclosed in the Javadoc that this method is a no-
op? But I digress….
So, the level meter is not going to work—not because of the graphics, but
because there’s no way to get an accurate level. Or is there?