OpenMW
|
00001 #ifndef GAME_SOUND_SOUNDMANAGER_H 00002 #define GAME_SOUND_SOUNDMANAGER_H 00003 00004 #include <string> 00005 #include <utility> 00006 #include <map> 00007 00008 #include <boost/shared_ptr.hpp> 00009 00010 #include <OgreVector3.h> 00011 #include <OgreResourceGroupManager.h> 00012 00013 #include <components/settings/settings.hpp> 00014 00015 #include "../mwbase/soundmanager.hpp" 00016 00017 namespace MWSound 00018 { 00019 class Sound_Output; 00020 struct Sound_Decoder; 00021 class Sound; 00022 00023 enum Environment { 00024 Env_Normal, 00025 Env_Underwater 00026 }; 00027 00028 class SoundManager : public MWBase::SoundManager 00029 { 00030 Ogre::ResourceGroupManager& mResourceMgr; 00031 00032 std::auto_ptr<Sound_Output> mOutput; 00033 00034 float mMasterVolume; 00035 float mSFXVolume; 00036 float mMusicVolume; 00037 float mVoiceVolume; 00038 float mFootstepsVolume; 00039 00040 boost::shared_ptr<Sound> mMusic; 00041 std::string mCurrentPlaylist; 00042 00043 typedef std::pair<MWWorld::Ptr,std::string> PtrIDPair; 00044 typedef std::map<MWBase::SoundPtr,PtrIDPair> SoundMap; 00045 SoundMap mActiveSounds; 00046 00047 MWBase::SoundPtr mUnderwaterSound; 00048 00049 Ogre::Vector3 mListenerPos; 00050 Ogre::Vector3 mListenerDir; 00051 Ogre::Vector3 mListenerUp; 00052 00053 int mPausedSoundTypes; 00054 00055 std::string lookup(const std::string &soundId, 00056 float &volume, float &min, float &max); 00057 void streamMusicFull(const std::string& filename); 00058 bool isPlaying(const MWWorld::Ptr &ptr, const std::string &id) const; 00059 void updateSounds(float duration); 00060 void updateRegionSound(float duration); 00061 00062 float volumeFromType(PlayType type) const; 00063 00064 SoundManager(const SoundManager &rhs); 00065 SoundManager& operator=(const SoundManager &rhs); 00066 00067 protected: 00068 DecoderPtr getDecoder(); 00069 friend class OpenAL_Output; 00070 00071 public: 00072 SoundManager(bool useSound); 00073 virtual ~SoundManager(); 00074 00075 virtual void processChangedSettings(const Settings::CategorySettingVector& settings); 00076 00077 virtual void stopMusic(); 00079 00080 virtual void streamMusic(const std::string& filename); 00083 00084 virtual void startRandomTitle(); 00086 00087 virtual bool isMusicPlaying(); 00089 00090 virtual void playPlaylist(const std::string &playlist); 00093 00094 virtual void say(const MWWorld::Ptr &reference, const std::string& filename); 00097 00098 virtual void say(const std::string& filename); 00101 00102 virtual bool sayDone(const MWWorld::Ptr &reference=MWWorld::Ptr()) const; 00104 00105 virtual void stopSay(const MWWorld::Ptr &reference=MWWorld::Ptr()); 00107 00108 virtual MWBase::SoundPtr playTrack(const DecoderPtr& decoder, PlayType type); 00110 00111 virtual MWBase::SoundPtr playSound(const std::string& soundId, float volume, float pitch, PlayType type=Play_TypeSfx, PlayMode mode=Play_Normal, float offset=0); 00114 00115 virtual MWBase::SoundPtr playSound3D(const MWWorld::Ptr &reference, const std::string& soundId, 00116 float volume, float pitch, PlayType type=Play_TypeSfx, 00117 PlayMode mode=Play_Normal, float offset=0); 00120 00121 virtual void stopSound3D(const MWWorld::Ptr &reference, const std::string& soundId); 00123 00124 virtual void stopSound3D(const MWWorld::Ptr &reference); 00126 00127 virtual void stopSound(const MWWorld::CellStore *cell); 00129 00130 virtual void stopSound(const std::string& soundId); 00132 00133 virtual void fadeOutSound3D(const MWWorld::Ptr &reference, const std::string& soundId, float duration); 00138 00139 virtual bool getSoundPlaying(const MWWorld::Ptr &reference, const std::string& soundId) const; 00141 00142 virtual void pauseSounds(int types=Play_TypeMask); 00144 00145 virtual void resumeSounds(int types=Play_TypeMask); 00147 00148 virtual void update(float duration); 00149 00150 virtual void setListenerPosDir(const Ogre::Vector3 &pos, const Ogre::Vector3 &dir, const Ogre::Vector3 &up); 00151 }; 00152 } 00153 00154 #endif