public class AudioSource extends Controller implements Effectable, Recordable
AudioSource
is a kind of wrapper around an
AudioStream
. An AudioSource
will add its
AudioBuffer
s as listeners on the stream so that you can access
the stream's samples without having to implement AudioListener
yourself. It also provides the Effectable
and
Recordable
interface. Because an AudioStream
must
be closed when you are finished with it, you must remember to call
close()
on any AudioSource
s you obtain from Minim, such
as AudioInput
s, AudioOutput
s, and
AudioPlayer
s.Modifier and Type | Field and Description |
---|---|
AudioBuffer |
left
The AudioBuffer containing the left channel samples.
|
AudioBuffer |
mix
The AudioBuffer containing the mix of the left and right channels.
|
AudioBuffer |
right
The AudioBuffer containing the right channel samples.
|
BALANCE, GAIN, MUTE, PAN, SAMPLE_RATE, VOLUME
Constructor and Description |
---|
AudioSource(ddf.minim.spi.AudioOut istream)
Constructs an
AudioSource that will subscribe to the samples
in stream . |
Modifier and Type | Method and Description |
---|---|
void |
addEffect(AudioEffect effect)
Deprecated.
|
void |
addListener(AudioListener listener)
Add an AudioListener to this sound generating object,
which will have its samples method called every time
this object generates a new buffer of samples.
|
int |
bufferSize()
The internal buffer size of this sound object.
|
void |
clearEffects()
Deprecated.
|
void |
close()
Closes this source, making it unavailable.
|
void |
disableEffect(AudioEffect effect)
Deprecated.
|
void |
disableEffect(int i)
Deprecated.
|
int |
effectCount()
Deprecated.
|
void |
effects()
Deprecated.
|
void |
enableEffect(AudioEffect effect)
Deprecated.
|
void |
enableEffect(int i)
Deprecated.
|
AudioEffect |
getEffect(int i)
Deprecated.
|
javax.sound.sampled.AudioFormat |
getFormat()
Returns an AudioFormat object that describes the audio properties
of this sound generating object.
|
boolean |
hasEffect(AudioEffect e)
Deprecated.
|
boolean |
isEffected()
Deprecated.
|
boolean |
isEnabled(AudioEffect effect)
Deprecated.
|
void |
noEffects()
Deprecated.
|
void |
removeEffect(AudioEffect effect)
Deprecated.
|
AudioEffect |
removeEffect(int i)
Deprecated.
|
void |
removeListener(AudioListener listener)
Removes an AudioListener that was previously
added to this sound object.
|
float |
sampleRate()
Returns the sample rate of this sound object.
|
int |
type()
The type is an int describing the number of channels
this sound object has.
|
balance, gain, getBalance, getControl, getControls, getGain, getPan, getVolume, hasControl, isMuted, mute, pan, printControls, setBalance, setGain, setPan, setVolume, shiftBalance, shiftGain, shiftPan, shiftVolume, unmute, volume
public final AudioBuffer left
public final AudioBuffer right
right
contains the same samples as
left
.public final AudioBuffer mix
mix
contains the same
samples as left
.public AudioSource(ddf.minim.spi.AudioOut istream)
AudioSource
that will subscribe to the samples
in stream
. It is expected that the stream is using a
DataLine
for playback. If it is not, calls to
Controller
's methods will result in a
NullPointerException
.istream
- the AudioStream
to subscribe to and wrappublic void close()
public void addEffect(AudioEffect effect)
Effectable
addEffect
in interface Effectable
effect
- the AudioEffect to addpublic void clearEffects()
Effectable
clearEffects
in interface Effectable
public void disableEffect(int i)
Effectable
i
th effect in the effect chain.disableEffect
in interface Effectable
i
- the index of the effect to disablepublic void disableEffect(AudioEffect effect)
Effectable
effect
if it is in the chain.disableEffect
in interface Effectable
effect
- the AudioEffect
to disablepublic int effectCount()
Effectable
effectCount
in interface Effectable
public void effects()
Effectable
Effectable.enableEffect(int)
.effects
in interface Effectable
public boolean hasEffect(AudioEffect e)
Effectable
effect
is in the chain.hasEffect
in interface Effectable
e
- the effec to check foreffect
is attached to thispublic void enableEffect(int i)
Effectable
i
th effect in the effect chain.enableEffect
in interface Effectable
i
- the index of the effect to enablepublic void enableEffect(AudioEffect effect)
Effectable
effect
if it is in the chain.enableEffect
in interface Effectable
effect
- the AudioEffect
to enablepublic AudioEffect getEffect(int i)
Effectable
ith
effect in the effect chain.
This method is not required to do bounds checking and may throw an
ArrayOutOfBoundsException if i
is larger than
Effectable.effectCount()
.getEffect
in interface Effectable
i
- which effect to returnpublic boolean isEffected()
Effectable
isEffected
in interface Effectable
public boolean isEnabled(AudioEffect effect)
Effectable
effect
is in the chain and is also enabled.isEnabled
in interface Effectable
effect
- the AudioEffect
to check the status ofeffect
is in the chain and is enabledpublic void noEffects()
Effectable
Effectable.disableEffect(int)
.noEffects
in interface Effectable
public void removeEffect(AudioEffect effect)
Effectable
effect
from the effects chain.removeEffect
in interface Effectable
effect
- the AudioEffect to removepublic AudioEffect removeEffect(int i)
Effectable
ith
effect in the
effect chain.removeEffect
in interface Effectable
i
- which effect to removeAudioEffect
public void addListener(AudioListener listener)
addListener
in interface Recordable
listener
- the AudioListener that will listen to thispublic int bufferSize()
bufferSize
in interface Recordable
public javax.sound.sampled.AudioFormat getFormat()
getFormat
in interface Recordable
public void removeListener(AudioListener listener)
removeListener
in interface Recordable
listener
- the AudioListener that should stop listening to thispublic int type()
type
in interface Recordable
public float sampleRate()
sampleRate
in interface Recordable