OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
soundmanager.hpp
Go to the documentation of this file.
1 #ifndef GAME_MWBASE_SOUNDMANAGER_H
2 #define GAME_MWBASE_SOUNDMANAGER_H
3 
4 #include <string>
5 #include <set>
6 #include <boost/shared_ptr.hpp>
7 
8 #include "../mwworld/ptr.hpp"
9 
10 namespace MWWorld
11 {
12  class CellStore;
13 }
14 
15 namespace MWSound
16 {
17  class Sound;
18  class Stream;
19  struct Sound_Decoder;
20  typedef boost::shared_ptr<Sound_Decoder> DecoderPtr;
21 }
22 
23 namespace MWBase
24 {
25  typedef boost::shared_ptr<MWSound::Sound> SoundPtr;
26  typedef boost::shared_ptr<MWSound::Stream> SoundStreamPtr;
27 
30  {
31  public:
32  /* These must all fit together */
33  enum PlayMode {
34  Play_Normal = 0, /* non-looping, affected by environment */
35  Play_Loop = 1<<0, /* Sound will continually loop until explicitly stopped */
36  Play_NoEnv = 1<<1, /* Do not apply environment effects (eg, underwater filters) */
37  Play_RemoveAtDistance = 1<<2, /* (3D only) If the listener gets further than 2000 units away
38  from the sound source, the sound is removed.
39  This is weird stuff but apparently how vanilla works for sounds
40  played by the PlayLoopSound family of script functions. Perhaps we
41  can make this cut off a more subtle fade later, but have to
42  be careful to not change the overall volume of areas by too much. */
43  Play_NoPlayerLocal = 1<<3, /* (3D only) Don't play the sound local to the listener even if the
44  player is making it. */
47  };
48  enum PlayType {
49  Play_TypeSfx = 1<<4, /* Normal SFX sound */
50  Play_TypeVoice = 1<<5, /* Voice sound */
51  Play_TypeFoot = 1<<6, /* Footstep sound */
52  Play_TypeMusic = 1<<7, /* Music track */
53  Play_TypeMovie = 1<<8, /* Movie audio track */
55  };
56 
57  private:
58 
59  SoundManager (const SoundManager&);
61 
64 
65  public:
66 
68 
69  virtual ~SoundManager() {}
70 
71  virtual void processChangedSettings(const std::set< std::pair<std::string, std::string> >& settings) = 0;
72 
73  virtual void stopMusic() = 0;
75 
76  virtual void streamMusic(const std::string& filename) = 0;
79 
80  virtual void startRandomTitle() = 0;
82 
83  virtual bool isMusicPlaying() = 0;
85 
86  virtual void playPlaylist(const std::string &playlist) = 0;
89 
90  virtual void say(const MWWorld::ConstPtr &reference, const std::string& filename) = 0;
93 
94  virtual void say(const std::string& filename) = 0;
97 
98  virtual bool sayDone(const MWWorld::ConstPtr &reference=MWWorld::ConstPtr()) const = 0;
100 
101  virtual void stopSay(const MWWorld::ConstPtr &reference=MWWorld::ConstPtr()) = 0;
103 
104  virtual float getSaySoundLoudness(const MWWorld::ConstPtr& reference) const = 0;
108 
109  virtual SoundStreamPtr playTrack(const MWSound::DecoderPtr& decoder, PlayType type) = 0;
111 
112  virtual void stopTrack(SoundStreamPtr stream) = 0;
114 
115  virtual double getTrackTimeDelay(SoundStreamPtr stream) = 0;
119 
120  virtual SoundPtr playSound(const std::string& soundId, float volume, float pitch,
122  float offset=0) = 0;
125 
126  virtual MWBase::SoundPtr playSound3D(const MWWorld::ConstPtr &reference, const std::string& soundId,
127  float volume, float pitch, PlayType type=Play_TypeSfx,
128  PlayMode mode=Play_Normal, float offset=0) = 0;
131 
132  virtual MWBase::SoundPtr playSound3D(const osg::Vec3f& initialPos, const std::string& soundId,
133  float volume, float pitch, PlayType type=Play_TypeSfx, PlayMode mode=Play_Normal, float offset=0) = 0;
135 
136  virtual void stopSound(SoundPtr sound) = 0;
138 
139  virtual void stopSound3D(const MWWorld::ConstPtr &reference, const std::string& soundId) = 0;
141 
142  virtual void stopSound3D(const MWWorld::ConstPtr &reference) = 0;
144 
145  virtual void stopSound(const MWWorld::CellStore *cell) = 0;
147 
148  virtual void stopSound(const std::string& soundId) = 0;
150 
151  virtual void fadeOutSound3D(const MWWorld::ConstPtr &reference, const std::string& soundId, float duration) = 0;
156 
157  virtual bool getSoundPlaying(const MWWorld::ConstPtr &reference, const std::string& soundId) const = 0;
160 
161  virtual void pauseSounds(int types=Play_TypeMask) = 0;
163 
164  virtual void resumeSounds(int types=Play_TypeMask) = 0;
166 
167  virtual void update(float duration) = 0;
168 
169  virtual void setListenerPosDir(const osg::Vec3f &pos, const osg::Vec3f &dir, const osg::Vec3f &up, bool underwater) = 0;
170 
171  virtual void updatePtr(const MWWorld::ConstPtr& old, const MWWorld::ConstPtr& updated) = 0;
172 
173  virtual void clear() = 0;
174  };
175 }
176 
177 #endif
virtual void playPlaylist(const std::string &playlist)=0
virtual void stopTrack(SoundStreamPtr stream)=0
Stop the given audio track from playing.
virtual void stopSound(SoundPtr sound)=0
Stop the given sound from playing.
Definition: soundmanager.hpp:50
SoundManager & operator=(const SoundManager &)
not implemented
virtual SoundStreamPtr playTrack(const MWSound::DecoderPtr &decoder, PlayType type)=0
Play a 2D audio track, using a custom decoder.
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)=0
virtual void setListenerPosDir(const osg::Vec3f &pos, const osg::Vec3f &dir, const osg::Vec3f &up, bool underwater)=0
Definition: soundmanager.hpp:54
Definition: soundmanager.hpp:49
Definition: soundmanager.hpp:45
Definition: soundmanager.hpp:43
virtual void stopMusic()=0
Stops music if it's playing.
virtual bool sayDone(const MWWorld::ConstPtr &reference=MWWorld::ConstPtr()) const =0
Is actor not speaking?
PlayType
Definition: soundmanager.hpp:48
Definition: soundmanager.hpp:51
virtual SoundPtr playSound(const std::string &soundId, float volume, float pitch, PlayType type=Play_TypeSfx, PlayMode mode=Play_Normal, float offset=0)=0
Definition: soundmanager.hpp:34
virtual void startRandomTitle()=0
Starts a random track from the current playlist.
virtual void streamMusic(const std::string &filename)=0
virtual void say(const MWWorld::ConstPtr &reference, const std::string &filename)=0
Definition: soundmanager.hpp:35
virtual void updatePtr(const MWWorld::ConstPtr &old, const MWWorld::ConstPtr &updated)=0
virtual bool isMusicPlaying()=0
Returns true if music is playing.
Definition: soundmanager.hpp:53
boost::shared_ptr< Sound_Decoder > DecoderPtr
Definition: soundmanager.hpp:19
boost::shared_ptr< MWSound::Stream > SoundStreamPtr
Definition: soundmanager.hpp:26
virtual void update(float duration)=0
virtual void clear()=0
Mutable state of a cell.
Definition: cellstore.hpp:53
virtual void processChangedSettings(const std::set< std::pair< std::string, std::string > > &settings)=0
Pointer to a const LiveCellRef.
Definition: ptr.hpp:90
virtual float getSaySoundLoudness(const MWWorld::ConstPtr &reference) const =0
Definition: soundmanager.hpp:52
virtual bool getSoundPlaying(const MWWorld::ConstPtr &reference, const std::string &soundId) const =0
virtual void pauseSounds(int types=Play_TypeMask)=0
Pauses all currently playing sounds, including music.
PlayMode
Definition: soundmanager.hpp:33
virtual double getTrackTimeDelay(SoundStreamPtr stream)=0
Interface for sound manager (implemented in MWSound)
Definition: soundmanager.hpp:29
virtual void fadeOutSound3D(const MWWorld::ConstPtr &reference, const std::string &soundId, float duration)=0
virtual ~SoundManager()
Definition: soundmanager.hpp:69
virtual void stopSound3D(const MWWorld::ConstPtr &reference, const std::string &soundId)=0
Stop the given object from playing the given sound,.
Definition: soundmanager.hpp:37
virtual void stopSay(const MWWorld::ConstPtr &reference=MWWorld::ConstPtr())=0
Stop an actor speaking.
SoundManager()
Definition: soundmanager.hpp:67
Definition: soundmanager.hpp:36
Definition: sound_decoder.hpp:33
boost::shared_ptr< MWSound::Sound > SoundPtr
Definition: soundmanager.hpp:25
virtual void resumeSounds(int types=Play_TypeMask)=0
Resumes all previously paused sounds.