APIdia Launch Partner
Top Description Inners Fields Constructors Methods
javax.sound.sampled

public abstract Class FloatControl

extends Control
Class Inheritance
Known Direct Subclasses
com.sun.media.sound.DirectAudioDevice.DirectDL.Gain, com.sun.media.sound.DirectAudioDevice.DirectDL.Balance, com.sun.media.sound.DirectAudioDevice.DirectDL.Pan, com.sun.media.sound.PortMixer.FloatCtrl, com.sun.media.sound.SoftMixingDataLine.Gain, com.sun.media.sound.SoftMixingDataLine.Balance, com.sun.media.sound.SoftMixingDataLine.Pan, com.sun.media.sound.SoftMixingDataLine.ReverbSend, com.sun.media.sound.SoftMixingDataLine.ChorusSend

A FloatControl object provides control over a range of floating-point values. Float controls are often represented in graphical user interfaces by continuously adjustable objects such as sliders or rotary knobs. Concrete subclasses of FloatControl implement controls, such as gain and pan, that affect a line's audio signal in some way that an application can manipulate. The FloatControl.Type inner class provides static instances of types that are used to identify some common kinds of float control.

The FloatControl abstract class provides methods to set and get the control's current floating-point value. Other methods obtain the possible range of values and the control's resolution (the smallest increment between returned values). Some float controls allow ramping to a new value over a specified period of time. FloatControl also includes methods that return string labels for the minimum, maximum, and midpoint positions of the control.

Authors
David Rivas, Kara Kytle
Since
1.3
See Also
Line#getControls, Line#isControlSupported

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
FloatControl.Type

An instance of the FloatControl.Type inner class identifies one kind of float control.

Field Summary

Modifier and TypeField and Description
private final float
maximum

The maximum supported value.

private final String
maxLabel

A label for the maximum value, such as "Right".

private final String
midLabel

A label for the mid-point value, such as "Center".

private final float
minimum

The minimum supported value.

private final String
minLabel

A label for the minimum value, such as "Left".

private final float
precision

The control's precision.

private final String
units

A label for the units in which the control values are expressed, such as "dB" for decibels.

private final int
updatePeriod

The smallest time increment in which a value change can be effected during a value shift, in microseconds.

private float
value

The current value.

Constructor Summary

AccessConstructor and Description
protected
FloatControl(FloatControl.Type
the kind of control represented by this float control object
type
,
float
the smallest value permitted for the control
minimum
,
float
the largest value permitted for the control
maximum
,
float
the resolution or granularity of the control. This is the size of the increment between discrete valid values.
precision
,
int
the smallest time interval, in microseconds, over which the control can change from one discrete value to the next during a shift
updatePeriod
,
float
the value that the control starts with when constructed
initialValue
,
String
the label for the units in which the control's values are expressed, such as "dB" or "frames per second"
units
,
String
the label for the minimum value, such as "Left" or "Off"
minLabel
,
String
the label for the midpoint value, such as "Center" or "Default"
midLabel
,
String
the label for the maximum value, such as "Right" or "Full"
maxLabel
)

Constructs a new float control object with the given parameters.

protected
FloatControl(FloatControl.Type
the kind of control represented by this float control object
type
,
float
the smallest value permitted for the control
minimum
,
float
the largest value permitted for the control
maximum
,
float
the resolution or granularity of the control. This is the size of the increment between discrete valid values.
precision
,
int
the smallest time interval, in microseconds, over which the control can change from one discrete value to the next during a shift
updatePeriod
,
float
the value that the control starts with when constructed
initialValue
,
String
the label for the units in which the control's values are expressed, such as "dB" or "frames per second"
units
)

Constructs a new float control object with the given parameters.

Method Summary

Modifier and TypeMethod and Description
public float

Returns:

the maximum allowable value
getMaximum
()

Obtains the maximum value permitted.

public String

Returns:

the maximum value label, or a zero-length string if no label has been set
getMaxLabel
()

Obtains the label for the maximum value, such as "Right" or "Full".

public String

Returns:

the mid-point value label, or a zero-length string if no label has been set
getMidLabel
()

Obtains the label for the mid-point value, such as "Center" or "Default".

public float

Returns:

the minimum allowable value
getMinimum
()

Obtains the minimum value permitted.

public String

Returns:

the minimum value label, or a zero-length string if no label has been set
getMinLabel
()

Obtains the label for the minimum value, such as "Left" or "Off".

public float

Returns:

the control's precision
getPrecision
()

Obtains the resolution or granularity of the control, in the units that the control measures.

public String

Returns:

the units label, or a zero-length string if no label
getUnits
()

Obtains the label for the units in which the control's values are expressed, such as "dB" or "frames per second."

public int

Returns:

update period in microseconds, or -1 if shifting over time is unsupported
getUpdatePeriod
()

Obtains the smallest time interval, in microseconds, over which the control's value can change during a shift.

public float

Returns:

the current value
getValue
()

Obtains this control's current value.

public void
setValue(float
desired new value
newValue
)

Sets the current value for the control.

public void
shift(float
initial value at the beginning of the shift
from
,
float
final value after the shift
to
,
int
maximum duration of the shift in microseconds
microseconds
)

Changes the control value from the initial value to the final value linearly over the specified time period, specified in microseconds.

public String

Returns:

a string representation of the float control
toString
()

Overrides javax.sound.sampled.Control.toString.

Returns a string representation of the float control.

Inherited from javax.sound.sampled.Control:
getType

Field Detail

maximumback to summary
private final float maximum

The maximum supported value.

maxLabelback to summary
private final String maxLabel

A label for the maximum value, such as "Right".

midLabelback to summary
private final String midLabel

A label for the mid-point value, such as "Center".

minimumback to summary
private final float minimum

The minimum supported value.

minLabelback to summary
private final String minLabel

A label for the minimum value, such as "Left".

precisionback to summary
private final float precision

The control's precision.

unitsback to summary
private final String units

A label for the units in which the control values are expressed, such as "dB" for decibels.

updatePeriodback to summary
private final int updatePeriod

The smallest time increment in which a value change can be effected during a value shift, in microseconds.

valueback to summary
private float value

The current value.

Constructor Detail

FloatControlback to summary
protected FloatControl(FloatControl.Type type, float minimum, float maximum, float precision, int updatePeriod, float initialValue, String units, String minLabel, String midLabel, String maxLabel)

Constructs a new float control object with the given parameters.

Parameters
type:FloatControl.Type

the kind of control represented by this float control object

minimum:float

the smallest value permitted for the control

maximum:float

the largest value permitted for the control

precision:float

the resolution or granularity of the control. This is the size of the increment between discrete valid values.

updatePeriod:int

the smallest time interval, in microseconds, over which the control can change from one discrete value to the next during a shift

initialValue:float

the value that the control starts with when constructed

units:String

the label for the units in which the control's values are expressed, such as "dB" or "frames per second"

minLabel:String

the label for the minimum value, such as "Left" or "Off"

midLabel:String

the label for the midpoint value, such as "Center" or "Default"

maxLabel:String

the label for the maximum value, such as "Right" or "Full"

Exceptions
IllegalArgumentException:
if minimum is greater than maximum or initialValue does not fall within the allowable range
FloatControlback to summary
protected FloatControl(FloatControl.Type type, float minimum, float maximum, float precision, int updatePeriod, float initialValue, String units)

Constructs a new float control object with the given parameters. The labels for the minimum, maximum, and mid-point values are set to zero-length strings.

Parameters
type:FloatControl.Type

the kind of control represented by this float control object

minimum:float

the smallest value permitted for the control

maximum:float

the largest value permitted for the control

precision:float

the resolution or granularity of the control. This is the size of the increment between discrete valid values.

updatePeriod:int

the smallest time interval, in microseconds, over which the control can change from one discrete value to the next during a shift

initialValue:float

the value that the control starts with when constructed

units:String

the label for the units in which the control's values are expressed, such as "dB" or "frames per second"

Exceptions
IllegalArgumentException:
if minimum is greater than maximum or initialValue does not fall within the allowable range

Method Detail

getMaximumback to summary
public float getMaximum()

