Imported GNU Classpath 0.90
[official-gcc.git] / libjava / classpath / javax / sound / sampled / FloatControl.java
blobbbdb24bab23067f1f1dbd6dacfe8cb2a4e8e20e0
1 /* Floating point control
2 Copyright (C) 2005 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 02110-1301 USA.
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
24 combination.
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
39 package javax.sound.sampled;
41 /** @since 1.3 */
42 public abstract class FloatControl extends Control
44 /**
45 * An instance of this class describes a particular floating point control.
46 * @since 1.3
48 public static class Type extends Control.Type
50 /** Auxiliary return gain. */
51 public static final Type AUX_RETURN = new Type("AUX return");
53 /** Auxiliary send gain. */
54 public static final Type AUX_SEND = new Type("AUX send");
56 /** Balance. */
57 public static final Type BALANCE = new Type("Balance");
59 /** Master gain control. */
60 public static final Type MASTER_GAIN = new Type("Master gain");
62 /** Control for panning. */
63 public static final Type PAN = new Type("Pan");
65 /** Post-reverb gain. */
66 public static final Type REVERB_RETURN = new Type("Reverb return");
68 /** Pre-reverb gain. */
69 public static final Type REVERB_SEND = new Type("Reverb send");
71 /** Control the sample rate. */
72 public static final Type SAMPLE_RATE = new Type("Sample rate");
74 /** Volume control. */
75 public static final Type VOLUME = new Type("Volume");
77 /**
78 * Create a new type given its name.
79 * @param name the name of the type
81 protected Type(String name)
83 super(name);
87 private float minimum;
88 private float maximum;
89 private float precision;
90 private int updatePeriod;
91 private float value;
92 private String units;
93 private String minLabel;
94 private String maxLabel;
95 private String midLabel;
97 /**
98 * Create a new FloatControl given its type and various parameters.
99 * The minimum, maximum, and midpoint labels will all be the empty string.
101 * @param type the type
102 * @param min the minimum valuee
103 * @param max the maximum value
104 * @param prec the precision
105 * @param update the update period
106 * @param init the initial value
107 * @param units the description of the units
109 protected FloatControl(Type type, float min, float max, float prec,
110 int update, float init, String units)
112 super(type);
113 this.minimum = min;
114 this.maximum = max;
115 this.precision = prec;
116 this.updatePeriod = update;
117 this.value = init;
118 this.units = units;
119 this.minLabel = "";
120 this.maxLabel = "";
121 this.midLabel = "";
125 * Create a new FloatControl given its type and various parameters.
127 * @param type the type
128 * @param min the minimum valuee
129 * @param max the maximum value
130 * @param prec the precision
131 * @param update the update period
132 * @param init the initial value
133 * @param units the description of the units
134 * @param minLabel the label for the minimum value
135 * @param midLabel the label for the midpoint
136 * @param maxLabel the label for the maximum value
138 protected FloatControl(Type type, float min, float max, float prec,
139 int update, float init, String units,
140 String minLabel, String midLabel, String maxLabel)
142 super(type);
143 this.minimum = min;
144 this.maximum = max;
145 this.precision = prec;
146 this.updatePeriod = update;
147 this.value = init;
148 this.units = units;
149 this.minLabel = minLabel;
150 this.maxLabel = maxLabel;
151 this.midLabel = midLabel;
155 * Return the maximum value of this control.
157 public float getMaximum()
159 return maximum;
163 * Return the label for the minimum value of this control.
165 public String getMaxLabel()
167 return maxLabel;
171 * Return the label for the midpoint of this control.
173 public String getMidLabel()
175 return midLabel;
179 * Return the minimum value of this control.
181 public float getMinimum()
183 return minimum;
187 * Return the label for the minimum value of this control.
189 public String getMinLabel()
191 return minLabel;
195 * Return the precision of this control.
197 public float getPrecision()
199 return precision;
203 * Return the name of the units for this control.
205 public String getUnits()
207 return units;
211 * Return the update period of this control.
213 public int getUpdatePeriod()
215 return updatePeriod;
219 * Return the current value of this control.
221 public float getValue()
223 return value;
227 * Set the new value of this control.
228 * @param value the new value
229 * @throws IllegalArgumentException if the new value is greater than the
230 * maximum or less than the minimum.
232 public void setValue(float value)
234 if (value < minimum || value > maximum)
235 throw new IllegalArgumentException("value out of range");
236 this.value = value;
240 * This tells the control to start at the starting value
241 * and to shift its value incrementally to the final value
242 * over the given time interval, specified in microseconds.
243 * The default implementation does not do this, but instead
244 * simply sets the value to the final value immediately.
246 * @param from the starting value
247 * @param to the final value
248 * @param ms the number of microseconds
250 public void shift(float from, float to, int ms)
252 if (from < minimum || from > maximum
253 || to < minimum || to > maximum
254 || ms < 0)
255 throw new IllegalArgumentException("argument out of range");
256 // The default just sets the value to TO.
257 this.value = to;
261 * Return a string describing this control.
263 public String toString()
265 return super.toString() + ": " + value;