Add support for a base gain level to be applied to all sound effects.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4124 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -94,6 +94,9 @@ public class Sound
|
|||||||
* corresponding to +6db amplification. This will not affect an
|
* corresponding to +6db amplification. This will not affect an
|
||||||
* already playing sound but will take effect the next time it is
|
* already playing sound but will take effect the next time it is
|
||||||
* played.
|
* played.
|
||||||
|
*
|
||||||
|
* <p><em>Note:</em> this value is multiplied by the base gain configured
|
||||||
|
* in the sound manager.
|
||||||
*/
|
*/
|
||||||
public void setGain (float gain)
|
public void setGain (float gain)
|
||||||
{
|
{
|
||||||
@@ -224,7 +227,7 @@ public class Sound
|
|||||||
|
|
||||||
// configure the source with our ephemera
|
// configure the source with our ephemera
|
||||||
AL10.alSourcef(_sourceId, AL10.AL_PITCH, _pitch);
|
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) {
|
if (_position != null) {
|
||||||
AL10.alSource(_sourceId, AL10.AL_POSITION, _position);
|
AL10.alSource(_sourceId, AL10.AL_POSITION, _position);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -122,6 +122,14 @@ public class SoundGroup
|
|||||||
return -1;
|
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. */
|
/** Used to track which sources are in use. */
|
||||||
protected static class Source
|
protected static class Source
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -88,6 +88,24 @@ public class SoundManager
|
|||||||
_clips.setMaxSize(bytes);
|
_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
|
* Creates an object that can be used to manage and play a group of
|
||||||
* sounds. <em>Note:</em> the sound group <em>must</em> be disposed
|
* sounds. <em>Note:</em> the sound group <em>must</em> be disposed
|
||||||
@@ -126,7 +144,7 @@ public class SoundManager
|
|||||||
_streams.get(ii).update(time);
|
_streams.get(ii).update(time);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a sound manager and initializes the OpenAL sound subsystem.
|
* 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. */
|
/** Used to get back from the background thread to our "main" thread. */
|
||||||
protected RunQueue _rqueue;
|
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. */
|
/** Contains a mapping of all currently-loading clips. */
|
||||||
protected HashMap<Comparable,ClipBuffer> _loading =
|
protected HashMap<Comparable,ClipBuffer> _loading =
|
||||||
new HashMap<Comparable,ClipBuffer>();
|
new HashMap<Comparable,ClipBuffer>();
|
||||||
|
|||||||
Reference in New Issue
Block a user