SoundEffectManager Class Reference

A class for managing a large number of sound effects playing on different channels, along with simple prioritizing. More...

#include <SoundEffectManager.h>

List of all members.

Public Member Functions

int playSample (unsigned int sampleNum, bool override=true, unsigned int overrideChannel=0)
 Plays a sample and forces it to override any other sample playing in the overrideChannel.
int addSample (char *filename)
 Adds a sample from file to the internal storage.
void setVolume (int volume)
 Sets the volume using SDL_Mixer. Max is 128.
 SoundEffectManager (char *dir)
 Instantiate the sound effect manager from disk.
virtual ~SoundEffectManager ()
 Destruct the sound effect manager, clearing all samples.


Detailed Description

A class for managing a large number of sound effects playing on different channels, along with simple prioritizing.


Constructor & Destructor Documentation

SoundEffectManager::SoundEffectManager char *  dir  ) 
 

Instantiate the sound effect manager from disk.

This method loads every WAV in a directory, sequentially, with no gaps. This means you need 0.wav, 1.wav, ...

If you want to add OGG files, you will have to add those manually for now.

Parameters:
dir The path of the directory to load (for example, data/wav)


Member Function Documentation

int SoundEffectManager::addSample char *  filename  ) 
 

Adds a sample from file to the internal storage.

Loads a sample from a provided filename. Returns -1 on failure (file not found/cannot read file/unknown file format).

Returns the ID of this sample on a successful load.

Parameters:
filename The filename to load from (for example, data/wav/foobar.wav)
Returns:
-1 if there was an error, or the sample ID if the load succeeded.

int SoundEffectManager::playSample unsigned int  samp,
bool  override = true,
unsigned int  overrideChan = 0
 

Plays a sample and forces it to override any other sample playing in the overrideChannel.

Plays a sample from storage, with the option to "override" any samples that are already playing. This method allows you to specify which channel the sample will play on (only available when override is set to TRUE).

If an error occurs, will return -1 and emit a text error on stderr.

Parameters:
samp The sample ID to play
override If true, it will override the channel defined by overrideChan
overrideChan The sound channel to override if override is set to true
Returns:
The return code from SDL_Mixer, or -1 if failure

void SoundEffectManager::setVolume int  vol  ) 
 

Sets the volume using SDL_Mixer. Max is 128.

Allows you to set the volume of sound effects, from 0 (mute) to 128 (loudest). SDL dependent.

Parameters:
vol The volume level. See SDL docs for more information.


The documentation for this class was generated from the following files:
Generated on Sun Jan 14 16:49:11 2007 for Propane Injector by  doxygen 1.4.6