Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

ONE::sound::SoundManager Class Reference

Inheritance diagram for ONE::sound::SoundManager:

Inheritance graph
[legend]
List of all members.

Detailed Description

a sound effect manager

This class calls init on its instantiation and cleanup on shutdown.

Author:
Daniel Seibert


Public Types

typedef std::pair< SoundEffectRef,
int > 
EffectInfo

Public Member Functions

void cleanup ()
void clear ()
 clears the cache
MusicStreamRef createMusicStream (const std::string &filename)
SoundEffectRef createSoundEffect (const std::string &filename)
Sto get (const Key &k)
 retrieves the object identified by k
int getChannels () const
 returns the number of channels, 1 for mono, 2 for stereo
unsigned int getCount () const
G3D::uint16 getFormat () const
 returns the audio format
int getRate () const
 returns the audio rate in samples per second
bool init ()
bool isCached (const Key &k) const
 checks if the object identified by k is cached
void pauseChannel (int channel)
 pauses playback of the given channel
void pauseMusic ()
 pauses music playback
EffectInfo playEffect (const std::string &filename, int channel=-1)
 plays a sound effect
MusicStreamRef playMusic (const std::string &filename, int repeats=-1)
 plays a music file
void remove (const Key &k)
 removes an object from the cache
void resumeChannel (int channel)
 resumes playback of the given channel
void resumeMusic ()
 resumes music playback
void setEffectVolume (int channel, float vol)
 sets the volume of the given channel to the given ratio
void setMusicVolume (float vol)
 sets the music volume
 SoundManager ()
void stopChannel (int channel)
 stops playback of the given channel
void stopEffect (int channel)
void stopMusic ()
 stops music playback
 ~SoundManager ()

Protected Member Functions

virtual Sto create (const Key &)=0
SoundEffectRef create (const std::string &)
virtual void dispose (Sto &)=0
void dispose (SoundEffectRef &)
virtual std::string toString (const Key &) const =0
 converts the given key to an identifier string
std::string toString (const std::string &) const


Member Typedef Documentation

typedef std::pair<SoundEffectRef,int> ONE::sound::SoundManager::EffectInfo
 


Constructor & Destructor Documentation

ONE::sound::SoundManager::SoundManager  ) 
 

ONE::sound::SoundManager::~SoundManager  ) 
 


Member Function Documentation

void ONE::sound::AudioDevice::cleanup  )  [inherited]
 

template<typename T, typename Key, typename Sto>
void ONE::util::ResourceManagerBase< T, Key, Sto >::clear  )  [inherited]
 

clears the cache

All cached resources are destroyed. Note that calling this function will invalidate any pointer to a cached resource that may be held elsewhere.

template<typename T, typename Key, typename Sto>
virtual Sto ONE::util::ResourceManagerBase< T, Key, Sto >::create const Key  )  [protected, pure virtual, inherited]
 

Implemented in ONE::util::ResourceManager< T, Key, Handle< T > >.

SoundEffectRef ONE::sound::SoundManager::create const std::string &   )  [protected]
 

MusicStreamRef ONE::sound::AudioDevice::createMusicStream const std::string &  filename  )  [inherited]
 

SoundEffectRef ONE::sound::AudioDevice::createSoundEffect const std::string &  filename  )  [inherited]
 

template<typename T, typename Key, typename Sto>
virtual void ONE::util::ResourceManagerBase< T, Key, Sto >::dispose Sto &   )  [protected, pure virtual, inherited]
 

Implemented in ONE::util::ResourceManager< T, Key, T * >, and ONE::util::ResourceManager< T, Key, Handle< T > >.

void ONE::sound::SoundManager::dispose SoundEffectRef  )  [protected]
 

template<typename T, typename Key, typename Sto>
Sto ONE::util::ResourceManagerBase< T, Key, Sto >::get const Key k  )  [inherited]
 

retrieves the object identified by k

