org.jrabbit.base.sound
Class SoundData

java.lang.Object
  extended by org.jrabbit.base.sound.SoundData
All Implemented Interfaces:
Destroyable, Referenced

public class SoundData
extends java.lang.Object
implements Referenced, Destroyable

SoundData represents audio data loaded into the game. Basically, it's a wrapper class that manages a Slick-Util Audio instance. A SoundData object can have multiple playbacks running simultaneously, so it can be used as a general resource. Thus, it's a logical object to place in a Cache. NOTE: SoundData is not streamed - it is loaded all at once. This can cause a noticeable pause if it occurs in-game.

Author:
Chris Molini

Field Summary
private  org.newdawn.slick.openal.Audio audio
          The Audio used to manage sound data.
private  java.lang.String reference
          The String that identifies this SoundData.
 
Constructor Summary
SoundData(Loader loader)
          Loads the sound file from the indicated resource into a SoundData.
SoundData(java.lang.String filepath)
          Loads the sound file at the indicated resource location into a SoundData.
SoundData(java.lang.String reference, Loader loader)
          Loads the sound file from the indicated resource into a SoundData and sets the identifier.
SoundData(java.lang.String reference, java.lang.String filepath)
          Loads the sound file at the indicated resource location into a SoundData and sets the identifier.
SoundData(java.lang.String reference, java.net.URL url)
          Loads the sound file at the indicated resource location into a SoundData and sets the identifier.
SoundData(java.net.URL url)
          Loads the sound file at the indicated resource location into a SoundData.
 
Method Summary
 org.newdawn.slick.openal.Audio audio()
          Accesses the Slick-Util Audio object contained in this SoundData.
 void destroy()
          Deletes the sound data associated with this object.
static org.newdawn.slick.openal.Audio loadData(Loader loader)
          Loads an Audio object (from Slick-Util) from the indicated Loader.
 java.lang.String reference()
          Gets the reference associated with this SoundData.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

audio

private org.newdawn.slick.openal.Audio audio
The Audio used to manage sound data.


reference

private java.lang.String reference
The String that identifies this SoundData.

Constructor Detail

SoundData

public SoundData(java.lang.String filepath)
Loads the sound file at the indicated resource location into a SoundData. The indicated filepath is used as the reference.

Parameters:
filepath - The location of the source audio.

SoundData

public SoundData(java.lang.String reference,
                 java.lang.String filepath)
Loads the sound file at the indicated resource location into a SoundData and sets the identifier.

Parameters:
reference - The String to identify the SoundData.
filepath - The location of the source audio.

SoundData

public SoundData(java.net.URL url)
Loads the sound file at the indicated resource location into a SoundData. NOTE: The created SoundData is streamed.

Parameters:
url - The URL that points to the desired source file.

SoundData

public SoundData(java.lang.String reference,
                 java.net.URL url)
Loads the sound file at the indicated resource location into a SoundData and sets the identifier. NOTE: The created SoundData is streamed.

Parameters:
reference - The String to identify the SoundData.
url - The URL that points to the desired source file.

SoundData

public SoundData(Loader loader)
Loads the sound file from the indicated resource into a SoundData.

Parameters:
loader - The Loader that accesses the desired source file.

SoundData

public SoundData(java.lang.String reference,
                 Loader loader)
Loads the sound file from the indicated resource into a SoundData and sets the identifier.

Parameters:
reference - The String to identify the SoundData.
loader - The Loader that accesses the desired source file.
Method Detail

loadData

public static org.newdawn.slick.openal.Audio loadData(Loader loader)
Loads an Audio object (from Slick-Util) from the indicated Loader.

Parameters:
loader - The Loader that accesses the desired source file.
Returns:
The Audio created from the indicated sound file.

reference

public java.lang.String reference()
Gets the reference associated with this SoundData.

Specified by:
reference in interface Referenced
Returns:
The string that identifies the SoundData.

audio

public org.newdawn.slick.openal.Audio audio()
Accesses the Slick-Util Audio object contained in this SoundData.

Returns:
The Audio that contains and controls the loaded sound.

destroy

public void destroy()
Deletes the sound data associated with this object.

Specified by:
destroy in interface Destroyable