javax.sound and calculating SNR

Discussion in 'Java' started by michas, Jun 3, 2007.

  1. michas

    michas Guest

    I have a problem, I need to calculate SNR (Signal-to-Noise Ratio) in
    my program. I made 2 programs already, that is: client app, which
    records voice and sends it through internet, and server app, which
    receives voice from client and plays it. now, I need to calculate SNR
    (Signal-to-Noise Ratio), and i can't find any examples of it... I use
    javax.sound.sampled in it. any advices?
    michas, Jun 3, 2007
    1. Advertisements

  2. michas

    Karl Uppiano Guest

    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
    ( 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.
    Karl Uppiano, Jun 3, 2007
    1. Advertisements

  3. It has been a really long time but isn't RMS = PEAK / sqrt(2)?
    Knute Johnson, Jun 4, 2007
  4. michas

    Lew Guest

    Correct, also calculable as

    Vrms = Vpeak * sqrt(2.0) / 2.0
    Lew, Jun 4, 2007
  5. michas

    Karl Uppiano Guest

    Yup. Sorry about that.
    Karl Uppiano, Jun 4, 2007
  6. michas

    Karl Uppiano Guest

    Yeah sorry, I left off the / 2.0.
    Karl Uppiano, Jun 4, 2007
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.