|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Provides an interface to the audio system for use by freetts.
Audio is presented to the AudioPlayer as byte arrays.
Implementations of this AudioPlayer interface will format the data
based upon the current audio format (as set by
setAudioFormat
) and output the data.
The AudioPlayer interface provides a set of potential synchronization points to allow a specific AudioPlayer to batch output in various ways.
These synchronization points are in pairs: reset,
drain
are used to bracket output of large amounts of audio
data. Typically, an implementation will not return from
drain
until all queued audio has been played (or
cancelled).
The methods: begin, end
are used to bracket smaller amounts of
audio data (typically associated with a single utterance).
pause,
resume, cancel, showMetrics, close, getTime, resetTime
which can be called from other threads.
Method Summary | |
void |
begin(int size)
Starts the output of a set of data. |
void |
cancel()
Cancels all queued output. |
void |
close()
Waits for all audio playback to stop, and closes this AudioPlayer. |
boolean |
drain()
Waits for all queued audio to be played |
boolean |
end()
Signals the end of a set of data. |
javax.sound.sampled.AudioFormat |
getAudioFormat()
Retrieves the audio format for this player |
long |
getTime()
Gets the amount of audio played since the last resetTime |
float |
getVolume()
Returns the current volume. |
void |
pause()
Pauses all audio output on this player. |
void |
reset()
Prepares for another batch of output. |
void |
resetTime()
Resets the audio clock |
void |
resume()
Resumes audio output on this player |
void |
setAudioFormat(javax.sound.sampled.AudioFormat format)
Sets the audio format to use for the next set of outputs. |
void |
setVolume(float volume)
Sets the current volume. |
void |
showMetrics()
Shows metrics for this audio player |
void |
startFirstSampleTimer()
Starts the first sample timer |
boolean |
write(byte[] audioData)
Writes the given bytes to the audio stream |
boolean |
write(byte[] audioData,
int offset,
int size)
Writes the given bytes to the audio stream |
Method Detail |
public void setAudioFormat(javax.sound.sampled.AudioFormat format)
format
- the audio formatpublic javax.sound.sampled.AudioFormat getAudioFormat()
public void pause()
public void resume()
public void reset()
public boolean drain()
true
if the audio played to completion;
otherwise false
if the audio was stoppedpublic void begin(int size)
size
- the size of data in bytes to be output before
end
is called.public boolean end()
begin/end
pairs.
true
if the audio was output properly,
false
if the output was cancelled
or interrupted.public void cancel()
public void close()
public float getVolume()
public void setVolume(float volume)
volume
- the new volume (between 0 and 1)public long getTime()
public void resetTime()
public void startFirstSampleTimer()
public boolean write(byte[] audioData)
audioData
- audio data to write to the device
true
of the write completed successfully,
false
if the write was cancelled.public boolean write(byte[] audioData, int offset, int size)
audioData
- audio data to write to the deviceoffset
- the offset into the buffersize
- the number of bytes to write.
true
of the write completed successfully,
false
if the write was cancelled.public void showMetrics()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |