com.cloudgarden.audio
Interface AudioObject

All Known Subinterfaces:
AudioConnector, AudioConverter, AudioSink, AudioSource
All Known Implementing Classes:
DefaultAudioObject

public interface AudioObject

Basic interface which is extended by AudioSource and AudioSink. Provides methods for setting/getting the AudioFormat and ContentType, and the state of this object


Field Summary
static int END_OF_DATA
          sent as a value for length of data when there is no more data available to be read or written.
 
Method Summary
 void addTransferListener(TransferListener listener)
          Adds a TransferListener to receive notification when data is passed to or from this AudioObject
 boolean canSetAudioFormat()
          Returns false if the AudioFormat cannot be set - eg some Recognizers may not be able to change their input format, so the CGAudioManager (which is an AudioSink) for that Recognizer will return false here.
 void drain()
          Blocks until END_OF_DATA is written to or read from this AudioObject.
 javax.sound.sampled.AudioFormat getAudioFormat()
          Returns the AudioFormat for this AudioObject.
 java.lang.String getContentType()
           
 boolean isPaused()
           
 boolean isWaiting()
          Returns true if no data has yet been written or read from this AudioObject
 void removeTransferListener(TransferListener listener)
           
 void setAudioFormat(javax.sound.sampled.AudioFormat format)
          Sets the AudioFormat for this AudioObject.
 void setContentType(java.lang.String contentType)
          Sets the content type for this AudioObject - contentType must be one of the FileTypeDescriptor String fields, eg MPEG_AUDIO.
 void setPaused(boolean paused)
          If paused is true, writing or reading data to or from this AudioObject will block until setPaused(false) is called.
 

Field Detail

END_OF_DATA

public static final int END_OF_DATA
sent as a value for length of data when there is no more data available to be read or written.
Method Detail

getAudioFormat

public javax.sound.sampled.AudioFormat getAudioFormat()
Returns the AudioFormat for this AudioObject.
See Also:
setAudioFormat(javax.sound.sampled.AudioFormat)

setAudioFormat

public void setAudioFormat(javax.sound.sampled.AudioFormat format)
                    throws java.io.IOException
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.

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:
getAudioFormat()

canSetAudioFormat

public boolean canSetAudioFormat()
Returns false if the AudioFormat cannot be set - eg some Recognizers may not be able to change their input format, so the CGAudioManager (which is an AudioSink) for that Recognizer will return false here.

isPaused

public boolean isPaused()

setPaused

public void setPaused(boolean paused)
If paused is true, writing or reading data to or from this AudioObject will block until setPaused(false) is called.

isWaiting

public boolean isWaiting()
Returns true if no data has yet been written or read from this AudioObject

drain

public void drain()
           throws java.io.IOException
Blocks until END_OF_DATA is written to or read from this AudioObject. For sinks such as an AudioLineSink, or sources such as AudioLineSource should also drain the line.

setContentType

public void setContentType(java.lang.String contentType)
                    throws java.io.IOException
Sets the content type for this AudioObject - contentType must be one of the FileTypeDescriptor String fields, eg MPEG_AUDIO.

getContentType

public java.lang.String getContentType()
See Also:
setContentType

addTransferListener

public void addTransferListener(TransferListener listener)
Adds a TransferListener to receive notification when data is passed to or from this AudioObject

removeTransferListener

public void removeTransferListener(TransferListener listener)
See Also:
addTransferListener