public class BasicVolumeControl extends java.lang.Object implements VolumeControl, javax.media.GainControl
Modifier and Type | Field and Description |
---|---|
protected static float |
MAX_VOLUME_LEVEL
The maximum volume level accepted by AbstractVolumeControl.
|
static int |
MAX_VOLUME_PERCENT
The maximum volume level expressed in percent accepted by
AbstractVolumeControl.
|
protected static float |
MIN_VOLUME_LEVEL
The minimum volume level accepted by AbstractVolumeControl.
|
static int |
MIN_VOLUME_PERCENT
The minimum volume level expressed in percent accepted by
AbstractVolumeControl.
|
protected float |
volumeLevel
The current volume level.
|
CAPTURE_VOLUME_LEVEL_PROPERTY_NAME, PLAYBACK_VOLUME_LEVEL_PROPERTY_NAME
Constructor and Description |
---|
BasicVolumeControl(java.lang.String volumeLevelConfigurationPropertyName)
Creates volume control instance and initializes initial level value
if stored in the configuration service.
|
Modifier and Type | Method and Description |
---|---|
void |
addGainChangeListener(javax.media.GainChangeListener listener)
Register for gain change update events.
|
void |
addVolumeChangeListener(VolumeChangeListener listener)
Adds a VolumeChangeListener to be informed for any change
in the volume levels.
|
static void |
applyGain(javax.media.GainControl gainControl,
byte[] buffer,
int offset,
int length)
Applies the gain specified by gainControl to the signal defined
by the length number of samples given in buffer
starting at offset.
|
java.awt.Component |
getControlComponent()
Not used.
|
float |
getDB()
Get the current gain set for this object in dB.
|
protected static float |
getDefaultVolumeLevel()
Returns the default volume level.
|
protected static float |
getGainReferenceLevel()
Returns the reference volume level for computing the gain.
|
float |
getLevel()
Get the current gain set for this object as a value between 0.0 and 1.0
|
float |
getMaxValue()
Returns the maximum allowed volume value.
|
float |
getMinValue()
Returns the minimum allowed volume value.
|
boolean |
getMute()
Get mute state of sound.
|
float |
getVolume()
Current volume value.
|
protected void |
loadVolume()
Reads the initial volume level from the system.
|
void |
removeGainChangeListener(javax.media.GainChangeListener listener)
Remove interest in gain change update events.
|
void |
removeVolumeChangeListener(VolumeChangeListener listener)
Removes a VolumeChangeListener.
|
float |
setDB(float gain)
Set the gain in decibels.
|
float |
setLevel(float level)
Set the gain using a floating point scale
with values between 0.0 and 1.0.
|
void |
setMute(boolean mute)
Mutes current sound.
|
float |
setVolume(float value)
Changes volume level.
|
protected void |
updateHardwareVolume()
Modifies the hardware microphone sensibility (hardware amplification).
|
protected static final float MAX_VOLUME_LEVEL
public static final int MAX_VOLUME_PERCENT
protected static final float MIN_VOLUME_LEVEL
public static final int MIN_VOLUME_PERCENT
protected float volumeLevel
public BasicVolumeControl(java.lang.String volumeLevelConfigurationPropertyName)
volumeLevelConfigurationPropertyName
- the name of the configuration
property which specifies the value of the volume level of the new
instancepublic static void applyGain(javax.media.GainControl gainControl, byte[] buffer, int offset, int length)
gainControl
- the GainControl which specifies the gain to
applybuffer
- the samples of the signal to apply the gain tooffset
- the start of the samples of the signal in bufferlength
- the number of samples of the signal given in
bufferprotected static float getDefaultVolumeLevel()
protected static float getGainReferenceLevel()
public void addGainChangeListener(javax.media.GainChangeListener listener)
GainChangeEvent
is
posted when the state of the GainControl
changes.addGainChangeListener
in interface javax.media.GainControl
listener
- The object to deliver events to.public void addVolumeChangeListener(VolumeChangeListener listener)
addVolumeChangeListener
in interface VolumeControl
listener
- volume change listener.public java.awt.Component getControlComponent()
getControlComponent
in interface javax.media.Control
public float getDB()
getDB
in interface javax.media.GainControl
public float getLevel()
getLevel
in interface javax.media.GainControl
GainControl
public float getMaxValue()
getMaxValue
in interface VolumeControl
VolumeControl
public float getMinValue()
getMinValue
in interface VolumeControl
VolumeControl
public boolean getMute()
getMute
in interface javax.media.GainControl
getMute
in interface VolumeControl
public float getVolume()
getVolume
in interface VolumeControl
VolumeControl
protected void loadVolume()
public void removeGainChangeListener(javax.media.GainChangeListener listener)
removeGainChangeListener
in interface javax.media.GainControl
listener
- The object that has been receiving events.public void removeVolumeChangeListener(VolumeChangeListener listener)
removeVolumeChangeListener
in interface VolumeControl
listener
- the volume change listener to be removed.public float setDB(float gain)
setDB
in interface javax.media.GainControl
gain
- The new gain in dB.GainControl
public float setLevel(float level)
GainControl
supports.setLevel
in interface javax.media.GainControl
level
- The new gain value specified in the level scale.GainControl
public void setMute(boolean mute)
setMute
in interface javax.media.GainControl
setMute
in interface VolumeControl
mute
- mutes/unmutes.public float setVolume(float value)
setVolume
in interface VolumeControl
value
- the new level to set.VolumeControl
protected void updateHardwareVolume()
Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under Apache license.