diff --git a/src/java/com/threerings/openal/Sound.java b/src/java/com/threerings/openal/Sound.java index 1e6e5839f..4ab003427 100644 --- a/src/java/com/threerings/openal/Sound.java +++ b/src/java/com/threerings/openal/Sound.java @@ -94,6 +94,9 @@ public class Sound * corresponding to +6db amplification. This will not affect an * already playing sound but will take effect the next time it is * played. + * + *
Note: this value is multiplied by the base gain configured
+ * in the sound manager.
*/
public void setGain (float gain)
{
@@ -224,7 +227,7 @@ public class Sound
// configure the source with our ephemera
AL10.alSourcef(_sourceId, AL10.AL_PITCH, _pitch);
- AL10.alSourcef(_sourceId, AL10.AL_GAIN, _gain);
+ AL10.alSourcef(_sourceId, AL10.AL_GAIN, _gain * _group.getBaseGain());
if (_position != null) {
AL10.alSource(_sourceId, AL10.AL_POSITION, _position);
}
diff --git a/src/java/com/threerings/openal/SoundGroup.java b/src/java/com/threerings/openal/SoundGroup.java
index 661ad73a8..5ed34dd4b 100644
--- a/src/java/com/threerings/openal/SoundGroup.java
+++ b/src/java/com/threerings/openal/SoundGroup.java
@@ -122,6 +122,14 @@ public class SoundGroup
return -1;
}
+ /**
+ * Used to pass the base gain through to sound effects.
+ */
+ protected float getBaseGain ()
+ {
+ return _manager.getBaseGain();
+ }
+
/** Used to track which sources are in use. */
protected static class Source
{
diff --git a/src/java/com/threerings/openal/SoundManager.java b/src/java/com/threerings/openal/SoundManager.java
index 24ab458ca..ff438361d 100644
--- a/src/java/com/threerings/openal/SoundManager.java
+++ b/src/java/com/threerings/openal/SoundManager.java
@@ -88,6 +88,24 @@ public class SoundManager
_clips.setMaxSize(bytes);
}
+ /**
+ * Configures the base gain (which must be a value between 0 and 1.0) which
+ * is multiplied to the individual gain assigned to sound effects (but not
+ * music).
+ */
+ public void setBaseGain (float gain)
+ {
+ _baseGain = gain;
+ }
+
+ /**
+ * Returns the base gain used for sound effects (not music).
+ */
+ public float getBaseGain ()
+ {
+ return _baseGain;
+ }
+
/**
* Creates an object that can be used to manage and play a group of
* sounds. Note: the sound group must be disposed
@@ -126,7 +144,7 @@ public class SoundManager
_streams.get(ii).update(time);
}
}
-
+
/**
* Creates a sound manager and initializes the OpenAL sound subsystem.
*/
@@ -285,6 +303,10 @@ public class SoundManager
/** Used to get back from the background thread to our "main" thread. */
protected RunQueue _rqueue;
+ /** A base gain that is multiplied by the individual gain assigned to
+ * sounds. */
+ protected float _baseGain = 1;
+
/** Contains a mapping of all currently-loading clips. */
protected HashMap