wyvern.lib.properties
Class SimpleSound

java.lang.Object
  extended bywyvern.lib.properties.SimpleSound
All Implemented Interfaces:
Alert
Direct Known Subclasses:
MovableSoundSource

public class SimpleSound
extends java.lang.Object
implements Alert

Implementation of wyvern.lib.Alert, the most basic sound type in Wyvern's audio framework.

It's best not to use new Alert() unless you need to control the volume level. Instead, use Alert.get(path) to get a shared, cached version. Should only be used for very short sounds, since it provides no way to stop the sound or modify its volume. That means that if the sound starts, and a player who hears it moves out of the map, it will continue to play until it's finished.

Version:
1.0, Jul 22, 2003
Author:
Steve Yegge

Field Summary
protected  double gain_
          Relative volume at which to play the Alert on the client.
protected  java.lang.String path_
          Relative path to the sound file.
 
Constructor Summary
SimpleSound()
          No-arg constructor.
SimpleSound(java.lang.String path)
          Constructs a new SimpleSound for the specified sound file.
SimpleSound(java.lang.String path, double gain)
          Constructs a new SimpleSound
 
Method Summary
static Alert get(java.lang.String path)
          Returns an Alert for the specified file.
 double getGain()
          Returns the gain for this sound.
 java.lang.String getPath()
          Returns the relative path to the sound file to play.
 void setGain(double gain)
          Sets the volume for the alert.
 void setPath(java.lang.String path)
          Sets the relative path to the sound file to play.
 java.lang.String toString()
          Returns debugging string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

path_

protected java.lang.String path_
Relative path to the sound file.


gain_

protected double gain_
Relative volume at which to play the Alert on the client.

Constructor Detail

SimpleSound

public SimpleSound()
No-arg constructor.


SimpleSound

public SimpleSound(java.lang.String path)
Constructs a new SimpleSound for the specified sound file.

Parameters:
path - the path to the sound file to play

SimpleSound

public SimpleSound(java.lang.String path,
                   double gain)
Constructs a new SimpleSound

Parameters:
path - the relative path to the file
gain - the volume to play it at (0.0-1.0)
Method Detail

get

public static Alert get(java.lang.String path)
Returns an Alert for the specified file.

Parameters:
path - the relative path to a sound file
Returns:
an Alert object

toString

public java.lang.String toString()
Returns debugging string.


getPath

public java.lang.String getPath()
Returns the relative path to the sound file to play.

Specified by:
getPath in interface Alert
Returns:
the relative path to the sound file to play.

setPath

public void setPath(java.lang.String path)
Sets the relative path to the sound file to play.

Specified by:
setPath in interface Alert
Parameters:
path - the relative path to the sound file to play.

getGain

public double getGain()
Returns the gain for this sound.

Specified by:
getGain in interface Alert
Returns:
gain (sound volume) from 0.0 to 1.0

setGain

public void setGain(double gain)
Sets the volume for the alert.

Specified by:
setGain in interface Alert
Parameters:
gain - the gain (sound volume), from 0.0 to 1.0