com.softsynth.jsyn.util
Class SampleQueueOutputStream
java.lang.Object
com.softsynth.jsyn.util.SampleQueueStream
com.softsynth.jsyn.util.SampleQueueOutputStream
public class SampleQueueOutputStream
- extends SampleQueueStream
Adds streaming write capabilities to a SynthSampleQueue.
The queue must be on a unit that will read data from the queue
such as a SampleReader_16F1. Data is written to the sample that
will then later be read by the SampleReader.
- Author:
- (C) 1997 Phil Burk, SoftSynth.com, All Rights Reserved
Method Summary |
int |
flush()
Wait until any data that has been written to the queue has been played. |
boolean |
getUnderflowed()
Return true if the buffer has underflowed and data was not supplied in time. |
int |
write(short[] data,
int offset,
int numFrames)
Write an array of short data to the sample. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
SampleQueueOutputStream
public SampleQueueOutputStream(SynthSampleQueue queue,
int bufferSizeInFrames,
int channelsPerFrame)
getUnderflowed
public boolean getUnderflowed()
- Return true if the buffer has underflowed and data was not supplied in time.
To prevent this, use a larger buffer, or write the data more often.
write
public int write(short[] data,
int offset,
int numFrames)
- Write an array of short data to the sample.
If there is not enough room available, block until all of the data can be written.
To avoid blocking, call available() first to see how much can be written without blocking.
- Parameters:
data
- Array of shorts containing PCM sample dataoffset
- index of array to start writing data fromnumFrames
- number of frames to write to sample
- Returns:
- number of frames read
flush
public int flush()
- Wait until any data that has been written to the queue has been played.
Call this when you want to make sure you hear the last little bit of a sound.
- Returns:
- frames not played if the stream is stopped.