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 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 StreamplayTrack (const DecoderPtr &decoder, Type type)
 Play a 2D audio track, using a custom decoder. More...
 
virtual void stopTrack (Stream *stream)
 Stop the given audio track from playing. More...
 
virtual double getTrackTimeDelay (Stream *stream)
 
virtual SoundplaySound (const std::string &soundId, float volume, float pitch, Type type=Type::Sfx, PlayMode mode=PlayMode::Normal, float offset=0)
 
virtual SoundplaySound3D (const MWWorld::ConstPtr &reference, const std::string &soundId, float volume, float pitch, Type type=Type::Sfx, PlayMode mode=PlayMode::Normal, float offset=0)
 
virtual SoundplaySound3D (const osg::Vec3f &initialPos, const std::string &soundId, float volume, float pitch, Type type, PlayMode mode, float offset=0)
 
virtual void stopSound (Sound *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)
 Pauses all currently playing sounds, including music. More...
 
virtual void resumeSounds (int types)
 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 ()
 
void stopSound (Sound_Buffer *sfx, const MWWorld::ConstPtr &ptr)
 Stop the given object from playing given sound buffer. More...
 

Private Types

typedef std::unique_ptr
< std::deque< Sound_Buffer > > 
SoundBufferList
 
typedef std::unordered_map
< std::string, Sound_Buffer * > 
NameBufferMap
 
typedef std::deque
< Sound_Buffer * > 
SoundList
 
typedef std::pair
< MWBase::Sound
*, Sound_Buffer * > 
SoundBufferRefPair
 
typedef std::vector
< SoundBufferRefPair
SoundBufferRefPairList
 
typedef std::map
< MWWorld::ConstPtr,
SoundBufferRefPairList
SoundMap
 
typedef std::map
< MWWorld::ConstPtr, Stream * > 
SaySoundMap
 
typedef std::vector< Stream * > 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)
 
SoundgetSoundRef ()
 
StreamgetStreamRef ()
 
StreamplayVoice (DecoderPtr decoder, const osg::Vec3f &pos, bool playlocal)
 
void streamMusicFull (const std::string &filename)
 
void advanceMusic (const std::string &filename)
 
void startRandomTitle ()
 
void updateSounds (float duration)
 
void updateRegionSound (float duration)
 
void updateWaterSound (float duration)
 
void updateMusic (float duration)
 
float volumeFromType (Type type) const
 
 SoundManager (const SoundManager &rhs)
 
SoundManageroperator= (const SoundManager &rhs)
 

Private Attributes

const VFS::ManagermVFS
 
Fallback::Map mFallback
 
std::unique_ptr< Sound_OutputmOutput
 
std::unordered_map
< std::string, std::vector
< std::string > > 
mMusicFiles
 
std::unordered_map
< std::string, std::vector
< int > > 
mMusicToPlay
 
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
 
std::unique_ptr< std::deque
< Sound > > 
mSounds
 
std::vector< Sound * > mUnusedSounds
 
std::unique_ptr< std::deque
< Stream > > 
mStreams
 
std::vector< Stream * > mUnusedStreams
 
SoundMap mActiveSounds
 
SaySoundMap mActiveSaySounds
 
TrackList mActiveTracks
 
StreammMusic
 
std::string mCurrentPlaylist
 
bool mListenerUnderwater
 
osg::Vec3f mListenerPos
 
osg::Vec3f mListenerDir
 
osg::Vec3f mListenerUp
 
int mPausedSoundTypes
 
SoundmUnderwaterSound
 
SoundmNearWaterSound
 
std::string mNextMusic
 

Friends

class OpenAL_Output
 

Additional Inherited Members

- Protected Types inherited from MWBase::SoundManager
using PlayMode = MWSound::PlayMode
 
using Type = MWSound::Type
 

Member Typedef Documentation

typedef std::unordered_map<std::string,Sound_Buffer*> MWSound::SoundManager::NameBufferMap
private
typedef std::unique_ptr<std::deque<Sound_Buffer> > MWSound::SoundManager::SoundBufferList
private
typedef std::deque<Sound_Buffer*> MWSound::SoundManager::SoundList
private
typedef std::vector<Stream*> MWSound::SoundManager::TrackList
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::advanceMusic ( const std::string &  filename)
private

