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