zombie.core.sound
Class Buffer

java.lang.Object
  extended by zombie.core.sound.Buffer
All Implemented Interfaces:
Sound

public class Buffer
extends java.lang.Object

A sound buffer, used for playing short sound effects from RAM.


Constructor Summary
Buffer()
          C'tor
Buffer(java.lang.String url, float gain, float pitch, int priority, boolean looped)
          C'tor.
Buffer(java.lang.String url, float gain, float pitch, int priority, boolean looped, Attenuator attenuator)
          C'tor
Buffer(java.lang.String url, int priority)
          C'tor.
Buffer(java.lang.String url, int priority, boolean looped)
          C'tor.
 
Method Summary
 void create()
          Create native resources, load and decode the Ogg data from the URL, and upload to AL.
 void destroy()
          Destroy native resources.
 Attenuator getAttenuator()
          Returns the Attenuator to use for this Sound.
 int getBufferID()
           
 int getFormat()
           
 float getGain()
          Returns the gain.
 float getPitch()
          Returns the pitch.
 int getPriority()
          Returns the priority.
 java.lang.String getURL()
           
 boolean isCreated()
           
 boolean isLooped()
          Returns looped status
 boolean isStereo()
           
 void setAttenuator(Attenuator attenuator)
          Sets the Attenuator to use for this Sound.
 void setGain(float gain)
          Sets the default gain for this buffer
 void setLooped(boolean looped)
          Sets whether this buffer should be looped by default
 void setPitch(float pitch)
          Sets the default pitch for this buffer
 void setPriority(int priority)
          Sets the default priority for this buffer relative to all other buffers.
 void setURL(java.lang.String url)
          Sets the URL from where this AbstractSound will read Ogg Vorbis data
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Buffer

public Buffer()
C'tor


Buffer

public Buffer(java.lang.String url,
              int priority)
C'tor. Pitch and gain are at 1.0f and the sound is not looped and uses the sound engine default attenuator.

Parameters:
url -
priority -

Buffer

public Buffer(java.lang.String url,
              int priority,
              boolean looped)
C'tor. Pitch and gain are at 1.0f and uses the sound engine default attenuator.

Parameters:
url -
priority -
looped -

Buffer

public Buffer(java.lang.String url,
              float gain,
              float pitch,
              int priority,
              boolean looped)
C'tor. Uses the sound engine default attenuator

Parameters:
url -
gain -
pitch -
priority -
looped -

Buffer

public Buffer(java.lang.String url,
              float gain,
              float pitch,
              int priority,
              boolean looped,
              Attenuator attenuator)
C'tor

Parameters:
url -
gain -
pitch -
priority -
looped -
attenuator -
Method Detail

create

public void create()
Create native resources, load and decode the Ogg data from the URL, and upload to AL. Does nothing if AL has not been created.

See Also:
destroy()

destroy

public void destroy()
Destroy native resources. Does nothing if create() has not yet been called.

See Also:
create()

isCreated

public boolean isCreated()
Returns:
true if create() has been called

getBufferID

public final int getBufferID()
Returns:
the buffer ID

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getFormat

public int getFormat()
Returns:
the AL format (AL_FORMAT_STEREO16,etc)

isStereo

public boolean isStereo()
Returns:
true if the sound is stereo

setGain

public final void setGain(float gain)
Description copied from interface: Sound
Sets the default gain for this buffer

Specified by:
setGain in interface Sound
Parameters:
gain - (must be ≥ 0.0f and ≤ 1.0f)

setPitch

public final void setPitch(float pitch)
Description copied from interface: Sound
Sets the default pitch for this buffer

Specified by:
setPitch in interface Sound
Parameters:
pitch - (must be > 0.0f)

setPriority

public final void setPriority(int priority)
Description copied from interface: Sound
Sets the default priority for this buffer relative to all other buffers.

Specified by:
setPriority in interface Sound
Parameters:
priority - (must be >= 0)

setLooped

public final void setLooped(boolean looped)
Description copied from interface: Sound
Sets whether this buffer should be looped by default

Specified by:
setLooped in interface Sound

setURL

public final void setURL(java.lang.String url)
Description copied from interface: Sound
Sets the URL from where this AbstractSound will read Ogg Vorbis data

Specified by:
setURL in interface Sound
Parameters:
url - May ne null

getGain

public final float getGain()
Description copied from interface: Sound
Returns the gain. Gain defaults to 1.0f

Specified by:
getGain in interface Sound
Returns:
float (≥0.0f and ≤1.0f)

getPitch

public final float getPitch()
Description copied from interface: Sound
Returns the pitch. Pitch defaults to 1.0f

Specified by:
getPitch in interface Sound
Returns:
float (>0.0f)

getPriority

public final int getPriority()
Description copied from interface: Sound
Returns the priority. Priority defaults to 0.

Specified by:
getPriority in interface Sound
Returns:
int

isLooped

public final boolean isLooped()
Description copied from interface: Sound
Returns looped status

Specified by:
isLooped in interface Sound
Returns:
boolean

getURL

public final java.lang.String getURL()
Specified by:
getURL in interface Sound
Returns:
Returns the url.

getAttenuator

public Attenuator getAttenuator()
Description copied from interface: Sound
Returns the Attenuator to use for this Sound. The default Attenuator is specified by the SoundEngine itself, so if no attenuator has been set with Sound.setAttenuator(Attenuator) then the default returned by SoundEngine.getDefaultAttenuator() will be used instead when playing the sound.

Specified by:
getAttenuator in interface Sound
Returns:
an Attenuator (never null)
See Also:
Sound.setAttenuator(Attenuator), SoundEngine.getDefaultAttenuator()

setAttenuator

public void setAttenuator(Attenuator attenuator)
Description copied from interface: Sound
Sets the Attenuator to use for this Sound. If set to null, then the default attenuator as returned by SoundEngine.getDefaultAttenuator() will be used when playing this sound.

Specified by:
setAttenuator in interface Sound
Parameters:
attenuator - May be null
See Also:
Sound.getAttenuator(), SoundEngine.getDefaultAttenuator()