Class AudioBuffer

All Implemented Interfaces:

public class AudioBuffer extends AudioData
An AudioBuffer is an implementation of AudioData where the audio is buffered (stored in memory). All parts of it are accessible at any time.
AudioBuffers are useful for short sounds, like effects, etc.
  • Field Details

    • audioData

      protected ByteBuffer audioData
      The audio data buffer. Should be direct and native ordered.
  • Constructor Details

    • AudioBuffer

      public AudioBuffer()
    • AudioBuffer

      protected AudioBuffer(int id)
  • Method Details

    • getDataType

      public AudioData.DataType getDataType()
      Specified by:
      getDataType in class AudioData
      The data type, either Buffer or Stream.
    • getDuration

      public float getDuration()
      Specified by:
      getDuration in class AudioData
      The duration of the audio in seconds. It is expected that audio is uncompressed.
    • toString

      public String toString()
      toString in class NativeObject
    • updateData

      public void updateData(ByteBuffer data)
      Update the data in the buffer with new data.
      data - the audio data provided (not null, direct, alias created)
      IllegalArgumentException - if the provided buffer is not a direct buffer
    • getData

      public ByteBuffer getData()
      The buffered audio data.
    • resetObject

      public void resetObject()
      Description copied from class: NativeObject
      Called when the GL context is restarted to reset all IDs. Prevents "white textures" on display restart.
      Specified by:
      resetObject in class NativeObject
    • deleteNativeBuffers

      protected void deleteNativeBuffers()
      Description copied from class: NativeObject
      Deletes any associated native buffers. This is necessary because it is unlikely that native buffers will be garbage collected naturally (due to how GC works), therefore the collection must be handled manually. Only implementations that manage native buffers need to override this method. Note that the behavior that occurs when a deleted native buffer is used is not defined, therefore this method is protected
      deleteNativeBuffers in class NativeObject
    • deleteObject

      public void deleteObject(Object rendererObject)
      Description copied from class: NativeObject
      Deletes the GL object from the GPU when it is no longer used. Called automatically by the GL object manager.
      Specified by:
      deleteObject in class NativeObject
      rendererObject - The renderer to be used to delete the object
    • createDestructableClone

      public NativeObject createDestructableClone()
      Description copied from class: NativeObject
      Creates a shallow clone of this GL Object. The deleteObject method should be functional for this object.
      Specified by:
      createDestructableClone in class NativeObject
      a new instance
    • getUniqueId

      public long getUniqueId()
      Description copied from class: NativeObject
      Returns a unique ID for this NativeObject. No other NativeObject shall have the same ID.
      Specified by:
      getUniqueId in class NativeObject
      unique ID for this NativeObject.