I am not aware of any handy audio Java libraries that do this.
Signal-to-noise is the difference (usually expressed in decibels) between
the RMS voltage representing the "standard program level" and the RMS
voltage of the residual noise of the idle channel. This measurement is
fraught with pitfalls, however.
1. Determining the standard program level is not easy, although it is often
chosen to be 15 or 20 dB below full scale. Actual program audio, such as
voice, varies constantly, and peaks may reach full scale, while the average
level hovers around the standard program level. VU meters
(
http://en.wikipedia.org/wiki/VU_Meter) having very specific averaging
characteristics were designed to help determine this, but you will note that
they are always bouncing around with real program material.
2. Determining the residual noise on an idle channel is also challenging.
First of all, some digital systems mute idle channels, which result in
"infinite" SNR, which is misleading. If un-muted, you might discover that
you are picking up room noise from an open microphone. That isn't really the
SNR of the system either. For measuring the system SNR, you typically would
need to replace the microphone with a dummy load, and then compare the
remaining noise to the standard program level.
The formula for calculating dB is:
dB = 20*log(v2/v1)
Where log is the common log (base 10), v2 is the standard program level, and
v1 is the noise level.
For sinusoidal signals, RMS is calculated:
Vrms = Vpeak * sqrt(2)
This will be a constant for the standard program level. The noise level will
require RMS weighting, which is an averaging function over some period of
time. I do not have the specifics on hand at the moment, but simply
averaging the absolute value of noise samples over a few milliseconds would
be ok to a first approximation.
Hope this helps.