public class Controller
extends java.lang.Object
Controller
is the base class of all Minim classes that deal
with audio I/O. It provides control over the underlying DataLine
,
which is a low-level JavaSound class that talks directly to the audio
hardware of the computer. This means that you can make changes to the audio
without having to manipulate the samples directly. The downside to this is
that when outputting sound to the system (such as with an
AudioOutput
), these changes will not be present in the
samples made available to your program.
The volume()
, gain()
, pan()
, and
balance()
methods return objects of type FloatControl
,
which is a class defined by the JavaSound API. A FloatControl
represents a control of a line that holds a float
value. This
value has an associated maximum and minimum value (such as between -1 and 1
for pan), and also a unit type (such as dB for gain). You should refer to the
FloatControl
Javadoc for the full description of the methods available.
Not all controls are available on all objects. Before calling the methods
mentioned above, you should call
hasControl(javax.sound.sampled.Control.Type)
with the control type
you want to use. Alternatively, you can use the get
and
set
methods, which will simply do nothing if the control you
are trying to manipulate is not available.
Modifier and Type | Field and Description |
---|---|
static javax.sound.sampled.FloatControl.Type |
BALANCE
Deprecated.
|
static javax.sound.sampled.FloatControl.Type |
GAIN
Deprecated.
|
static javax.sound.sampled.BooleanControl.Type |
MUTE
Deprecated.
|
static javax.sound.sampled.FloatControl.Type |
PAN
Deprecated.
|
static javax.sound.sampled.FloatControl.Type |
SAMPLE_RATE
Deprecated.
|
static javax.sound.sampled.FloatControl.Type |
VOLUME
Deprecated.
|
Constructor and Description |
---|
Controller(javax.sound.sampled.Control[] cntrls)
Constructs a
Controller for the given Line . |
Modifier and Type | Method and Description |
---|---|
javax.sound.sampled.FloatControl |
balance()
Deprecated.
|
javax.sound.sampled.FloatControl |
gain()
Deprecated.
|
float |
getBalance()
Returns the current balance.
|
javax.sound.sampled.Control |
getControl(javax.sound.sampled.Control.Type type)
Deprecated.
|
javax.sound.sampled.Control[] |
getControls()
Deprecated.
|
float |
getGain()
Returns the current gain.
|
float |
getPan()
Returns the current pan.
|
float |
getVolume()
Returns the current volume.
|
boolean |
hasControl(javax.sound.sampled.Control.Type type)
Deprecated.
|
boolean |
isMuted()
Returns true if the sound is muted.
|
void |
mute()
Mutes the sound.
|
javax.sound.sampled.FloatControl |
pan()
Deprecated.
|
void |
printControls() |
void |
setBalance(float value)
Sets the balance.
|
void |
setGain(float value)
Sets the gain.
|
void |
setPan(float value)
Sets the pan.
|
void |
setVolume(float value)
Sets the volume.
|
void |
shiftBalance(float from,
float to,
int millis)
Transitions the balance from one value to another.
|
void |
shiftGain(float from,
float to,
int millis)
Transitions the gain from one value to another.
|
void |
shiftPan(float from,
float to,
int millis)
Transitions the pan from one value to another.
|
void |
shiftVolume(float from,
float to,
int millis)
Transitions the volume from one value to another.
|
void |
unmute()
Unmutes the sound.
|
javax.sound.sampled.FloatControl |
volume()
Deprecated.
|
@Deprecated public static javax.sound.sampled.FloatControl.Type VOLUME
@Deprecated public static javax.sound.sampled.FloatControl.Type GAIN
@Deprecated public static javax.sound.sampled.FloatControl.Type BALANCE
@Deprecated public static javax.sound.sampled.FloatControl.Type PAN
@Deprecated public static javax.sound.sampled.FloatControl.Type SAMPLE_RATE
@Deprecated public static javax.sound.sampled.BooleanControl.Type MUTE
public Controller(javax.sound.sampled.Control[] cntrls)
Controller
for the given Line
.cntrls
- an array of Controls that this Controller will manipulatepublic void printControls()
@Deprecated public boolean hasControl(javax.sound.sampled.Control.Type type)
@Deprecated public javax.sound.sampled.Control[] getControls()
@Deprecated public javax.sound.sampled.Control getControl(javax.sound.sampled.Control.Type type)
@Deprecated public javax.sound.sampled.FloatControl volume()
@Deprecated public javax.sound.sampled.FloatControl gain()
@Deprecated public javax.sound.sampled.FloatControl balance()
@Deprecated public javax.sound.sampled.FloatControl pan()
public void mute()
public void unmute()
public boolean isMuted()
public float getVolume()
level()
of an AudioBuffer!public void setVolume(float value)
value
- float: the new value for the volume, usually in the range [0,1].public void shiftVolume(float from, float to, int millis)
from
- float: the starting volumeto
- float: the ending volumemillis
- int: the length of the transition in millisecondspublic float getGain()
level()
of an AudioBuffer! Gain describes the current volume of the sound in
decibels, which is a logarithmic, rather than linear, scale. A gain
of 0dB means the sound is not being amplified or attenuated. Negative
gain values will reduce the volume of the sound, and positive values
will increase it.
public void setGain(float value)
value
- float: the new value for the gain, expressed in decibels.public void shiftGain(float from, float to, int millis)
from
- float: the starting gainto
- float: the ending gainmillis
- int: the length of the transition in millisecondspublic float getBalance()
public void setBalance(float value)
value
- float: the new value for the balancepublic void shiftBalance(float from, float to, int millis)
from
- float: the starting balanceto
- float: the ending balancemillis
- int: the length of the transition in millisecondspublic float getPan()
public void setPan(float value)
value
- float: the new value for the panpublic void shiftPan(float from, float to, int millis)
from
- float: the starting panto
- float: the ending panmillis
- int: the length of the transition in milliseconds