OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | Friends | List of all members
MWSound::SoundManager Class Reference

#include <soundmanagerimp.hpp>

Inheritance diagram for MWSound::SoundManager:
Collaboration diagram for MWSound::SoundManager:

Public Member Functions

 SoundManager (const VFS::Manager *vfs, const std::map< std::string, std::string > &fallbackMap, bool useSound)
 
virtual ~SoundManager ()
 
virtual void processChangedSettings (const Settings::CategorySettingVector &settings)
 
virtual void stopMusic ()
 Stops music if it's playing. More...
 
virtual void streamMusic (const std::string &filename)
 
virtual void startRandomTitle ()
 Starts a random track from the current playlist. More...
 
virtual bool isMusicPlaying ()
 Returns true if music is playing. More...
 
virtual void playPlaylist (const std::string &playlist)
 
virtual void say (const MWWorld::ConstPtr &reference, const std::string &filename)
 
virtual void say (const std::string &filename)
 
virtual bool sayDone (const MWWorld::ConstPtr &reference=MWWorld::ConstPtr()) const
 Is actor not speaking? More...
 
virtual void stopSay (const MWWorld::ConstPtr &reference=MWWorld::ConstPtr())
 Stop an actor speaking. More...
 
virtual float getSaySoundLoudness (const MWWorld::ConstPtr &reference) const
 
virtual MWBase::SoundStreamPtr playTrack (const DecoderPtr &decoder, PlayType type)
 Play a 2D audio track, using a custom decoder. More...
 
virtual void stopTrack (MWBase::SoundStreamPtr stream)
 Stop the given audio track from playing. More...
 
virtual double getTrackTimeDelay (MWBase::SoundStreamPtr stream)
 
virtual MWBase::SoundPtr playSound (const std::string &soundId, float volume, float pitch, PlayType type=Play_TypeSfx, PlayMode mode=Play_Normal, float offset=0)
 
virtual MWBase::SoundPtr playSound3D (const MWWorld::ConstPtr &reference, const std::string &soundId, float volume, float pitch, PlayType type=Play_TypeSfx, PlayMode mode=Play_Normal, float offset=0)
 
virtual MWBase::SoundPtr playSound3D (const osg::Vec3f &initialPos, const std::string &soundId, float volume, float pitch, PlayType type, PlayMode mode, float offset=0)
 
virtual void stopSound (MWBase::SoundPtr sound)
 
virtual void stopSound3D (const MWWorld::ConstPtr &reference, const std::string &soundId)
 Stop the given object from playing the given sound,. More...
 
virtual void stopSound3D (const MWWorld::ConstPtr &reference)
 Stop the given object from playing all sounds. More...
 
virtual void stopSound (const MWWorld::CellStore *cell)
 Stop all sounds for the given cell. More...
 
virtual void stopSound (const std::string &soundId)
 Stop a non-3d looping sound. More...
 
virtual void fadeOutSound3D (const MWWorld::ConstPtr &reference, const std::string &soundId, float duration)
 
virtual bool getSoundPlaying (const MWWorld::ConstPtr &reference, const std::string &soundId) const
 Is the given sound currently playing on the given object? More...
 
virtual void pauseSounds (int types=Play_TypeMask)
 Pauses all currently playing sounds, including music. More...
 
virtual void resumeSounds (int types=Play_TypeMask)
 Resumes all previously paused sounds. More...
 
virtual void update (float duration)
 
virtual void setListenerPosDir (const osg::Vec3f &pos, const osg::Vec3f &dir, const osg::Vec3f &up, bool underwater)
 
virtual void updatePtr (const MWWorld::ConstPtr &old, const MWWorld::ConstPtr &updated)
 
virtual void clear ()
 
- Public Member Functions inherited from MWBase::SoundManager
 SoundManager ()
 
virtual void processChangedSettings (const std::set< std::pair< std::string, std::string > > &settings)=0
 

Protected Member Functions

