Interface AudioStream
- All Superinterfaces:
AutoCloseable, Closeable
- All Known Implementing Classes:
AiffInputStream, FlacInputStream, Mp3InputStream, OggInputStream, QoaInputStream, WavInputStream
An audio stream interface that can be implemented to feed a
StreamedSoundSource.-
Method Summary
Modifier and TypeMethodDescriptionintReturns the number of bits per sample, also known as the sample depth.default intReturns the block alignment in sample frames.default intReturns the block size in bytes.intReturns the number of audio channels.floatReturns the duration in seconds or -1 if this information is not available.Returns the output data format of this AudioStream.intReturns the sample rate.booleanisClosed()Returns true if the AudioStream is closed.intread(byte[] bytes) Reads bytes from the stream until the given array is full or the stream ends.reset()Resets the audio stream as if it was re-opened.
-
Method Details
-
getDuration
float getDuration()Returns the duration in seconds or -1 if this information is not available.- Returns:
- duration in seconds or -1 if the information is not available
-
reset
AudioStream reset()Resets the audio stream as if it was re-opened. Implementations are free to close themselves and provide a new AudioStream. The AudioStream returned by this function will be used, regardless of whether it is a new instance or the old one.- Returns:
- an AudioStream
-
getChannels
int getChannels()Returns the number of audio channels.- Returns:
- number of channels
-
getSampleRate
int getSampleRate()Returns the sample rate.- Returns:
- the sample rate
-
getBitsPerSample
int getBitsPerSample()Returns the number of bits per sample, also known as the sample depth.- Returns:
- the number of bits per sample
-
read
int read(byte[] bytes) Reads bytes from the stream until the given array is full or the stream ends. Returns the number of bytes that were actually read.- Parameters:
bytes- the byte array to store the bytes in- Returns:
- number of bytes read or -1 if there are no bytes left
-
getPcmDataType
PcmFormat.PcmDataType getPcmDataType()Returns the output data format of this AudioStream.- Returns:
- the pcm data type
-
getBlockSize
default int getBlockSize()Returns the block size in bytes. This only applies for data that is organized in blocks like ADPCM, all other implementations should return -1.- Returns:
- block size in bytes
-
getBlockAlign
default int getBlockAlign()Returns the block alignment in sample frames. This only applies for data that is organized in blocks like ADPCM, all other implementations should return -1.- Returns:
- the block size in sample frames
-
isClosed
boolean isClosed()Returns true if the AudioStream is closed.- Returns:
- true if closed, false if open
-