Here is the call graph for this function:

Here is the caller graph for this function:

void MWSound::SoundManager::clear ( )
virtual

Implements MWBase::SoundManager.

Here is the call graph for this function:

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:

Sound * MWSound::SoundManager::getSoundRef ( )
private

Here is the caller graph for this function:

Stream * MWSound::SoundManager::getStreamRef ( )
private

Here is the caller graph for this function:

double MWSound::SoundManager::getTrackTimeDelay ( Stream 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.

Here is the caller graph for this function:

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

Here is the call graph for this function:

Here is the caller graph for this function:

DecoderPtr MWSound::SoundManager::loadVoice ( const std::string &  voicefile)
private

Here is the call graph for this function:

Here is the caller graph for this function:

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

Here is the caller graph for this function:

SoundManager& MWSound::SoundManager::operator= ( const SoundManager rhs)
private
void MWSound::SoundManager::pauseSounds ( int  types)
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.

Here is the call graph for this function:

Sound * MWSound::SoundManager::playSound ( const std::string &  soundId,
float  volume,
float  pitch,
Type  type = Type::Sfx,
PlayMode  mode = PlayMode::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:

Here is the caller graph for this function:

Sound * MWSound::SoundManager::playSound3D ( const MWWorld::ConstPtr reference,
const std::string &  soundId,
float  volume,
float  pitch,
Type  type = Type::Sfx,
PlayMode  mode = PlayMode::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:

Sound * MWSound::SoundManager::playSound3D ( const osg::Vec3f &  initialPos,
const std::string &  soundId,
float  volume,
float  pitch,
Type  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:

Stream * MWSound::SoundManager::playTrack ( const DecoderPtr decoder,
Type  type 
)
virtual

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

Implements MWBase::SoundManager.

Here is the call graph for this function:

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

Here is the call graph for this function:

Here is the caller 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)
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.

Here is the call graph for this function:

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 ( )
private

Here is the call graph for this function:

Here is the caller graph for this function:

void MWSound::SoundManager::stopMusic ( )
virtual

Stops music if it's playing.

Implements MWBase::SoundManager.

Here is the caller graph for this function:

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

Stop an actor speaking.

Implements MWBase::SoundManager.

Here is the caller graph for this function:

void MWSound::SoundManager::stopSound ( Sound_Buffer sfx,
const MWWorld::ConstPtr ptr 
)
protected

Stop the given object from playing given sound buffer.

Here is the caller graph for this function:

void MWSound::SoundManager::stopSound ( Sound 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 ( Stream 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.

Here is the call graph for this function:

void MWSound::SoundManager::streamMusicFull ( const std::string &  filename)
private

Here is the call graph for this function:

Here is the caller graph for this function:

void MWSound::SoundManager::update ( float  duration)
virtual

Implements MWBase::SoundManager.

Here is the call graph for this function:

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

Here is the call graph for this function:

Here is the caller 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:

Here is the caller graph for this function:

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Here is the caller graph for this function:

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
Stream* MWSound::SoundManager::mMusic
private
std::unordered_map<std::string, std::vector<std::string> > MWSound::SoundManager::mMusicFiles
private
std::unordered_map<std::string, std::vector<int> > MWSound::SoundManager::mMusicToPlay
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
Sound* MWSound::SoundManager::mNearWaterSound
private
std::string MWSound::SoundManager::mNextMusic
private
std::unique_ptr<Sound_Output> MWSound::SoundManager::mOutput
private
int MWSound::SoundManager::mPausedSoundTypes
private
float MWSound::SoundManager::mSFXVolume
private
SoundBufferList MWSound::SoundManager::mSoundBuffers
private
std::unique_ptr<std::deque<Sound> > MWSound::SoundManager::mSounds
private
std::unique_ptr<std::deque<Stream> > MWSound::SoundManager::mStreams
private
Sound* MWSound::SoundManager::mUnderwaterSound
private
SoundList MWSound::SoundManager::mUnusedBuffers
private
std::vector<Sound*> MWSound::SoundManager::mUnusedSounds
private
std::vector<Stream*> MWSound::SoundManager::mUnusedStreams
private
const VFS::Manager* MWSound::SoundManager::mVFS
private
float MWSound::SoundManager::mVoiceVolume
private

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