Allow streams and sounds to have their gain controlled individually as well as from the overall control

git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@649 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
Charlie Groves
2008-08-26 22:17:11 +00:00
parent e4cdad7741
commit 60d2febeda
@@ -174,14 +174,19 @@ public class OpenALSoundPlayer extends SoundPlayer
getSoundQueue().postRunnable(new Runnable(){ getSoundQueue().postRunnable(new Runnable(){
public void run () { public void run () {
Stream s = new Stream(_alSoundManager) { Stream s = new Stream(_alSoundManager) {
@Override @Override
protected void update (float time) { protected void update (float time) {
super.update(time); super.update(time);
if (_state != AL10.AL_PLAYING) { if (_state != AL10.AL_PLAYING) {
return; return;
} }
setGain(_clipVol); super.setGain(_clipVol * _streamGain);
}
@Override
public void setGain (float gain) {
_streamGain = gain;
super.setGain(_clipVol * _streamGain);
} }
@Override @Override
@@ -203,9 +208,12 @@ public class OpenALSoundPlayer extends SoundPlayer
read += dec.read(buf); read += dec.read(buf);
} }
return read; return read;
}}; }
s.setGain(_clipVol);
listener.requestCompleted(s); protected float _streamGain = 1F;
};
s.setGain(_clipVol);
listener.requestCompleted(s);
}}); }});
} }
@@ -243,12 +251,19 @@ public class OpenALSoundPlayer extends SoundPlayer
@Override @Override
public void play (String pkgPath, String key, float pan) public void play (String pkgPath, String key, float pan)
{
play(pkgPath, key, pan, getClipVolume());
}
public void play (String pkgPath, String key, float pan, final float gain)
{ {
getSoundQueue().postRunnable(new SoundGrabber(pkgPath, key) { getSoundQueue().postRunnable(new SoundGrabber(pkgPath, key) {
@Override @Override
protected void soundLoaded () { protected void soundLoaded () {
sound.setGain(gain);
sound.play(true); sound.play(true);
}}); }
});
} }
@Override @Override