Engine::Audio Class Reference

Singleton for managing sound effects and music. More...

#include <Audio.h>

List of all members.

Public Member Functions

 ~Audio ()
void pause ()
 Pause all playing sound effects.
void resume ()
 Resume all paused sound effects.
bool get_paused ()
 Return the paused state.
void commit ()
 Commit all changes to the listeners and sound sources.
void attach_listner (SoundListener *listener)
 Remember a listener.
void attach_source (SoundSource *source)
void forget_listener (SoundListener *listener)
 Forget about a listener.
void forget_source (SoundSource *source)
 Forget about a sound source.

Static Public Member Functions

static Audioget_instance ()

Private Member Functions

 Audio ()

Private Attributes

std::vector< boost::shared_ptr<
SoundInstance > > 
m_instances
 The playing sound instances for positional audio.
std::vector< SoundListener * > m_listeners
 Listeners Ordered as in m_instances.
std::vector< SoundSource * > m_sources
 SoundSources Ordered as in m_instances.
std::vector< boost::shared_ptr<
ALSoundSource > > 
m_al_sources
 OpenAL sources.
ALfloat m_speed_of_sound
 The speed of sound for doppler calculations.
bool m_paused
 True if all sounds have been paused.


Detailed Description

Singleton for managing sound effects and music.

Definition at line 31 of file Audio.h.


Constructor & Destructor Documentation

Engine::Audio::Audio (  )  [private]

Definition at line 23 of file Audio.cpp.

Engine::Audio::~Audio (  ) 

Definition at line 51 of file Audio.cpp.


Member Function Documentation

void Engine::Audio::attach_listner ( SoundListener listener  ) 

Remember a listener.

Used when a listener is constructed.

Definition at line 247 of file Audio.cpp.

void Engine::Audio::attach_source ( SoundSource source  ) 

Todo:
The mapping between Audio::SoundSources and OpenAL sound sources isn't scalable. Try using a fixed number n of OpenAL sources and switching to the loudest n Audio::SoundSources. Try about 30. On my system, having many sound sources causes an error. Having more than a few causes terribly low refresh rate.

Definition at line 271 of file Audio.cpp.

void Engine::Audio::commit (  ) 

Commit all changes to the listeners and sound sources.

Sounds will begin to play at their set gains and pitches. Should be called once per tick after sounds have been set using SoundSources and Listeners.

Definition at line 118 of file Audio.cpp.

void Engine::Audio::forget_listener ( SoundListener listener  ) 

Forget about a listener.

Used when the listener is destructing.

Definition at line 286 of file Audio.cpp.

void Engine::Audio::forget_source ( SoundSource source  ) 

Forget about a sound source.

Definition at line 317 of file Audio.cpp.

Audio & Engine::Audio::get_instance (  )  [static]

Definition at line 56 of file Audio.cpp.

bool Engine::Audio::get_paused (  ) 

Return the paused state.

Returns:
true if resume() was called after the last call to pause(), or if pause() has not been called. Returns false otherwise.

Definition at line 102 of file Audio.cpp.

void Engine::Audio::pause (  ) 

Pause all playing sound effects.

Definition at line 62 of file Audio.cpp.

void Engine::Audio::resume (  ) 

Resume all paused sound effects.

Definition at line 82 of file Audio.cpp.


Member Data Documentation

std::vector<boost::shared_ptr<ALSoundSource> > Engine::Audio::m_al_sources [private]

OpenAL sources.

There is a hardware / sound driver limit on the number available, and also performance problems with large numbers of sounds. Therefore we have a fixed limited number of OpenAL sources. Only the most audiable sounds are played.

Definition at line 89 of file Audio.h.

std::vector<boost::shared_ptr<SoundInstance> > Engine::Audio::m_instances [private]

The playing sound instances for positional audio.

Sorted by listner then SoundSource, since the listners are created and destroyed less often, and they can cause the most moves when created or destroyed.

Definition at line 74 of file Audio.h.

std::vector<SoundListener *> Engine::Audio::m_listeners [private]

Listeners Ordered as in m_instances.

Definition at line 78 of file Audio.h.

bool Engine::Audio::m_paused [private]

True if all sounds have been paused.

Definition at line 98 of file Audio.h.

std::vector<SoundSource *> Engine::Audio::m_sources [private]

SoundSources Ordered as in m_instances.

Definition at line 82 of file Audio.h.

ALfloat Engine::Audio::m_speed_of_sound [private]

The speed of sound for doppler calculations.

It isn't used to delay distant sounds, only change the pitch when something moves.

Definition at line 95 of file Audio.h.


The documentation for this class was generated from the following files:
Get Racer at SourceForge.net. Fast, secure and Free Open Source software downloads

Generated at Mon Sep 6 00:41:17 2010 by Doxygen version 1.4.7 for Racer version svn335.