Hello everybody,
the other day I had to realise that DataLine.getLevel() will always return -1 regardless from the object being a TargetDataLine or a SourceDataLine. I found
this FAQ saying that getLevel() was not implemented in JDK 1.4.1. I really have to wonder why this has not been achieved yet since I'm using JDK 6 for developing and of course JRE 6 for running. The documentation does not give any further information about the method being implemented but this:
Returns: the current amplitude of the signal in this line, or AudioSystem.NOT_SPECIFIED sample code for javax.sound.sampled.AudioSystem.NOT_SPECIFIED
So I searched on to figure out how to implement this method on my own and found this [right here|http://forums.sun.com/thread.jspa?forumID=541&threadID=5395673]. Sorry but I still don't get it. All I can get from a line (that might have to do with the explanation) is the AudioFormat and from that the SampleRate and the SampleSizeInBits. How can this help me to calculate the current level?
I also stumbled upon other approaches telling me to calculate the root mean square of some buffered bytes I Just read from the line. I can understand what an RMS is in means of mathematics but I still don't comprehend how to apply this calculation on a byte array.
Please, can someone explain how to do it the right way?