DecoderPtr getDecoder ()
 

Private Types

typedef std::auto_ptr
< std::deque< Sound_Buffer > > 
SoundBufferList
 
typedef std::map< std::string,
Sound_Buffer * > 
NameBufferMap
 
typedef std::deque
< Sound_Buffer * > 
SoundList
 
typedef std::pair
< MWBase::SoundPtr,
Sound_Buffer * > 
SoundBufferRefPair
 
typedef std::vector
< SoundBufferRefPair
SoundBufferRefPairList
 
typedef std::map
< MWWorld::ConstPtr,
SoundBufferRefPairList
SoundMap
 
typedef std::map
< MWWorld::ConstPtr,
MWBase::SoundStreamPtr
SaySoundMap
 
typedef std::vector
< MWBase::SoundStreamPtr
TrackList
 

Private Member Functions

Sound_BufferinsertSound (const std::string &soundId, const ESM::Sound *sound)
 
Sound_BufferlookupSound (const std::string &soundId) const
 
Sound_BufferloadSound (const std::string &soundId)
 
DecoderPtr loadVoice (const std::string &voicefile)
 
MWBase::SoundStreamPtr playVoice (DecoderPtr decoder, const osg::Vec3f &pos, bool playlocal)
 
void streamMusicFull (const std::string &filename)
 
void updateSounds (float duration)
 
void updateRegionSound (float duration)
 
void updateWaterSound (float duration)
 
float volumeFromType (PlayType type) const
 
 SoundManager (const SoundManager &rhs)
 
SoundManageroperator= (const SoundManager &rhs)
 

Private Attributes

const VFS::ManagermVFS
 
Fallback::Map mFallback
 
std::auto_ptr< Sound_OutputmOutput
 
std::map< std::string,
std::vector< std::string > > 
mMusicFiles
 
std::string mLastPlayedMusic
 
float mMasterVolume
 
float mSFXVolume
 
float mMusicVolume
 
float mVoiceVolume
 
float mFootstepsVolume
 
int mNearWaterRadius
 
int mNearWaterPoints
 
float mNearWaterIndoorTolerance
 
float mNearWaterOutdoorTolerance
 
std::string mNearWaterIndoorID
 
std::string mNearWaterOutdoorID
 
SoundBufferList mSoundBuffers
 
size_t mBufferCacheMin
 
size_t mBufferCacheMax
 
size_t mBufferCacheSize
 
NameBufferMap mBufferNameMap
 
SoundList mUnusedBuffers
 
SoundMap mActiveSounds
 
SaySoundMap mActiveSaySounds
 
TrackList mActiveTracks
 
MWBase::SoundStreamPtr mMusic
 
std::string mCurrentPlaylist
 
bool mListenerUnderwater
 
osg::Vec3f mListenerPos
 
osg::Vec3f mListenerDir
 
osg::Vec3f mListenerUp
 
int mPausedSoundTypes
 
MWBase::SoundPtr mUnderwaterSound
 
MWBase::SoundPtr mNearWaterSound
 

Friends

class OpenAL_Output
 

Additional Inherited Members

- Public Types inherited from MWBase::SoundManager
enum  PlayMode {
  Play_Normal = 0, Play_Loop = 1<<0, Play_NoEnv = 1<<1, Play_RemoveAtDistance = 1<<2,
  Play_NoPlayerLocal = 1<<3, Play_LoopNoEnv = Play_Loop | Play_NoEnv, Play_LoopRemoveAtDistance = Play_Loop | Play_RemoveAtDistance
}
 
enum  PlayType {
  Play_TypeSfx = 1<<4, Play_TypeVoice = 1<<5, Play_TypeFoot = 1<<6, Play_TypeMusic = 1<<7,
  Play_TypeMovie = 1<<8, Play_TypeMask = Play_TypeSfx|Play_TypeVoice|Play_TypeFoot|Play_TypeMusic|Play_TypeMovie
}
 

