2010-07-03 13:04:00 +00:00
|
|
|
#ifndef GAME_SOUND_SOUNDMANAGER_H
|
|
|
|
#define GAME_SOUND_SOUNDMANAGER_H
|
|
|
|
|
|
|
|
#include <string>
|
2012-03-27 09:50:45 +00:00
|
|
|
#include <utility>
|
|
|
|
#include <map>
|
2010-07-03 13:04:00 +00:00
|
|
|
|
2012-03-20 17:34:36 +00:00
|
|
|
#include <OgreResourceGroupManager.h>
|
|
|
|
|
2012-05-24 02:34:53 +00:00
|
|
|
#include <components/settings/settings.hpp>
|
|
|
|
|
2012-03-05 23:21:00 +00:00
|
|
|
#include "../mwworld/ptr.hpp"
|
2011-10-09 07:28:36 +00:00
|
|
|
|
|
|
|
|
2010-08-12 14:13:54 +00:00
|
|
|
namespace Ogre
|
|
|
|
{
|
|
|
|
class Root;
|
|
|
|
class Camera;
|
|
|
|
}
|
|
|
|
|
2010-07-03 13:04:00 +00:00
|
|
|
namespace MWSound
|
|
|
|
{
|
2012-03-17 05:12:17 +00:00
|
|
|
class Sound_Output;
|
2012-03-26 22:36:53 +00:00
|
|
|
struct Sound_Decoder;
|
2012-03-17 09:45:18 +00:00
|
|
|
class Sound;
|
2012-03-17 05:12:17 +00:00
|
|
|
|
2012-03-18 06:30:43 +00:00
|
|
|
typedef boost::shared_ptr<Sound_Decoder> DecoderPtr;
|
2012-03-27 12:59:09 +00:00
|
|
|
typedef boost::shared_ptr<Sound> SoundPtr;
|
2012-03-18 06:30:43 +00:00
|
|
|
|
2012-03-31 14:31:55 +00:00
|
|
|
enum PlayMode {
|
|
|
|
Play_Normal = 0, /* tracked, non-looping, multi-instance, environment */
|
|
|
|
Play_Loop = 1<<0, /* Sound will continually loop until explicitly stopped */
|
|
|
|
Play_NoEnv = 1<<1, /* Do not apply environment effects (eg, underwater filters) */
|
|
|
|
Play_NoTrack = 1<<2, /* (3D only) Play the sound at the given object's position
|
|
|
|
* but do not keep it updated (the sound will not move with
|
|
|
|
* the object and will not stop when the object is deleted. */
|
|
|
|
};
|
|
|
|
static inline int operator|(const PlayMode &a, const PlayMode &b)
|
|
|
|
{ return (int)a | (int)b; }
|
|
|
|
static inline int operator&(const PlayMode &a, const PlayMode &b)
|
|
|
|
{ return (int)a & (int)b; }
|
|
|
|
|
2012-03-31 17:06:12 +00:00
|
|
|
enum Environment {
|
|
|
|
Env_Normal,
|
|
|
|
Env_Underwater,
|
|
|
|
};
|
|
|
|
|
2010-07-03 13:04:00 +00:00
|
|
|
class SoundManager
|
|
|
|
{
|
2012-03-24 07:22:54 +00:00
|
|
|
Ogre::ResourceGroupManager& mResourceMgr;
|
2012-03-17 05:12:17 +00:00
|
|
|
|
2012-03-18 18:17:45 +00:00
|
|
|
std::auto_ptr<Sound_Output> mOutput;
|
2012-03-17 05:12:17 +00:00
|
|
|
|
2012-04-07 23:00:30 +00:00
|
|
|
float mMasterVolume;
|
|
|
|
float mSFXVolume;
|
|
|
|
float mMusicVolume;
|
2012-05-24 02:34:53 +00:00
|
|
|
float mVoiceVolume;
|
|
|
|
|
|
|
|
// not implemented
|
|
|
|
float mFootstepsVolume;
|
2012-04-07 23:00:30 +00:00
|
|
|
|
2012-03-17 09:45:18 +00:00
|
|
|
boost::shared_ptr<Sound> mMusic;
|
2012-03-20 18:31:13 +00:00
|
|
|
std::string mCurrentPlaylist;
|
2012-03-17 09:45:18 +00:00
|
|
|
|
2012-03-27 09:50:45 +00:00
|
|
|
typedef std::pair<MWWorld::Ptr,std::string> PtrIDPair;
|
2012-03-28 10:48:51 +00:00
|
|
|
typedef std::map<SoundPtr,PtrIDPair> SoundMap;
|
2012-03-18 18:17:45 +00:00
|
|
|
SoundMap mActiveSounds;
|
2012-03-17 15:02:46 +00:00
|
|
|
|
2012-03-17 05:12:17 +00:00
|
|
|
std::string lookup(const std::string &soundId,
|
|
|
|
float &volume, float &min, float &max);
|
2012-03-20 19:39:49 +00:00
|
|
|
void streamMusicFull(const std::string& filename);
|
2012-03-17 05:12:17 +00:00
|
|
|
bool isPlaying(MWWorld::Ptr ptr, const std::string &id) const;
|
2012-03-22 02:21:36 +00:00
|
|
|
void updateSounds(float duration);
|
2012-03-17 13:18:59 +00:00
|
|
|
void updateRegionSound(float duration);
|
2012-03-17 05:12:17 +00:00
|
|
|
|
2012-03-24 10:49:03 +00:00
|
|
|
SoundManager(const SoundManager &rhs);
|
|
|
|
SoundManager& operator=(const SoundManager &rhs);
|
|
|
|
|
2012-03-18 06:30:43 +00:00
|
|
|
protected:
|
|
|
|
DecoderPtr getDecoder();
|
|
|
|
friend class OpenAL_Output;
|
|
|
|
|
2012-03-17 05:12:17 +00:00
|
|
|
public:
|
2012-04-23 13:27:03 +00:00
|
|
|
SoundManager(bool useSound);
|
2012-03-17 05:12:17 +00:00
|
|
|
~SoundManager();
|
2012-03-07 00:20:15 +00:00
|
|
|
|
2012-05-24 02:34:53 +00:00
|
|
|
void processChangedSettings(const Settings::CategorySettingVector& settings);
|
|
|
|
|
2012-03-17 05:12:17 +00:00
|
|
|
void stopMusic();
|
|
|
|
///< Stops music if it's playing
|
2012-03-07 15:46:51 +00:00
|
|
|
|
2012-03-17 05:12:17 +00:00
|
|
|
void streamMusic(const std::string& filename);
|
|
|
|
///< Play a soundifle
|
|
|
|
/// \param filename name of a sound file in "Music/" in the data directory.
|
2012-03-07 00:20:15 +00:00
|
|
|
|
2012-03-17 05:12:17 +00:00
|
|
|
void startRandomTitle();
|
|
|
|
///< Starts a random track from the current playlist
|
2012-03-05 23:21:00 +00:00
|
|
|
|
2012-03-17 05:12:17 +00:00
|
|
|
bool isMusicPlaying();
|
|
|
|
///< Returns true if music is playing
|
2011-06-12 00:01:21 +00:00
|
|
|
|
2012-03-20 18:31:13 +00:00
|
|
|
void playPlaylist(const std::string &playlist);
|
2012-03-17 05:12:17 +00:00
|
|
|
///< Start playing music from the selected folder
|
|
|
|
/// \param name of the folder that contains the playlist
|
2012-03-09 01:56:29 +00:00
|
|
|
|
2012-03-17 05:12:17 +00:00
|
|
|
void say(MWWorld::Ptr reference, const std::string& filename);
|
|
|
|
///< Make an actor say some text.
|
2012-05-02 03:30:31 +00:00
|
|
|
/// \param filename name of a sound file in "Sound/" in the data directory.
|
2011-06-15 20:33:31 +00:00
|
|
|
|
2012-05-02 03:30:31 +00:00
|
|
|
void say(const std::string& filename);
|
|
|
|
///< Say some text, without an actor ref
|
|
|
|
/// \param filename name of a sound file in "Sound/" in the data directory.
|
|
|
|
|
|
|
|
bool sayDone(MWWorld::Ptr reference=MWWorld::Ptr()) const;
|
2012-03-17 05:12:17 +00:00
|
|
|
///< Is actor not speaking?
|
2011-06-15 20:33:31 +00:00
|
|
|
|
2012-05-02 03:30:31 +00:00
|
|
|
void stopSay(MWWorld::Ptr reference=MWWorld::Ptr());
|
|
|
|
///< Stop an actor speaking
|
|
|
|
|
2012-03-31 14:31:55 +00:00
|
|
|
SoundPtr playSound(const std::string& soundId, float volume, float pitch, int mode=Play_Normal);
|
2012-03-17 05:12:17 +00:00
|
|
|
///< Play a sound, independently of 3D-position
|
2010-10-31 16:23:03 +00:00
|
|
|
|
2012-03-28 13:08:25 +00:00
|
|
|
SoundPtr playSound3D(MWWorld::Ptr reference, const std::string& soundId,
|
2012-03-31 14:31:55 +00:00
|
|
|
float volume, float pitch, int mode=Play_Normal);
|
2012-03-17 05:12:17 +00:00
|
|
|
///< Play a sound from an object
|
2012-03-07 15:46:51 +00:00
|
|
|
|
2012-03-27 10:20:50 +00:00
|
|
|
void stopSound3D(MWWorld::Ptr reference, const std::string& soundId);
|
|
|
|
///< Stop the given object from playing the given sound,
|
|
|
|
|
|
|
|
void stopSound3D(MWWorld::Ptr reference);
|
|
|
|
///< Stop the given object from playing all sounds.
|
2012-03-07 15:46:51 +00:00
|
|
|
|
2012-03-27 10:00:04 +00:00
|
|
|
void stopSound(const MWWorld::Ptr::CellStore *cell);
|
2012-03-17 05:12:17 +00:00
|
|
|
///< Stop all sounds for the given cell.
|
2010-08-14 05:54:51 +00:00
|
|
|
|
2012-03-17 05:12:17 +00:00
|
|
|
void stopSound(const std::string& soundId);
|
|
|
|
///< Stop a non-3d looping sound
|
2010-07-03 13:04:00 +00:00
|
|
|
|
2012-03-17 05:12:17 +00:00
|
|
|
bool getSoundPlaying(MWWorld::Ptr reference, const std::string& soundId) const;
|
|
|
|
///< Is the given sound currently playing on the given object?
|
2010-08-14 05:54:51 +00:00
|
|
|
|
2012-03-17 05:12:17 +00:00
|
|
|
void updateObject(MWWorld::Ptr reference);
|
|
|
|
///< Update the position of all sounds connected to the given object.
|
2010-07-03 13:04:00 +00:00
|
|
|
|
2012-03-17 05:12:17 +00:00
|
|
|
void update(float duration);
|
|
|
|
};
|
2010-07-03 13:04:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|