GameEngine::SoundManager Class Reference

#include <SoundManager.h>

Inheritance diagram for GameEngine::SoundManager:

Inheritance graph
Collaboration diagram for GameEngine::SoundManager:

Collaboration graph
List of all members.

Detailed Description

The SoundManager is responsible for the loading and playing of game audio. There are three components to this:

1. A listener with a position and orientation in space which represents the player 2. Buffers which store audio data loaded from files 3. Sources which represent a sound being generated from a source with a position and velocity

First you must load a file with loadSound, and make note of which buffer it was loading in to. Then when you want to play that sound you must call playSound with the id of the buffer the sound was loaded in to the position in space where the sound should be played, and the velocity at which that source of sound is moving at.

Definition at line 38 of file SoundManager.h.

Public Member Functions

 SoundManager (GameApp *application)
virtual ~SoundManager ()
bool init ()
void setListenerNode (Ogre::SceneNode *listenerNode)
bool loadSound (std::string fileName, ALuint *bufferId)
bool playSound (ALuint bufId, ALuint *soundId, bool loop, Vector3 position, Vector3 velocity)
bool stopSound (ALuint soundId)
bool stopAllSounds ()
void update (const double &dt)

Private Member Functions

bool loadWavFile (std::string fileName, ALuint destAudioBuffId)
bool loadOggFile (std::string fileName, ALuint destAudioBuffId)
bool setListenerPos (Vector3 pos, Vector3 vel, Quaternion ori)

Private Attributes

ALCdevice * mAudioDevice
ALCcontext * mAudioContext
ALuint mAudioBuffers [MAX_NUM_BUFFERS]
bool mBufferInUse [MAX_NUM_BUFFERS]
ALuint mBuffersUsed
ALuint mAudioSources [MAX_NUM_SOURCES]
bool mSourceInUse [MAX_NUM_SOURCES]
ALuint mSourcesUsed
Ogre::SceneNode * mListenerNode

Constructor & Destructor Documentation

GameEngine::SoundManager::SoundManager ( GameApp application  ) 


application A pointer back to the game application

Definition at line 5 of file SoundManager.cpp.

GameEngine::SoundManager::~SoundManager (  )  [virtual]


Definition at line 24 of file SoundManager.cpp.

Member Function Documentation

bool GameEngine::SoundManager::init (  )  [virtual]

Initialises the sound manager

true if initialisation was successfull, false otherwise

Reimplemented from GameEngine::Process.

Definition at line 41 of file SoundManager.cpp.

void GameEngine::SoundManager::setListenerNode ( Ogre::SceneNode *  listenerNode  ) 

Set the scene node which is used to represent the listener in the scene.

listenerNode The scene node representing the lsitener in the scene

Definition at line 90 of file SoundManager.cpp.

bool GameEngine::SoundManager::loadSound ( std::string  fileName,
ALuint *  bufferId 

Load a sound into a buffer

fileName The name of the file to load
bufferId A pointer to an ALuint, which will be used to return to the caller the ID of the buffer the file was loaded to
true of the file was loaded, false otherwise

Definition at line 96 of file SoundManager.cpp.

bool GameEngine::SoundManager::playSound ( ALuint  bufId,
ALuint *  soundId,
bool  loop,
Vector3  position,
Vector3  velocity 

Play a sound from a buffer

bufId The ID of the buffer containing the sound to be played
soundId A pointer to an ALuint used to return to the caller the ID of the source created to represent this sound
loop True if the sound should loop, false if it should play just once
position The position the sound should be played at
velocity The velocity the sound source is moving at
true if the sound was played, false otherwise

Definition at line 135 of file SoundManager.cpp.

bool GameEngine::SoundManager::stopSound ( ALuint  soundId  ) 

Stop a sound

soundId The id of the source to stop playing
true if the sound could be stopped, false otherwise

Definition at line 213 of file SoundManager.cpp.

bool GameEngine::SoundManager::stopAllSounds (  ) 

Stop all sounds

true if sounds were stopped, false otherwise

Definition at line 234 of file SoundManager.cpp.

void GameEngine::SoundManager::update ( const double &  dt  )  [virtual]

Update the sound manager, performs tasks required each frame such as updating the position of the listener.

dt Time since last frame

Reimplemented from GameEngine::Process.

Definition at line 321 of file SoundManager.cpp.

bool GameEngine::SoundManager::loadWavFile ( std::string  fileName,
ALuint  destAudioBuffId 
) [private]

Loads a wav file

Definition at line 240 of file SoundManager.cpp.

bool GameEngine::SoundManager::loadOggFile ( std::string  fileName,
ALuint  destAudioBuffId 
) [private]

Loads an ogg vorbis file

Definition at line 280 of file SoundManager.cpp.

bool GameEngine::SoundManager::setListenerPos ( Vector3  pos,
Vector3  vel,
Quaternion  ori 
) [private]

Set the position and orientation of the listener

pos The position of the listener
vel The velocity the listener is moving at
ori The orientation of the listern

Definition at line 328 of file SoundManager.cpp.

Member Data Documentation

GameApp* GameEngine::SoundManager::mApplication [private]

Definition at line 113 of file SoundManager.h.

ALCdevice* GameEngine::SoundManager::mAudioDevice [private]

Definition at line 115 of file SoundManager.h.

ALCcontext* GameEngine::SoundManager::mAudioContext [private]

Definition at line 116 of file SoundManager.h.

ALuint GameEngine::SoundManager::mAudioBuffers[MAX_NUM_BUFFERS] [private]

Definition at line 118 of file SoundManager.h.

bool GameEngine::SoundManager::mBufferInUse[MAX_NUM_BUFFERS] [private]

Definition at line 119 of file SoundManager.h.

ALuint GameEngine::SoundManager::mBuffersUsed [private]

Definition at line 120 of file SoundManager.h.

ALuint GameEngine::SoundManager::mAudioSources[MAX_NUM_SOURCES] [private]

Definition at line 122 of file SoundManager.h.

bool GameEngine::SoundManager::mSourceInUse[MAX_NUM_SOURCES] [private]

Definition at line 123 of file SoundManager.h.

ALuint GameEngine::SoundManager::mSourcesUsed [private]

Definition at line 124 of file SoundManager.h.

Ogre::SceneNode* GameEngine::SoundManager::mListenerNode [private]

Definition at line 126 of file SoundManager.h.

The documentation for this class was generated from the following files:
Generated on Thu Apr 19 09:49:11 2007 for GameEngine by  doxygen 1.5.2