Jitsi: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.impl.neomedia.audiolevel
Class AudioLevelCalculator

java.lang.Object
  extended by net.java.sip.communicator.impl.neomedia.audiolevel.AudioLevelCalculator

public class AudioLevelCalculator
extends Object

Author:
Damian Minkov, Lyubomir Marinov

Constructor Summary
AudioLevelCalculator()
           
 
Method Summary
static int calculateSignalPowerLevel(byte[] samples, int offset, int length, int minLevel, int maxLevel, int lastLevel)
          Estimates the signal power and use the levelRatio to scale it to the needed levels.
static int calculateSoundPressureLevel(byte[] samples, int offset, int length, int minLevel, int maxLevel, int lastLevel)
          Calculates the sound pressure level of a signal with specific samples and makes sure that it is expressed as a value in the range between minLevel and maxLevel.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AudioLevelCalculator

public AudioLevelCalculator()
Method Detail

calculateSignalPowerLevel

public static int calculateSignalPowerLevel(byte[] samples,
                                            int offset,
                                            int length,
                                            int minLevel,
                                            int maxLevel,
                                            int lastLevel)
Estimates the signal power and use the levelRatio to scale it to the needed levels.

Parameters:
samples - the samples of the signal to calculate the signal power level of
offset - the offset that data starts.
length - the length of the data
minLevel - the minimum value of the result
maxLevel - the maximum value of the result
lastLevel - the last level we calculated.
Returns:
the power of the signal in dB SWL.

calculateSoundPressureLevel

public static int calculateSoundPressureLevel(byte[] samples,
                                              int offset,
                                              int length,
                                              int minLevel,
                                              int maxLevel,
                                              int lastLevel)
Calculates the sound pressure level of a signal with specific samples and makes sure that it is expressed as a value in the range between minLevel and maxLevel.

Parameters:
samples - the samples of the signal to calculate the sound pressure level of
offset - the offset in samples in which the samples start
length - the length in bytes of the samples in samples starting at offset
minLevel - the minimum value of the level to be returned
maxLevel - the maximum value of the level to be returned
lastLevel - the last level which has been previously calculated
Returns:
the sound pressure level of the specified signal as a value in the range between minLevel and maxLevel

Jitsi: the OpenSource Java VoIP and Instant Messaging client.

Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under LGPL license.