Member Typedef Documentation

typedef std::map<std::string,Sound_Buffer*> MWSound::SoundManager::NameBufferMap
private
typedef std::auto_ptr<std::deque<Sound_Buffer> > MWSound::SoundManager::SoundBufferList
private
typedef std::deque<Sound_Buffer*> MWSound::SoundManager::SoundList
private

Constructor & Destructor Documentation

MWSound::SoundManager::SoundManager ( const SoundManager rhs)
private
MWSound::SoundManager::SoundManager ( const VFS::Manager vfs,
const std::map< std::string, std::string > &  fallbackMap,
bool  useSound 
)

Here is the call graph for this function:

MWSound::SoundManager::~SoundManager ( )
virtual

Reimplemented from MWBase::SoundManager.

Here is the call graph for this function:

Member Function Documentation

void MWSound::SoundManager::clear ( )
virtual

Implements MWBase::SoundManager.

Here is the caller graph for this function:

void MWSound::SoundManager::fadeOutSound3D ( const MWWorld::ConstPtr reference,
const std::string &  soundId,
float  duration 
)
virtual

Fade out given sound (that is already playing) of given object

Parameters
referenceReference to object, whose sound is faded out
soundIdID of the sound to fade out.
durationTime until volume reaches 0.

Implements MWBase::SoundManager.

Here is the call graph for this function:

DecoderPtr MWSound::SoundManager::getDecoder ( )
protected

Here is the caller graph for this function:

float MWSound::SoundManager::getSaySoundLoudness ( const MWWorld::ConstPtr reference) const
virtual

Check the currently playing say sound for this actor and get an average loudness value (scale [0,1]) at the current time position. If the actor is not saying anything, returns 0.

Implements MWBase::SoundManager.

bool MWSound::SoundManager::getSoundPlaying ( const MWWorld::ConstPtr reference,
const std::string &  soundId 
) const
virtual

Is the given sound currently playing on the given object?

Implements MWBase::SoundManager.

Here is the call graph for this function:

double MWSound::SoundManager::getTrackTimeDelay ( MWBase::SoundStreamPtr  stream)
virtual

Retives the time delay, in seconds, of the audio track (must be a sound returned by playTrack). Only intended to be called by the track decoder's read method.

Implements MWBase::SoundManager.

Sound_Buffer * MWSound::SoundManager::insertSound ( const std::string &  soundId,
const ESM::Sound sound 
)
private

Here is the call graph for this function:

Here is the caller graph for this function:

bool MWSound::SoundManager::isMusicPlaying ( )
virtual

Returns true if music is playing.

Implements MWBase::SoundManager.

Sound_Buffer * MWSound::SoundManager::loadSound ( const std::string &  soundId)
private

Here is the call graph for this function:

DecoderPtr MWSound::SoundManager::loadVoice ( const std::string &  voicefile)
private
Sound_Buffer * MWSound::SoundManager::lookupSound ( const std::string &  soundId) const
private
SoundManager& MWSound::SoundManager::operator= ( const SoundManager rhs)
private
void MWSound::SoundManager::pauseSounds ( int  types = Play_TypeMask)
virtual

Pauses all currently playing sounds, including music.

Implements MWBase::SoundManager.

void MWSound::SoundManager::playPlaylist ( const std::string &  playlist)
virtual

Start playing music from the selected folder

Parameters
nameof the folder that contains the playlist

Implements MWBase::SoundManager.

MWBase::SoundPtr MWSound::SoundManager::playSound ( const std::string &  soundId,
float  volume,
float  pitch,
PlayType  type = Play_TypeSfx,
PlayMode  mode = Play_Normal,
float  offset = 0 
)
virtual

Play a sound, independently of 3D-position

Parameters
offsetNumber of seconds into the sound to start playback.

Implements MWBase::SoundManager.

Here is the call graph for this function:

