com.threerings.openal
Class SoundGroup

java.lang.Object
  extended by com.threerings.openal.SoundGroup

public class SoundGroup
extends Object

Manages a group of sounds, binding them to OpenAL sources as they are played and freeing up those sources for use by other sounds when the sounds are finished.


Nested Class Summary
protected static class SoundGroup.PooledSource
          Used to track which sources are in use.
 
Field Summary
protected  float _baseGain
          The base gain, or -1 to inherit from the manager.
protected  SoundManager _manager
           
protected  ClipProvider _provider
           
protected  ArrayList<SoundGroup.PooledSource> _sources
           
 
Constructor Summary
protected SoundGroup(SoundManager manager, ClipProvider provider, int sources)
           
 
Method Summary
protected  Source acquireSource(Sound acquirer)
          Called by a Sound when it wants to obtain a source on which to play its clip.
protected  void baseGainChanged()
          Called by the manager when the base gain has changed.
 void dispose()
          Disposes this sound group, freeing up the OpenAL sources with which it is associated.
 float getBaseGain()
          Returns the base gain for this group, or -1 if inherited from the manager.
protected  float getInheritedBaseGain()
          Used to pass the base gain through to sound effects.
 Sound getSound(String path)
          Obtains an "instance" of the specified sound which can be positioned, played, looped and otherwise used to make noise.
 void preloadClip(String path)
          Queues up the specified sound clip for pre-loading into the cache.
 void reclaimAll()
          Stops and reclaims all sounds from this sound group but does not free the sources.
 void setBaseGain(float gain)
          Sets the base gain for this group, or -1 to inherit from the manager (the default).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_manager

protected SoundManager _manager

_provider

protected ClipProvider _provider

_sources

protected ArrayList<SoundGroup.PooledSource> _sources

_baseGain

protected float _baseGain
The base gain, or -1 to inherit from the manager.

Constructor Detail

SoundGroup

protected SoundGroup(SoundManager manager,
                     ClipProvider provider,
                     int sources)
Method Detail

setBaseGain

public void setBaseGain(float gain)
Sets the base gain for this group, or -1 to inherit from the manager (the default).


getBaseGain

public float getBaseGain()
Returns the base gain for this group, or -1 if inherited from the manager.


preloadClip

public void preloadClip(String path)
Queues up the specified sound clip for pre-loading into the cache.


getSound

public Sound getSound(String path)
Obtains an "instance" of the specified sound which can be positioned, played, looped and otherwise used to make noise.


dispose

public void dispose()
Disposes this sound group, freeing up the OpenAL sources with which it is associated. All sounds obtained from this group will no longer be usable and should be discarded.


reclaimAll

public void reclaimAll()
Stops and reclaims all sounds from this sound group but does not free the sources.


acquireSource

protected Source acquireSource(Sound acquirer)
Called by a Sound when it wants to obtain a source on which to play its clip.


getInheritedBaseGain

protected float getInheritedBaseGain()
Used to pass the base gain through to sound effects.


baseGainChanged

protected void baseGainChanged()
Called by the manager when the base gain has changed.