evil-inside/src/ei/engine/sound/Sound.java

52 lines
1.1 KiB
Java
Raw Normal View History

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
*
* @param pitch The pitch of the play back
* @param gain The gain of the play back
*/
public void play(float pitch, float gain) {
SoundLoader.getInstnace().playSound(buffer, pitch, gain, getLocation());
}
public void update() {
//AL10.alSource(source.get(0), AL10.AL_POSITION, sourcePos);
}
/**
* unimplamented method
*/
public void render() {}
}