com.cloudgarden.audio
Class AudioLineSink
java.lang.Object
|
+--com.cloudgarden.audio.DefaultAudioObject
|
+--com.cloudgarden.audio.DefaultAudioSink
|
+--com.cloudgarden.audio.AudioLineSink
- All Implemented Interfaces:
- AudioObject, AudioSink
- public class AudioLineSink
- extends DefaultAudioSink
AudioSink wrapper for a SourceDataLine.
Constructor Summary |
AudioLineSink(javax.sound.sampled.AudioFormat format)
|
AudioLineSink(AudioSource src)
Creates an AudioLineSink to receive data from the given AudioSource, with the same AudioFormat as
the AudioSource. |
AudioLineSink(int rate,
int bits,
int chans,
boolean signed,
boolean bigEndian)
|
AudioLineSink(javax.sound.sampled.SourceDataLine line)
Creates new AudioLineSink |
Method Summary |
boolean |
canSetAudioFormat()
The AudioFormat is set when the AudioLineSink is created and cannot be changed |
void |
close()
Closes the line |
void |
drain()
Calls super.drain() then drains the line and stops it. |
javax.sound.sampled.AudioFormat |
getAudioFormat()
Returns the AudioFormat for this AudioObject. |
javax.sound.sampled.SourceDataLine |
getLine()
|
void |
open()
Opens the line |
void |
setAudioFormat(javax.sound.sampled.AudioFormat format)
Sets the AudioFormat for this AudioObject. |
int |
write(byte[] data,
int offset,
int len)
Writes audio data to the SourceDataLine. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
AudioLineSink
public AudioLineSink(javax.sound.sampled.SourceDataLine line)
- Creates new AudioLineSink
AudioLineSink
public AudioLineSink(int rate,
int bits,
int chans,
boolean signed,
boolean bigEndian)
throws javax.sound.sampled.LineUnavailableException,
java.io.IOException
AudioLineSink
public AudioLineSink(javax.sound.sampled.AudioFormat format)
throws javax.sound.sampled.LineUnavailableException,
java.io.IOException
AudioLineSink
public AudioLineSink(AudioSource src)
throws javax.sound.sampled.LineUnavailableException,
java.io.IOException
- Creates an AudioLineSink to receive data from the given AudioSource, with the same AudioFormat as
the AudioSource.
canSetAudioFormat
public boolean canSetAudioFormat()
- The AudioFormat is set when the AudioLineSink is created and cannot be changed
- Overrides:
canSetAudioFormat
in class DefaultAudioObject
getAudioFormat
public javax.sound.sampled.AudioFormat getAudioFormat()
- Description copied from interface:
AudioObject
- Returns the AudioFormat for this AudioObject.
- Overrides:
getAudioFormat
in class DefaultAudioObject
- Following copied from interface:
com.cloudgarden.audio.AudioObject
- See Also:
AudioObject.setAudioFormat(javax.sound.sampled.AudioFormat)
setAudioFormat
public void setAudioFormat(javax.sound.sampled.AudioFormat format)
throws java.io.IOException
- Description copied from interface:
AudioObject
- Sets the AudioFormat for this AudioObject.
If this object is connected to an AudioSource or an AudioSink, then the
source/sink's AudioFormat is set equal to that of this AudioObject.
Note: if the sink is an AudioConverter then the
setIncomingAudioFormat method is called instead of setAudioFormat.
This ensures that the AudioFormat is uniform along a set of connected
AudioObjects until the format is changed by an AudioConverter.
- Overrides:
setAudioFormat
in class DefaultAudioSink
- Following copied from interface:
com.cloudgarden.audio.AudioObject
- Throws:
java.io.IOException
- if unable to set the AudioFormat for any reason
(eg. if canSetAudioFormat returns false and setAudioFormat is used
to try to change the AudioFormat).- See Also:
AudioObject.getAudioFormat()
getLine
public javax.sound.sampled.SourceDataLine getLine()
write
public int write(byte[] data,
int offset,
int len)
throws java.io.IOException
- Writes audio data to the SourceDataLine. If the line is not open, this
method opens it. Also, if the line is not running, this method starts it.
- Following copied from interface:
com.cloudgarden.audio.AudioSink
- See Also:
AudioSink.setSource(com.cloudgarden.audio.AudioSource)
,
AudioSource.startSending()
,
AudioObject.setPaused(boolean)
drain
public void drain()
throws java.io.IOException
- Calls super.drain() then drains the line and stops it.
- Overrides:
drain
in class DefaultAudioObject
open
public void open()
throws javax.sound.sampled.LineUnavailableException
- Opens the line
close
public void close()
- Closes the line