Package com.portaudio
Class BlockingStream
- java.lang.Object
-
- com.portaudio.BlockingStream
-
public class BlockingStream extends java.lang.Object
Represents a stream for blocking read/write I/O. This Java object contains the pointer to a PortAudio stream stored as a long. It is passed to PortAudio when calling stream related functions. To create one of these, call PortAudio.openStream().- Author:
- Phil Burk
- See Also:
PortAudio
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
abort()
Stop immediately and lose any data that was written but not played.void
close()
Close the stream and zero out the pointer.StreamInfo
getInfo()
int
getReadAvailable()
double
getTime()
Get audio time related to this stream.int
getWriteAvailable()
boolean
isActive()
boolean
isStopped()
boolean
read(float[] buffer, int numFrames)
Read 32-bit floating point data from the stream into the array.boolean
read(short[] buffer, int numFrames)
Read 16-bit integer data to the stream from the array.void
start()
Atart audio I/O.void
stop()
Wait for the stream to play all of the data that has been written then stop.java.lang.String
toString()
boolean
write(float[] buffer, int numFrames)
Write 32-bit floating point data to the stream from the array.boolean
write(short[] buffer, int numFrames)
Write 16-bit integer data to the stream from the array.
-
-
-
Method Detail
-
getReadAvailable
public int getReadAvailable()
- Returns:
- number of frames that can be read without blocking.
-
getWriteAvailable
public int getWriteAvailable()
- Returns:
- number of frames that can be written without blocking.
-
read
public boolean read(float[] buffer, int numFrames)
Read 32-bit floating point data from the stream into the array.- Parameters:
buffer
-numFrames
- number of frames to read- Returns:
- true if an input overflow occurred
-
write
public boolean write(float[] buffer, int numFrames)
Write 32-bit floating point data to the stream from the array. The data should be in the range -1.0 to +1.0.- Parameters:
buffer
-numFrames
- number of frames to write- Returns:
- true if an output underflow occurred
-
read
public boolean read(short[] buffer, int numFrames)
Read 16-bit integer data to the stream from the array.- Parameters:
buffer
-numFrames
- number of frames to write- Returns:
- true if an input overflow occurred
-
write
public boolean write(short[] buffer, int numFrames)
Write 16-bit integer data to the stream from the array.- Parameters:
buffer
-numFrames
- number of frames to write- Returns:
- true if an output underflow occurred
-
start
public void start()
Atart audio I/O.
-
stop
public void stop()
Wait for the stream to play all of the data that has been written then stop.
-
abort
public void abort()
Stop immediately and lose any data that was written but not played.
-
close
public void close()
Close the stream and zero out the pointer. Do not reference the stream after this.
-
isStopped
public boolean isStopped()
-
isActive
public boolean isActive()
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getTime
public double getTime()
Get audio time related to this stream. Note that it may not start at 0.0.
-
getInfo
public StreamInfo getInfo()
-
-