Obtains the maximum value permitted.

Returns:float

the maximum allowable value

getMaxLabelback to summary
public String getMaxLabel()

Obtains the label for the maximum value, such as "Right" or "Full".

Returns:String

the maximum value label, or a zero-length string if no label has been set

getMidLabelback to summary
public String getMidLabel()

Obtains the label for the mid-point value, such as "Center" or "Default".

Returns:String

the mid-point value label, or a zero-length string if no label has been set

getMinimumback to summary
public float getMinimum()

Obtains the minimum value permitted.

Returns:float

the minimum allowable value

getMinLabelback to summary
public String getMinLabel()

Obtains the label for the minimum value, such as "Left" or "Off".

Returns:String

the minimum value label, or a zero-length string if no label has been set

getPrecisionback to summary
public float getPrecision()

Obtains the resolution or granularity of the control, in the units that the control measures. The precision is the size of the increment between discrete valid values for this control, over the set of supported floating-point values.

Returns:float

the control's precision

getUnitsback to summary
public String getUnits()

Obtains the label for the units in which the control's values are expressed, such as "dB" or "frames per second."

Returns:String

the units label, or a zero-length string if no label

getUpdatePeriodback to summary
public int getUpdatePeriod()

Obtains the smallest time interval, in microseconds, over which the control's value can change during a shift. The update period is the inverse of the frequency with which the control updates its value during a shift. If the implementation does not support value shifting over time, it should set the control's value to the final value immediately and return -1 from this method.

Returns:int

update period in microseconds, or -1 if shifting over time is unsupported

See Also
shift
getValueback to summary
public float getValue()

Obtains this control's current value.

Returns:float

the current value

setValueback to summary
public void setValue(float newValue)

Sets the current value for the control. The default implementation simply sets the value as indicated. If the value indicated is greater than the maximum value, or smaller than the minimum value, an IllegalArgumentException is thrown. Some controls require that their line be open before they can be affected by setting a value.

Parameters
newValue:float

desired new value

Exceptions
IllegalArgumentException:
if the value indicated does not fall within the allowable range
shiftback to summary
public void shift(float from, float to, int microseconds)

Changes the control value from the initial value to the final value linearly over the specified time period, specified in microseconds. This method returns without blocking; it does not wait for the shift to complete. An implementation should complete the operation within the time specified. The default implementation simply changes the value to the final value immediately.

Parameters
from:float

initial value at the beginning of the shift

to:float

final value after the shift

microseconds:int

maximum duration of the shift in microseconds

Exceptions
IllegalArgumentException:
if either from or to value does not fall within the allowable range
See Also
getUpdatePeriod
toStringback to summary
public String toString()

Overrides javax.sound.sampled.Control.toString.

Returns a string representation of the float control.

Returns:String

a string representation of the float control

Annotations
@Override
javax.sound.sampled back to summary

public Class FloatControl.Type

extends Type
Class Inheritance
Known Direct Subclasses
com.sun.media.sound.PortMixer.FloatCtrl.FCT

An instance of the FloatControl.Type inner class identifies one kind of float control. Static instances are provided for the common types.
Author
Kara Kytle
Since
1.3

Field Summary

Modifier and TypeField and Description
public static final FloatControl.Type
AUX_RETURN

Represents a control for the auxiliary return gain on a line.

public static final FloatControl.Type
AUX_SEND

Represents a control for the auxiliary send gain on a line.

public static final FloatControl.Type
BALANCE

Represents a control for the relative balance of a stereo signal between two stereo speakers.

public static final FloatControl.Type
MASTER_GAIN

Represents a control for the overall gain on a line.

public static final FloatControl.Type
PAN

Represents a control for the relative pan (left-right positioning) of the signal.

public static final FloatControl.Type
REVERB_RETURN

Represents a control for the post-reverb gain on a line.

public static final FloatControl.Type
REVERB_SEND

Represents a control for the pre-reverb gain on a line.

public static final FloatControl.Type
SAMPLE_RATE

Represents a control that changes the sample rate of audio playback.

public static final FloatControl.Type
VOLUME

Represents a control for the volume on a line.

Constructor Summary

AccessConstructor and Description
protected
Type(final String
the name of the new float control type
name
)

Constructs a new float control type.

Method Summary

Inherited from javax.sound.sampled.Control.Type:
equalshashCodetoString

Field Detail

AUX_RETURNback to summary
public static final FloatControl.Type AUX_RETURN

Represents a control for the auxiliary return gain on a line.

See Also
MASTER_GAIN, AUX_SEND
AUX_SENDback to summary
public static final FloatControl.Type AUX_SEND

Represents a control for the auxiliary send gain on a line.

See Also
MASTER_GAIN, AUX_RETURN
BALANCEback to summary
public static final FloatControl.Type BALANCE

Represents a control for the relative balance of a stereo signal between two stereo speakers. The valid range of values is -1.0 (left channel only) to 1.0 (right channel only). The default is 0.0 (centered).

See Also
PAN
MASTER_GAINback to summary
public static final FloatControl.Type MASTER_GAIN

Represents a control for the overall gain on a line.

Gain is a quantity in decibels (dB) that is added to the intrinsic decibel level of the audio signal--that is, the level of the signal before it is altered by the gain control. A positive gain amplifies (boosts) the signal's volume, and a negative gain attenuates(cuts)it. The gain setting defaults to a value of 0.0 dB, meaning the signal's loudness is unaffected. Note that gain measures dB, not amplitude. The relationship between a gain in decibels and the corresponding linear amplitude multiplier is:

linearScalar = pow(10.0, gainDB/20.0)

The FloatControl class has methods to impose a maximum and minimum allowable value for gain. However, because an audio signal might already be at a high amplitude, the maximum setting does not guarantee that the signal will be undistorted when the gain is applied to it (unless the maximum is zero or negative). To avoid numeric overflow from excessively large gain settings, a gain control can implement clipping, meaning that the signal's amplitude will be limited to the maximum value representable by its audio format, instead of wrapping around.

These comments apply to gain controls in general, not just master gain controls. A line can have more than one gain control. For example, a mixer (which is itself a line) might have a master gain control, an auxiliary return control, a reverb return control, and, on each of its source lines, an individual aux send and reverb send.

See Also
AUX_SEND, AUX_RETURN, REVERB_SEND, REVERB_RETURN, VOLUME
PANback to summary
public static final FloatControl.Type PAN

Represents a control for the relative pan (left-right positioning) of the signal. The signal may be mono; the pan setting affects how it is distributed by the mixer in a stereo mix. The valid range of values is -1.0 (left channel only) to 1.0 (right channel only). The default is 0.0 (centered).

See Also
BALANCE
REVERB_RETURNback to summary
public static final FloatControl.Type REVERB_RETURN

Represents a control for the post-reverb gain on a line. This control may be used to control the relative amplitude of the signal returned from an internal reverberation unit.

See Also
MASTER_GAIN, REVERB_SEND
REVERB_SENDback to summary
public static final FloatControl.Type REVERB_SEND

Represents a control for the pre-reverb gain on a line. This control may be used to affect how much of a line's signal is directed to a mixer's internal reverberation unit.

See Also
MASTER_GAIN, REVERB_RETURN, EnumControl.Type#REVERB
SAMPLE_RATEback to summary
public static final FloatControl.Type SAMPLE_RATE

Represents a control that changes the sample rate of audio playback. The net effect of changing the sample rate depends on the relationship between the media's natural rate and the rate that is set via this control. The natural rate is the sample rate that is specified in the data line's AudioFormat object. For example, if the natural rate of the media is 11025 samples per second and the sample rate is set to 22050 samples per second, the media will play back at twice the normal speed.

Changing the sample rate with this control does not affect the data line's audio format. Also note that whenever you change a sound's sample rate, a change in the sound's pitch results. For example, doubling the sample rate has the effect of doubling the frequencies in the sound's spectrum, which raises the pitch by an octave.

VOLUMEback to summary
public static final FloatControl.Type VOLUME

Represents a control for the volume on a line.

Constructor Detail

Typeback to summary
protected Type(final String name)

Constructs a new float control type.

Parameters
name:String

the name of the new float control type