- java.lang.Object
-
- javax.sound.sampled.Control
-
- javax.sound.sampled.FloatControl
-
public abstract class FloatControl extends Control
AFloatControl
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 ofFloatControl
implement controls, such as gain and pan, that affect a line's audio signal in some way that an application can manipulate. The
inner class provides static instances of types that are used to identify some common kinds of float control.FloatControl.Type
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.- Since:
- 1.3
- See Also:
Line.getControls()
,Line.isControlSupported(javax.sound.sampled.Control.Type)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description static class
FloatControl.Type
An instance of theFloatControl.Type
inner class identifies one kind of float control.
-
Constructor Summary
Constructors Modifier Constructor and Description 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.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
-
Method Summary
Methods Modifier and Type Method and Description float
getMaximum()
Obtains the maximum value permitted.String
getMaxLabel()
Obtains the label for the maximum value, such as "Right" or "Full."String
getMidLabel()
Obtains the label for the mid-point value, such as "Center" or "Default."float
getMinimum()
Obtains the minimum value permitted.String
getMinLabel()
Obtains the label for the minimum value, such as "Left" or "Off."float
getPrecision()
Obtains the resolution or granularity of the control, in the units that the control measures.String
getUnits()
Obtains the label for the units in which the control's values are expressed, such as "dB" or "frames per second."int
getUpdatePeriod()
Obtains the smallest time interval, in microseconds, over which the control's value can change during a shift.float
getValue()
Obtains this control's current value.void
setValue(float newValue)
Sets the current value for the control.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.String
toString()
Provides a string representation of the control-
Methods inherited from class javax.sound.sampled.Control
getType
-
-
-
-
Constructor Detail
-
FloatControl
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
- the kind of control represented by this float control objectminimum
- the smallest value permitted for the controlmaximum
- the largest value permitted for the controlprecision
- the resolution or granularity of the control. This is the size of the increment between discrete valid values.updatePeriod
- the smallest time interval, in microseconds, over which the control can change from one discrete value to the next during ashift
initialValue
- the value that the control starts with when constructedunits
- the label for the units in which the control's values are expressed, such as "dB" or "frames per second"minLabel
- the label for the minimum value, such as "Left" or "Off"midLabel
- the label for the midpoint value, such as "Center" or "Default"maxLabel
- the label for the maximum value, such as "Right" or "Full"- Throws:
IllegalArgumentException
- ifminimum
is greater thanmaximum
orinitialValue
does not fall within the allowable range
-
FloatControl
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
- the kind of control represented by this float control objectminimum
- the smallest value permitted for the controlmaximum
- the largest value permitted for the controlprecision
- the resolution or granularity of the control. This is the size of the increment between discrete valid values.updatePeriod
- the smallest time interval, in microseconds, over which the control can change from one discrete value to the next during ashift
initialValue
- the value that the control starts with when constructedunits
- the label for the units in which the control's values are expressed, such as "dB" or "frames per second"- Throws:
IllegalArgumentException
- ifminimum
is greater thanmaximum
orinitialValue
does not fall within the allowable range
-
-
Method Detail
-
setValue
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
- desired new value- Throws:
IllegalArgumentException
- if the value indicated does not fall within the allowable range
-
getValue
public float getValue()
Obtains this control's current value.- Returns:
- the current value
-
getMaximum
public float getMaximum()
Obtains the maximum value permitted.- Returns:
- the maximum allowable value
-
getMinimum
public float getMinimum()
Obtains the minimum value permitted.- Returns:
- the minimum allowable value
-
getUnits
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:
- the units label, or a zero-length string if no label
-
getMinLabel
public String getMinLabel()
Obtains the label for the minimum value, such as "Left" or "Off."- Returns:
- the minimum value label, or a zero-length string if no label * has been set
-
getMidLabel
public String getMidLabel()
Obtains the label for the mid-point value, such as "Center" or "Default."- Returns:
- the mid-point value label, or a zero-length string if no label * has been set
-
getMaxLabel
public String getMaxLabel()
Obtains the label for the maximum value, such as "Right" or "Full."- Returns:
- the maximum value label, or a zero-length string if no label * has been set
-
getPrecision
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:
- the control's precision
-
getUpdatePeriod
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:
- update period in microseconds, or -1 if shifting over time is unsupported
- See Also:
shift(float, float, int)
-
shift
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
- initial value at the beginning of the shiftto
- final value after the shiftmicroseconds
- maximum duration of the shift in microseconds- Throws:
IllegalArgumentException
- if eitherfrom
orto
value does not fall within the allowable range- See Also:
getUpdatePeriod()
-
-
Nederlandse vertaling
U hebt gevraagd om deze site in het Nederlands te bezoeken. Voor nu wordt alleen de interface vertaald, maar nog niet alle inhoud.Als je me wilt helpen met vertalingen, is je bijdrage welkom. Het enige dat u hoeft te doen, is u op de site registreren en mij een bericht sturen waarin u wordt gevraagd om u toe te voegen aan de groep vertalers, zodat u de gewenste pagina's kunt vertalen. Een link onderaan elke vertaalde pagina geeft aan dat u de vertaler bent en heeft een link naar uw profiel.
Bij voorbaat dank.
Document heeft de 11/06/2005 gemaakt, de laatste keer de 04/03/2020 gewijzigd
Bron van het afgedrukte document:https://www.gaudry.be/nl/java-api-rf-javax/sound/sampled/FloatControl.html
De infobrol is een persoonlijke site waarvan de inhoud uitsluitend mijn verantwoordelijkheid is. De tekst is beschikbaar onder CreativeCommons-licentie (BY-NC-SA). Meer info op de gebruiksvoorwaarden en de auteur.
Referenties
Deze verwijzingen en links verwijzen naar documenten die geraadpleegd zijn tijdens het schrijven van deze pagina, of die aanvullende informatie kunnen geven, maar de auteurs van deze bronnen kunnen niet verantwoordelijk worden gehouden voor de inhoud van deze pagina.
De auteur Deze site is als enige verantwoordelijk voor de manier waarop de verschillende concepten, en de vrijheden die met de referentiewerken worden genomen, hier worden gepresenteerd. Vergeet niet dat u meerdere broninformatie moet doorgeven om het risico op fouten te verkleinen.