OpenMW
apps/openmw/mwbase/soundmanager.hpp
Go to the documentation of this file.
00001 #ifndef GAME_MWBASE_SOUNDMANAGER_H
00002 #define GAME_MWBASE_SOUNDMANAGER_H
00003 
00004 #include <string>
00005 
00006 #include <boost/shared_ptr.hpp>
00007 
00008 #include <components/settings/settings.hpp>
00009 
00010 #include "../mwworld/ptr.hpp"
00011 
00012 namespace Ogre
00013 {
00014     class Vector3;
00015 }
00016 
00017 namespace MWWorld
00018 {
00019     class CellStore;
00020 }
00021 
00022 namespace MWSound
00023 {
00024     class Sound;
00025     class Sound_Decoder;
00026     typedef boost::shared_ptr<Sound_Decoder> DecoderPtr;
00027 }
00028 
00029 namespace MWBase
00030 {
00031     typedef boost::shared_ptr<MWSound::Sound> SoundPtr;
00032 
00034     class SoundManager
00035     {
00036         public:
00037             /* These must all fit together */
00038             enum PlayMode {
00039                 Play_Normal  = 0, /* tracked, non-looping, multi-instance, environment */
00040                 Play_Loop    = 1<<0, /* Sound will continually loop until explicitly stopped */
00041                 Play_NoEnv   = 1<<1, /* Do not apply environment effects (eg, underwater filters) */
00042                 Play_NoTrack = 1<<2, /* (3D only) Play the sound at the given object's position
00043                                       * but do not keep it updated (the sound will not move with
00044                                       * the object and will not stop when the object is deleted. */
00045 
00046                 Play_LoopNoEnv = Play_Loop | Play_NoEnv
00047             };
00048             enum PlayType {
00049                 Play_TypeSfx   = 1<<3, /* Normal SFX sound */
00050                 Play_TypeVoice = 1<<4, /* Voice sound */
00051                 Play_TypeFoot  = 1<<5, /* Footstep sound */
00052                 Play_TypeMusic = 1<<6, /* Music track */
00053                 Play_TypeMovie = 1<<7, /* Movie audio track */
00054                 Play_TypeMask  = Play_TypeSfx|Play_TypeVoice|Play_TypeFoot|Play_TypeMusic|Play_TypeMovie
00055             };
00056 
00057         private:
00058 
00059             SoundManager (const SoundManager&);
00061 
00062             SoundManager& operator= (const SoundManager&);
00064 
00065         public:
00066 
00067             SoundManager() {}
00068 
00069             virtual ~SoundManager() {}
00070 
00071             virtual void processChangedSettings(const Settings::CategorySettingVector& settings) = 0;
00072 
00073             virtual void stopMusic() = 0;
00075 
00076             virtual void streamMusic(const std::string& filename) = 0;
00079 
00080             virtual void startRandomTitle() = 0;
00082 
00083             virtual bool isMusicPlaying() = 0;
00085 
00086             virtual void playPlaylist(const std::string &playlist) = 0;
00089 
00090             virtual void say(const MWWorld::Ptr &reference, const std::string& filename) = 0;
00093 
00094             virtual void say(const std::string& filename) = 0;
00097 
00098             virtual bool sayDone(const MWWorld::Ptr &reference=MWWorld::Ptr()) const = 0;
00100 
00101             virtual void stopSay(const MWWorld::Ptr &reference=MWWorld::Ptr()) = 0;
00103 
00104             virtual SoundPtr playTrack(const MWSound::DecoderPtr& decoder, PlayType type) = 0;
00106 
00107             virtual SoundPtr playSound(const std::string& soundId, float volume, float pitch,
00108                                        PlayType type=Play_TypeSfx, PlayMode mode=Play_Normal,
00109                                        float offset=0) = 0;
00112 
00113             virtual SoundPtr playSound3D(const MWWorld::Ptr &reference, const std::string& soundId,
00114                                          float volume, float pitch, PlayType type=Play_TypeSfx,
00115                                          PlayMode mode=Play_Normal, float offset=0) = 0;
00118 
00119             virtual void stopSound3D(const MWWorld::Ptr &reference, const std::string& soundId) = 0;
00121 
00122             virtual void stopSound3D(const MWWorld::Ptr &reference) = 0;
00124 
00125             virtual void stopSound(const MWWorld::CellStore *cell) = 0;
00127 
00128             virtual void stopSound(const std::string& soundId) = 0;
00130 
00131             virtual void fadeOutSound3D(const MWWorld::Ptr &reference, const std::string& soundId, float duration) = 0;
00136 
00137             virtual bool getSoundPlaying(const MWWorld::Ptr &reference, const std::string& soundId) const = 0;
00140 
00141             virtual void pauseSounds(int types=Play_TypeMask) = 0;
00143 
00144             virtual void resumeSounds(int types=Play_TypeMask) = 0;
00146 
00147             virtual void update(float duration) = 0;
00148 
00149             virtual void setListenerPosDir(const Ogre::Vector3 &pos, const Ogre::Vector3 &dir, const Ogre::Vector3 &up) = 0;
00150     };
00151 }
00152 
00153 #endif