MWBase::SoundPtr MWSound::SoundManager::playSound3D ( const MWWorld::ConstPtr reference,
const std::string &  soundId,
float  volume,
float  pitch,
PlayType  type = Play_TypeSfx,
PlayMode  mode = Play_Normal,
float  offset = 0 
)
virtual

Play a 3D sound attached to an MWWorld::Ptr. Will be updated automatically with the Ptr's position, unless Play_NoTrack is specified.

Parameters
offsetNumber of seconds into the sound to start playback.

Implements MWBase::SoundManager.

Here is the call graph for this function:

MWBase::SoundPtr MWSound::SoundManager::playSound3D ( const osg::Vec3f &  initialPos,
const std::string &  soundId,
float  volume,
float  pitch,
PlayType  type,
PlayMode  mode,
float  offset = 0 
)
virtual

Play a 3D sound at initialPos. If the sound should be moving, it must be updated using Sound::setPosition.

Parameters
offsetNumber of seconds into the sound to start playback.

Implements MWBase::SoundManager.

Here is the call graph for this function:

MWBase::SoundStreamPtr MWSound::SoundManager::playTrack ( const DecoderPtr decoder,
PlayType  type 
)
virtual

Play a 2D audio track, using a custom decoder.

Implements MWBase::SoundManager.

MWBase::SoundStreamPtr MWSound::SoundManager::playVoice ( DecoderPtr  decoder,
const osg::Vec3f &  pos,
bool  playlocal 
)
private

Here is the call graph for this function:

void MWSound::SoundManager::processChangedSettings ( const Settings::CategorySettingVector settings)
virtual

Here is the call graph for this function:

void MWSound::SoundManager::resumeSounds ( int  types = Play_TypeMask)
virtual

Resumes all previously paused sounds.

Implements MWBase::SoundManager.

void MWSound::SoundManager::say ( const MWWorld::ConstPtr reference,
const std::string &  filename 
)
virtual

Make an actor say some text.

Parameters
filenamename of a sound file in "Sound/" in the data directory.

Implements MWBase::SoundManager.

Here is the call graph for this function:

void MWSound::SoundManager::say ( const std::string &  filename)
virtual

Say some text, without an actor ref

Parameters
filenamename of a sound file in "Sound/" in the data directory.

Implements MWBase::SoundManager.

bool MWSound::SoundManager::sayDone ( const MWWorld::ConstPtr reference = MWWorld::ConstPtr()) const
virtual

Is actor not speaking?

Implements MWBase::SoundManager.

void MWSound::SoundManager::setListenerPosDir ( const osg::Vec3f &  pos,
const osg::Vec3f &  dir,
const osg::Vec3f &  up,
bool  underwater 
)
virtual

Implements MWBase::SoundManager.

void MWSound::SoundManager::startRandomTitle ( )
virtual

Starts a random track from the current playlist.

Implements MWBase::SoundManager.

Here is the call graph for this function:

void MWSound::SoundManager::stopMusic ( )
virtual

Stops music if it's playing.

Implements MWBase::SoundManager.

void MWSound::SoundManager::stopSay ( const MWWorld::ConstPtr reference = MWWorld::ConstPtr())
virtual

Stop an actor speaking.

Implements MWBase::SoundManager.

void MWSound::SoundManager::stopSound ( MWBase::SoundPtr  sound)
virtual

Stop the given sound from playing

Note
no-op if sound is null

Implements MWBase::SoundManager.

void MWSound::SoundManager::stopSound ( const MWWorld::CellStore cell)
virtual

Stop all sounds for the given cell.

Implements MWBase::SoundManager.

Here is the call graph for this function:

void MWSound::SoundManager::stopSound ( const std::string &  soundId)
virtual

Stop a non-3d looping sound.

Implements MWBase::SoundManager.

Here is the call graph for this function:

void MWSound::SoundManager::stopSound3D ( const MWWorld::ConstPtr reference,
const std::string &  soundId 
)
virtual

Stop the given object from playing the given sound,.

