< prev index next >

src/java.desktop/share/classes/javax/sound/sampled/FloatControl.java

Print this page




  37  * <p>
  38  * The {@code FloatControl} abstract class provides methods to set and get the
  39  * control's current floating-point value. Other methods obtain the possible
  40  * range of values and the control's resolution (the smallest increment between
  41  * returned values). Some float controls allow ramping to a new value over a
  42  * specified period of time. {@code FloatControl} also includes methods that
  43  * return string labels for the minimum, maximum, and midpoint positions of the
  44  * control.
  45  *
  46  * @author David Rivas
  47  * @author Kara Kytle
  48  * @see Line#getControls
  49  * @see Line#isControlSupported
  50  * @since 1.3
  51  */
  52 public abstract class FloatControl extends Control {
  53 
  54     /**
  55      * The minimum supported value.
  56      */
  57     private float minimum;
  58 
  59     /**
  60      * The maximum supported value.
  61      */
  62     private float maximum;
  63 
  64     /**
  65      * The control's precision.
  66      */
  67     private float precision;
  68 
  69     /**
  70      * The smallest time increment in which a value change can be effected
  71      * during a value shift, in microseconds.
  72      */
  73     private int updatePeriod;
  74 
  75     /**
  76      * A label for the units in which the control values are expressed, such as
  77      * "dB" for decibels.
  78      */
  79     private final String units;
  80 
  81     /**
  82      * A label for the minimum value, such as "Left".
  83      */
  84     private final String minLabel;
  85 
  86     /**
  87      * A label for the maximum value, such as "Right".
  88      */
  89     private final String maxLabel;
  90 
  91     /**
  92      * A label for the mid-point value, such as "Center".
  93      */


 317      * @see #getUpdatePeriod
 318      */
 319     public void shift(float from, float to, int microseconds) {
 320         // test "from" value, "to" value will be tested by setValue()
 321         if (from < minimum) {
 322             throw new IllegalArgumentException("Requested value " + from
 323                     + " smaller than allowable minimum value " + minimum + ".");
 324         }
 325         if (from > maximum) {
 326             throw new IllegalArgumentException("Requested value " + from
 327                     + " exceeds allowable maximum value " + maximum + ".");
 328         }
 329         setValue(to);
 330     }
 331 
 332     /**
 333      * Provides a string representation of the control.
 334      *
 335      * @return a string description
 336      */

 337     public String toString() {
 338         return new String(getType() + " with current value: " + getValue() + " " + units +
 339                           " (range: " + minimum + " - " + maximum + ")");
 340     }
 341 
 342     /**
 343      * An instance of the {@code FloatControl.Type} inner class identifies one
 344      * kind of float control. Static instances are provided for the common
 345      * types.
 346      *
 347      * @author Kara Kytle
 348      * @since 1.3
 349      */
 350     public static class Type extends Control.Type {
 351 
 352         /**
 353          * Represents a control for the overall gain on a line.
 354          * <p>
 355          * Gain is a quantity in decibels (dB) that is added to the intrinsic
 356          * decibel level of the audio signal--that is, the level of the signal




  37  * <p>
  38  * The {@code FloatControl} abstract class provides methods to set and get the
  39  * control's current floating-point value. Other methods obtain the possible
  40  * range of values and the control's resolution (the smallest increment between
  41  * returned values). Some float controls allow ramping to a new value over a
  42  * specified period of time. {@code FloatControl} also includes methods that
  43  * return string labels for the minimum, maximum, and midpoint positions of the
  44  * control.
  45  *
  46  * @author David Rivas
  47  * @author Kara Kytle
  48  * @see Line#getControls
  49  * @see Line#isControlSupported
  50  * @since 1.3
  51  */
  52 public abstract class FloatControl extends Control {
  53 
  54     /**
  55      * The minimum supported value.
  56      */
  57     private final float minimum;
  58 
  59     /**
  60      * The maximum supported value.
  61      */
  62     private final float maximum;
  63 
  64     /**
  65      * The control's precision.
  66      */
  67     private final float precision;
  68 
  69     /**
  70      * The smallest time increment in which a value change can be effected
  71      * during a value shift, in microseconds.
  72      */
  73     private final int updatePeriod;
  74 
  75     /**
  76      * A label for the units in which the control values are expressed, such as
  77      * "dB" for decibels.
  78      */
  79     private final String units;
  80 
  81     /**
  82      * A label for the minimum value, such as "Left".
  83      */
  84     private final String minLabel;
  85 
  86     /**
  87      * A label for the maximum value, such as "Right".
  88      */
  89     private final String maxLabel;
  90 
  91     /**
  92      * A label for the mid-point value, such as "Center".
  93      */


 317      * @see #getUpdatePeriod
 318      */
 319     public void shift(float from, float to, int microseconds) {
 320         // test "from" value, "to" value will be tested by setValue()
 321         if (from < minimum) {
 322             throw new IllegalArgumentException("Requested value " + from
 323                     + " smaller than allowable minimum value " + minimum + ".");
 324         }
 325         if (from > maximum) {
 326             throw new IllegalArgumentException("Requested value " + from
 327                     + " exceeds allowable maximum value " + maximum + ".");
 328         }
 329         setValue(to);
 330     }
 331 
 332     /**
 333      * Provides a string representation of the control.
 334      *
 335      * @return a string description
 336      */
 337     @Override
 338     public String toString() {
 339         return new String(getType() + " with current value: " + getValue() + " " + units +
 340                           " (range: " + minimum + " - " + maximum + ")");
 341     }
 342 
 343     /**
 344      * An instance of the {@code FloatControl.Type} inner class identifies one
 345      * kind of float control. Static instances are provided for the common
 346      * types.
 347      *
 348      * @author Kara Kytle
 349      * @since 1.3
 350      */
 351     public static class Type extends Control.Type {
 352 
 353         /**
 354          * Represents a control for the overall gain on a line.
 355          * <p>
 356          * Gain is a quantity in decibels (dB) that is added to the intrinsic
 357          * decibel level of the audio signal--that is, the level of the signal


< prev index next >