Class OALBuffer

java.lang.Object
com.blackrook.gloop.openal.OALObject
com.blackrook.gloop.openal.OALBuffer

public final class OALBuffer extends OALObject
Sound sample buffer class.
Author:
Matthew Tropiano
  • Field Details

    • SAMPLING_RATE_8KHZ

      public static final int SAMPLING_RATE_8KHZ
      See Also:
    • SAMPLING_RATE_11KHZ

      public static final int SAMPLING_RATE_11KHZ
      See Also:
    • SAMPLING_RATE_16KHZ

      public static final int SAMPLING_RATE_16KHZ
      See Also:
    • SAMPLING_RATE_22KHZ

      public static final int SAMPLING_RATE_22KHZ
      See Also:
    • SAMPLING_RATE_32KHZ

      public static final int SAMPLING_RATE_32KHZ
      See Also:
    • SAMPLING_RATE_44KHZ

      public static final int SAMPLING_RATE_44KHZ
      See Also:
    • SAMPLING_RATE_48KHZ

      public static final int SAMPLING_RATE_48KHZ
      See Also:
    • bufferSize

      protected int bufferSize
      The sizes of each of the buffers.
    • bufferFormat

      protected OALBuffer.Format bufferFormat
      Sound format.
    • bufferRate

      protected int bufferRate
      Sound sampling rate.
  • Method Details

    • setFrequencyAndFormat

      public void setFrequencyAndFormat(AudioFormat format)
      Sets the audio frequency and format of this buffer using an AudioFormat info object.
      Parameters:
      format - the JavaX sound format data to pull from.
    • allocate

      protected final int allocate()
      Description copied from class: OALObject
      Allocates a new type of this object in OpenAL. Called by OALObject constructor.
      Specified by:
      allocate in class OALObject
      Returns:
      the ALId of this new object.
    • free

      protected final void free()
      Description copied from class: OALObject
      Destroys this object (deallocates it on OpenAL). This is called by destroy().
      Specified by:
      free in class OALObject
    • setData

      public void setData(byte[] data)
      Loads this buffer with sample data from an array of bytes. This is intended for pure convenience, and its use is discouraged if performance is desired.
      Parameters:
      data - the data to load into it.
    • setData

      public void setData(byte[] data, int offset, int length)
      Loads this buffer with sample data from an array of bytes. This is intended for pure convenience, and its use is discouraged if performance is desired.
      Parameters:
      data - the data to load into it.
      offset - the offset into the array to use.
      length - the amount of bytes to load.
      Throws:
      ArrayIndexOutOfBoundsException - if offset + length exceeds data.length.
    • setData

      public void setData(ByteBuffer data)
      Loads this buffer with sample data. The data is loaded from the source byte buffer's current position to its current limit.
      Parameters:
      data - the data to load into it.
    • getSize

      public int getSize()
      Returns:
      the buffer size in bytes.
    • setFormat

      public void setFormat(OALBuffer.Format format)
      Sets this buffer's bitrate format.
      Parameters:
      format - This buffer's format.
      Throws:
      IllegalArgumentException - if this is not set using a valid constant.
    • getFormat

      public OALBuffer.Format getFormat()
      Returns:
      this buffer's format (AL constant).
    • setSamplingRate

      public void setSamplingRate(int rate)
      Sets this buffer's sampling rate.
      Parameters:
      rate - the rate in kHz.
    • getSamplingRate

      public int getSamplingRate()
      Returns:
      this buffer's sampling rate.
    • setFormatByChannelsAndBits

      public void setFormatByChannelsAndBits(int channels, int bits)
      Sets format by channels and bits.
      Parameters:
      channels - amount of channels.
      bits - bit per sample.
      Throws:
      IllegalArgumentException - if the combination of channels and bits create an unsupported format.
    • toString

      public String toString()
      Overrides:
      toString in class OALObject