Implements MWBase::SoundManager.

Here is the call graph for this function:

void MWSound::SoundManager::stopSound3D ( const MWWorld::ConstPtr reference)
virtual

Stop the given object from playing all sounds.

Implements MWBase::SoundManager.

void MWSound::SoundManager::stopTrack ( MWBase::SoundStreamPtr  stream)
virtual

Stop the given audio track from playing.

Implements MWBase::SoundManager.

void MWSound::SoundManager::streamMusic ( const std::string &  filename)
virtual

Play a soundifle

Parameters
filenamename of a sound file in "Music/" in the data directory.

Implements MWBase::SoundManager.

void MWSound::SoundManager::streamMusicFull ( const std::string &  filename)
private
void MWSound::SoundManager::update ( float  duration)
virtual

Implements MWBase::SoundManager.

Here is the call graph for this function:

void MWSound::SoundManager::updatePtr ( const MWWorld::ConstPtr old,
const MWWorld::ConstPtr updated 
)
virtual

Implements MWBase::SoundManager.

void MWSound::SoundManager::updateRegionSound ( float  duration)
private

Here is the call graph for this function:

void MWSound::SoundManager::updateSounds ( float  duration)
private

Here is the call graph for this function:

void MWSound::SoundManager::updateWaterSound ( float  duration)
private

Here is the call graph for this function:

float MWSound::SoundManager::volumeFromType ( PlayType  type) const
private

Friends And Related Function Documentation

friend class OpenAL_Output
friend

Member Data Documentation

SaySoundMap MWSound::SoundManager::mActiveSaySounds
private
SoundMap MWSound::SoundManager::mActiveSounds
private
TrackList MWSound::SoundManager::mActiveTracks
private
size_t MWSound::SoundManager::mBufferCacheMax
private
size_t MWSound::SoundManager::mBufferCacheMin
private
size_t MWSound::SoundManager::mBufferCacheSize
private
NameBufferMap MWSound::SoundManager::mBufferNameMap
private
std::string MWSound::SoundManager::mCurrentPlaylist
private
Fallback::Map MWSound::SoundManager::mFallback
private
float MWSound::SoundManager::mFootstepsVolume
private
std::string MWSound::SoundManager::mLastPlayedMusic
private
osg::Vec3f MWSound::SoundManager::mListenerDir
private
osg::Vec3f MWSound::SoundManager::mListenerPos
private
bool MWSound::SoundManager::mListenerUnderwater
private
osg::Vec3f MWSound::SoundManager::mListenerUp
private
float MWSound::SoundManager::mMasterVolume
private
MWBase::SoundStreamPtr MWSound::SoundManager::mMusic
private
std::map<std::string, std::vector<std::string> > MWSound::SoundManager::mMusicFiles
private
float MWSound::SoundManager::mMusicVolume
private
std::string MWSound::SoundManager::mNearWaterIndoorID
private
float MWSound::SoundManager::mNearWaterIndoorTolerance
private
std::string MWSound::SoundManager::mNearWaterOutdoorID
private
float MWSound::SoundManager::mNearWaterOutdoorTolerance
private
int MWSound::SoundManager::mNearWaterPoints
private
int MWSound::SoundManager::mNearWaterRadius
private
MWBase::SoundPtr MWSound::SoundManager::mNearWaterSound
private
std::auto_ptr<Sound_Output> MWSound::SoundManager::mOutput
private
int MWSound::SoundManager::mPausedSoundTypes
private
float MWSound::SoundManager::mSFXVolume
private
SoundBufferList MWSound::SoundManager::mSoundBuffers
private
MWBase::SoundPtr MWSound::SoundManager::mUnderwaterSound
private
SoundList MWSound::SoundManager::mUnusedBuffers
private
const VFS::Manager* MWSound::SoundManager::mVFS
private
float MWSound::SoundManager::mVoiceVolume
private

The documentation for this class was generated from the following files: