2007-03-15 19:52:28 +00:00
|
|
|
package ei.engine.sound;
|
|
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
|
|
|
|
|
import ei.engine.scene.Entity;
|
|
|
|
|
import ei.engine.util.MultiPrintStream;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* A sound that can be played through OpenAL
|
|
|
|
|
*
|
|
|
|
|
* @author Kevin Glass
|
|
|
|
|
*/
|
|
|
|
|
public class Sound extends Entity{
|
|
|
|
|
/** The buffer containing the sound */
|
|
|
|
|
private int buffer;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Create a new sound
|
|
|
|
|
*
|
|
|
|
|
* @param name The name of the sound
|
|
|
|
|
* @param ref the path to the sound file
|
|
|
|
|
*/
|
|
|
|
|
public Sound(String name, String ref) {
|
|
|
|
|
super(name);
|
|
|
|
|
try {
|
|
|
|
|
this.buffer = SoundLoader.getInstnace().loadSound(ref);
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
MultiPrintStream.out.println("Unable to load sound: "+ref+" - "+e.getMessage());
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Play this sound as a sound effect
|
|
|
|
|
*/
|
2007-03-15 23:29:55 +00:00
|
|
|
public void play() {
|
|
|
|
|
SoundLoader.getInstnace().playSound(buffer, getLocation(),false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Loop this sound
|
|
|
|
|
*/
|
|
|
|
|
public void loop() {
|
|
|
|
|
SoundLoader.getInstnace().playSound(buffer, getLocation(),true);
|
2007-03-15 19:52:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void update() {
|
|
|
|
|
//AL10.alSource(source.get(0), AL10.AL_POSITION, sourcePos);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* unimplamented method
|
|
|
|
|
*/
|
|
|
|
|
public void render() {}
|
|
|
|
|
}
|