Interface AudioStream

All Superinterfaces:
AutoCloseable, Closeable
All Known Implementing Classes:
AiffInputStream, FlacInputStream, Mp3InputStream, OggInputStream, QoaInputStream, WavInputStream

public interface AudioStream extends Closeable
An audio stream interface that can be implemented to feed a StreamedSoundSource.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Returns the number of bits per sample, also known as the sample depth.
    default int
    Returns the block alignment in sample frames.
    default int
    Returns the block size in bytes.
    int
    Returns the number of audio channels.
    float
    Returns the duration in seconds or -1 if this information is not available.
    Returns the output data format of this AudioStream.
    int
    Returns the sample rate.
    boolean
    Returns true if the AudioStream is closed.
    int
    read(byte[] bytes)
    Reads bytes from the stream until the given array is full or the stream ends.
    Resets the audio stream as if it was re-opened.

    Methods inherited from interface Closeable

    close
  • 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