Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members

peon::AudioEngine Class Reference

This object is used to encapsulate our audio hardware. More...

#include <AudioEngine.h>

Inheritance diagram for peon::AudioEngine:

peon::ISingleton< AudioEngine > List of all members.

Public Member Functions

 AudioEngine ()
 Constructor.
 ~AudioEngine ()
 Destructor.
bool loadEngine (IniConfigReader *pConfig)
 This method loads and instantiates the subsystems necessary in SDL_Mixer and OpenAL to get a device working for each.
void unloadEngine ()
 This method frees up our allocated audio resources.
Mix_Music * loadMIDI (const String &strFilename)
 This method makes the necessary calls to load up a Mix_Music instance which is used for playback of MIDI files.
Mix_Chunk * loadWAVChunk (const String &strFilename)
 This method makes the necessary calls to load up a Mix_Chunk instance which is used for playback of MIDI files.
bool loadAudioNode (const String &strWAVFile, AudioNode *pNode)
 This method internally loads the audio resource into some OpenAL compatible buffers.
void setAudioNode (AudioNode *pNode)
 This method is responsible for setting the current AudioNode.
void playAudioNode (AudioNode *pNode)
 This method is responsible for playing the currently set AudioNode.
void stopAudioNode (AudioNode *pNode)
 This method is responsible for stopping the playback of the AudioNode.
void enableSound ()
 This method just enables the global audio mask.
void disableSound ()
 This method disables the global audio mask.
void enableMusic ()
 This method enables the global music mask.
void disableMusic ()
 This method disables the global music mask.

Static Public Member Functions

static AudioEnginegetSingleton (void)
 Override standard Singleton retrieval.
static AudioEnginegetSingletonPtr (void)
 Override standard Singleton retrieval.

Protected Attributes

ALCcontext * m_pALContext
 The OpenAL context.
ALCdevice * m_pALDevice
 The OpenAL device.
bool m_bEnableSound
 do we enable/disable sound? Note this only affects OGG and WAV playback
bool m_bEnableMusic
 do we enable/disable music? Note this only affects MIDI playback
ALuint m_uAudioBuffers [NUM_BUFFERS]
 a storage buffer for NUM_BUFFERS number of sounds
bool m_bAudioSupported
 is our audio hardware even supported?
int m_iCurrentSlot

Detailed Description

This object is used to encapsulate our audio hardware.

It should be able to play both MIDI tunes (yes people still use 'em) and OGG/WAV files.


Member Function Documentation

static AudioEngine& peon::AudioEngine::getSingleton void   )  [static]
 

Override standard Singleton retrieval.

Remarks:
Why do we do this? Well, it's because the Singleton implementation is in a .h file, which means it gets compiled into anybody who includes it. This is needed for the Singleton template to work, but we actually only want it compiled into the implementation of the class based on the Singleton, not all of them. If we don't change this, we get link errors when trying to use the Singleton-based class from an outside dll.
This method just delegates to the template version anyway, but the implementation stays in this single compilation unit, preventing link errors.

Reimplemented from peon::ISingleton< AudioEngine >.

static AudioEngine* peon::AudioEngine::getSingletonPtr void   )  [static]
 

Override standard Singleton retrieval.

Remarks:
Why do we do this? Well, it's because the Singleton implementation is in a .h file, which means it gets compiled into anybody who includes it. This is needed for the Singleton template to work, but we actually only want it compiled into the implementation of the class based on the Singleton, not all of them. If we don't change this, we get link errors when trying to use the Singleton-based class from an outside dll.
This method just delegates to the template version anyway, but the implementation stays in this single compilation unit, preventing link errors.

Reimplemented from peon::ISingleton< AudioEngine >.

bool peon::AudioEngine::loadAudioNode const String &  strWAVFile,
AudioNode pNode
 

This method internally loads the audio resource into some OpenAL compatible buffers.

When you wish to work with a resource, you need to reference it by the slot you stored it in.

Parameters:
strFilename - path to WAV file
slot - slot to store resource
Returns:
bool - true if sound loaded properly

bool peon::AudioEngine::loadEngine IniConfigReader pConfig  ) 
 

This method loads and instantiates the subsystems necessary in SDL_Mixer and OpenAL to get a device working for each.

If the initialization fails, then you can decide if you want to just disable all sound, or quit the app entirely.

Parameters:
pConfig - The INI information
Returns:
bool - true if audio loaded properly

Mix_Music* peon::AudioEngine::loadMIDI const String &  strFilename  ) 
 

This method makes the necessary calls to load up a Mix_Music instance which is used for playback of MIDI files.

Parameters:
strFilename - path to the MIDI file
Returns:
Mix_Music* - pointer to our Mix_Music object

Mix_Chunk* peon::AudioEngine::loadWAVChunk const String &  strFilename  ) 
 

This method makes the necessary calls to load up a Mix_Chunk instance which is used for playback of MIDI files.

Parameters:
strFilename - path to the WAV file
Returns:
Mix_Music* - pointer to our Mix_Chunk object

void peon::AudioEngine::playAudioNode AudioNode pNode  ) 
 

This method is responsible for playing the currently set AudioNode.

Parameters:
pNode - pointer to a valid AudioNode

void peon::AudioEngine::setAudioNode AudioNode pNode  ) 
 

This method is responsible for setting the current AudioNode.

Parameters:
pNode - pointer to valid AudioNode

void peon::AudioEngine::stopAudioNode AudioNode pNode  ) 
 

This method is responsible for stopping the playback of the AudioNode.

Parameters:
pNode - pointer to AudioNode to stop


The documentation for this class was generated from the following file:
Generated on Thu Dec 1 01:55:41 2005 for Peon by  doxygen 1.4.1