If k is found in the cache, the cached object is returned. Otherwise, a new object is created through the create function, cached via insert and returned.

Parameters:
k the key identifying the desired object
Returns:
an object as specified above

int ONE::sound::AudioDevice::getChannels  )  const [inline, inherited]
 

returns the number of channels, 1 for mono, 2 for stereo

template<typename T, typename Key, typename Sto>
unsigned int ONE::util::ResourceManagerBase< T, Key, Sto >::getCount  )  const [inline, inherited]
 

Returns:
the number of cached objects

G3D::uint16 ONE::sound::AudioDevice::getFormat  )  const [inline, inherited]
 

returns the audio format

int ONE::sound::AudioDevice::getRate  )  const [inline, inherited]
 

returns the audio rate in samples per second

bool ONE::sound::AudioDevice::init  )  [inherited]
 

template<typename T, typename Key, typename Sto>
bool ONE::util::ResourceManagerBase< T, Key, Sto >::isCached const Key k  )  const [inline, inherited]
 

checks if the object identified by k is cached

The resource will not be loaded if k is not found. Note that this function runs in O(log n) time.

Parameters:
k the desired key

void ONE::sound::AudioDevice::pauseChannel int  channel  )  [inherited]
 

pauses playback of the given channel

Parameters:
channel the channel that should be paused or -1 to pause all channels

void ONE::sound::AudioDevice::pauseMusic  )  [inherited]
 

pauses music playback

EffectInfo ONE::sound::SoundManager::playEffect const std::string &  filename,
int  channel = -1
 

plays a sound effect

Several effects may be played concurrently.

Parameters:
filename the file's path

MusicStreamRef ONE::sound::SoundManager::playMusic const std::string &  filename,
int  repeats = -1
 

plays a music file

The old music will be stopped if a new file is requested while music is already playing.

Parameters:
filename the file's path
repeats the number of times the music should be repeated. 0 to play just once, -1 for an (almost) infinite loop

template<typename T, typename Key, typename Sto>
void ONE::util::ResourceManagerBase< T, Key, Sto >::remove const Key k  )  [inherited]
 

removes an object from the cache

The removed object is destroyed. Note that this will invalidate any pointer to the resource that may be held elsewhere. If k is unknown, this function will fail silently.

Parameters:
k a key

void ONE::sound::AudioDevice::resumeChannel int  channel  )  [inherited]
 

resumes playback of the given channel

Parameters:
channel the channel that should be resumed or -1 to resume all channels

void ONE::sound::AudioDevice::resumeMusic  )  [inherited]
 

resumes music playback

void ONE::sound::AudioDevice::setEffectVolume int  channel,
float  vol
[inherited]
 

sets the volume of the given channel to the given ratio

Parameters:
channel the channel whose volume should be changed or -1 to control all channels
vol the new volume, 0.0 being muted and 1.0 the maximum volume

void ONE::sound::AudioDevice::setMusicVolume float  vol  )  [inherited]
 

sets the music volume

Parameters:
vol the new volume, 0.0 being muted and 1.0 the maximum volume

void ONE::sound::AudioDevice::stopChannel int  channel  )  [inherited]
 

stops playback of the given channel

Parameters:
channel the channel that should be stopped or -1 to stop all effects

void ONE::sound::SoundManager::stopEffect int  channel  ) 
 

void ONE::sound::AudioDevice::stopMusic  )  [inherited]
 

stops music playback

template<typename T, typename Key, typename Sto>
virtual std::string ONE::util::ResourceManagerBase< T, Key, Sto >::toString const Key  )  const [protected, pure virtual, inherited]
 

converts the given key to an identifier string

The return value is stored in the resource map and must serve as a unique identifier for the key.

std::string ONE::sound::SoundManager::toString const std::string &   )  const [protected]
 


Generated on Wed Sep 7 19:03:30 2005 for ONEngine by  doxygen 1.4.3