net.jinx.audio
Class Buffer

java.lang.Object
  extended by net.jinx.audio.AbstractAudible
      extended by net.jinx.audio.Buffer
All Implemented Interfaces:
Audible

public class Buffer
extends AbstractAudible

Buffer objects hold audio data that can be used by a Source object to play sounds.

It is designed to loosely mimic the Buffer class of the Sound3D toolkit, while still allowing low-level access to the OpenAL APIs.

API Stability: Alpha; this is subject to change at any time.


Constructor Summary
Buffer(java.nio.ByteBuffer data, int format, int freq)
          Constructs a new Buffer using the given data.
 
Method Summary
 void deinit()
          Frees the OpenAL resources that this Buffer is consuming.
 int getBitDepth()
          Provides the bit depth of this Buffer.
 int getBufferID()
          Provides the OpenAL name of this Buffer.
 java.nio.ByteBuffer getData()
          Provides the ByteBuffer that contains the audio data for this Buffer.
 int getFormat()
          Provides the format constant for this Buffer.
 int getFrequency()
          Provides the frequency in Hertz of this Buffer.
 int getSize()
          Utility method to get the number of bytes of audio data this Buffer holds.
 void init(net.java.games.joal.AL al, net.java.games.joal.ALC alc)
          Prepares this Buffer for audio rendering by generating an OpenAL buffer for it and then configuring it with this Buffer's data.
 boolean isStereo()
          Provides a way to determine if this Buffer is mono or stereo.
 void update()
          Does nothing.
 
Methods inherited from class net.jinx.audio.AbstractAudible
getAL, getALC, isInitialized
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Buffer

public Buffer(java.nio.ByteBuffer data,
              int format,
              int freq)
Constructs a new Buffer using the given data.

Parameters:
data - the ByteBuffer of audio data to use.
format - the OpenAL audio format constant that describes what kind of data is in the ByteBuffer.
freq - the frequency in Hertz of the audio data (sampling rate).
Throws:
java.lang.NullPointerException - if data is null.
java.lang.IllegalArgumentException - if fromat is invalid or freq is less than or equal to zero.
Method Detail

getBufferID

public int getBufferID()
Provides the OpenAL name of this Buffer. This can be used to configure the buffer using regular OpenAL commands.

Returns:
the buffer ID.

isStereo

public boolean isStereo()
Provides a way to determine if this Buffer is mono or stereo.

Returns:
true if this Buffer is stereo.

getBitDepth

public int getBitDepth()
Provides the bit depth of this Buffer. This will be either 8 or 16.

Returns:
the bit depth.

getFrequency

public int getFrequency()
Provides the frequency in Hertz of this Buffer.

Returns:
the frequency.

getFormat

public int getFormat()
Provides the format constant for this Buffer.

Returns:
the format constant.

getData

public java.nio.ByteBuffer getData()
Provides the ByteBuffer that contains the audio data for this Buffer.

Returns:
the ByteBuffer.

getSize

public int getSize()
Utility method to get the number of bytes of audio data this Buffer holds.


init

public void init(net.java.games.joal.AL al,
                 net.java.games.joal.ALC alc)
Prepares this Buffer for audio rendering by generating an OpenAL buffer for it and then configuring it with this Buffer's data.

Specified by:
init in interface Audible
Overrides:
init in class AbstractAudible
Parameters:
al - the AL object to use for audio rendering. If this is null, a NullPointerException will be thrown.
alc - the ALC object to use for audio rendering. If this is null, a NullPointerException will be thrown.

update

public void update()
Does nothing.


deinit

public void deinit()
Frees the OpenAL resources that this Buffer is consuming.

Specified by:
deinit in interface Audible
Overrides:
deinit in class AbstractAudible