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-08-09 17:01:03 +04:00
|
|
|
#include <OgreVector3.h>
|
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-08-09 14:33:21 +02:00
|
|
|
#include "../mwbase/soundmanager.hpp"
|
2011-10-09 09:28:36 +02:00
|
|
|
|
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-31 10:06:12 -07:00
|
|
|
enum Environment {
|
|
|
|
Env_Normal,
|
2012-10-09 17:10:25 +02:00
|
|
|
Env_Underwater
|
2012-03-31 10:06:12 -07:00
|
|
|
};
|
|
|
|
|
2012-08-09 14:33:21 +02:00
|
|
|
class SoundManager : public MWBase::SoundManager
|
2010-07-03 15:04:00 +02:00
|
|
|
{
|
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;
|
|
|
|
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-08-09 14:33:21 +02:00
|
|
|
typedef std::map<MWBase::SoundPtr,PtrIDPair> SoundMap;
|
2012-03-18 11:17:45 -07:00
|
|
|
SoundMap mActiveSounds;
|
2012-03-17 08:02:46 -07:00
|
|
|
|
2013-08-27 13:48:20 -07:00
|
|
|
MWBase::SoundPtr mUnderwaterSound;
|
|
|
|
|
2012-08-09 17:01:03 +04:00
|
|
|
Ogre::Vector3 mListenerPos;
|
|
|
|
Ogre::Vector3 mListenerDir;
|
2012-09-30 17:23:05 -07:00
|
|
|
Ogre::Vector3 mListenerUp;
|
2012-08-09 17:01:03 +04:00
|
|
|
|
2012-12-18 04:35:24 -08:00
|
|
|
int mPausedSoundTypes;
|
|
|
|
|
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);
|
2013-01-15 12:07:15 -08:00
|
|
|
bool isPlaying(const 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-12-18 02:01:04 -08:00
|
|
|
float volumeFromType(PlayType type) const;
|
|
|
|
|
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-08-09 14:33:21 +02:00
|
|
|
virtual ~SoundManager();
|
2012-03-07 02:20:15 +02:00
|
|
|
|
2012-08-09 14:33:21 +02:00
|
|
|
virtual void processChangedSettings(const Settings::CategorySettingVector& settings);
|
2012-05-24 04:34:53 +02:00
|
|
|
|
2012-08-09 14:33:21 +02:00
|
|
|
virtual void stopMusic();
|
2012-03-16 22:12:17 -07:00
|
|
|
///< Stops music if it's playing
|
2012-03-07 17:46:51 +02:00
|
|
|
|
2012-08-09 14:33:21 +02:00
|
|
|
virtual void streamMusic(const std::string& filename);
|
2012-03-16 22:12:17 -07:00
|
|
|
///< 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-08-09 14:33:21 +02:00
|
|
|
virtual void startRandomTitle();
|
2012-03-16 22:12:17 -07:00
|
|
|
///< Starts a random track from the current playlist
|
2012-03-06 01:21:00 +02:00
|
|
|
|
2012-08-09 14:33:21 +02:00
|
|
|
virtual bool isMusicPlaying();
|
2012-03-16 22:12:17 -07:00
|
|
|
///< Returns true if music is playing
|
2011-06-11 20:01:21 -04:00
|
|
|
|
2012-08-09 14:33:21 +02:00
|
|
|
virtual 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
|
|
|
|
2013-01-15 12:07:15 -08:00
|
|
|
virtual void say(const MWWorld::Ptr &reference, const std::string& filename);
|
2012-03-16 22:12:17 -07:00
|
|
|
///< 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-08-09 14:33:21 +02:00
|
|
|
virtual void say(const std::string& filename);
|
2012-05-01 20:30:31 -07:00
|
|
|
///< Say some text, without an actor ref
|
|
|
|
/// \param filename name of a sound file in "Sound/" in the data directory.
|
|
|
|
|
2013-01-15 12:07:15 -08:00
|
|
|
virtual bool sayDone(const 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
|
|
|
|
2013-01-15 12:07:15 -08:00
|
|
|
virtual void stopSay(const MWWorld::Ptr &reference=MWWorld::Ptr());
|
2012-05-01 20:30:31 -07:00
|
|
|
///< Stop an actor speaking
|
|
|
|
|
2012-12-18 01:35:20 -08:00
|
|
|
virtual MWBase::SoundPtr playTrack(const DecoderPtr& decoder, PlayType type);
|
2012-12-13 00:05:57 -08:00
|
|
|
///< Play a 2D audio track, using a custom decoder
|
|
|
|
|
2013-07-26 18:43:06 +02:00
|
|
|
virtual MWBase::SoundPtr playSound(const std::string& soundId, float volume, float pitch, PlayType type=Play_TypeSfx, PlayMode mode=Play_Normal, float offset=0);
|
2012-03-16 22:12:17 -07:00
|
|
|
///< Play a sound, independently of 3D-position
|
2013-07-26 18:43:06 +02:00
|
|
|
///< @param offset value from [0,1], when to start playback. 0 is beginning, 1 is end.
|
2010-10-31 12:23:03 -04:00
|
|
|
|
2013-01-15 12:07:15 -08:00
|
|
|
virtual MWBase::SoundPtr playSound3D(const MWWorld::Ptr &reference, const std::string& soundId,
|
2013-07-18 19:01:13 -07:00
|
|
|
float volume, float pitch, PlayType type=Play_TypeSfx,
|
2013-07-26 18:43:06 +02:00
|
|
|
PlayMode mode=Play_Normal, float offset=0);
|
2012-03-16 22:12:17 -07:00
|
|
|
///< Play a sound from an object
|
2013-07-26 18:43:06 +02:00
|
|
|
///< @param offset value from [0,1], when to start playback. 0 is beginning, 1 is end.
|
2012-03-07 17:46:51 +02:00
|
|
|
|
2013-01-15 12:07:15 -08:00
|
|
|
virtual void stopSound3D(const MWWorld::Ptr &reference, const std::string& soundId);
|
2012-03-27 03:20:50 -07:00
|
|
|
///< Stop the given object from playing the given sound,
|
|
|
|
|
2013-01-15 12:07:15 -08:00
|
|
|
virtual void stopSound3D(const MWWorld::Ptr &reference);
|
2012-03-27 03:20:50 -07:00
|
|
|
///< Stop the given object from playing all sounds.
|
2012-03-07 17:46:51 +02:00
|
|
|
|
2012-08-09 14:33:21 +02:00
|
|
|
virtual 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-08-09 14:33:21 +02:00
|
|
|
virtual void stopSound(const std::string& soundId);
|
2012-03-16 22:12:17 -07:00
|
|
|
///< Stop a non-3d looping sound
|
2010-07-03 15:04:00 +02:00
|
|
|
|
2013-07-26 18:43:06 +02:00
|
|
|
virtual void fadeOutSound3D(const MWWorld::Ptr &reference, const std::string& soundId, float duration);
|
|
|
|
///< Fade out given sound (that is already playing) of given object
|
|
|
|
///< @param reference Reference to object, whose sound is faded out
|
|
|
|
///< @param soundId ID of the sound to fade out.
|
|
|
|
///< @param duration Time until volume reaches 0.
|
|
|
|
|
2013-01-15 12:07:15 -08:00
|
|
|
virtual bool getSoundPlaying(const MWWorld::Ptr &reference, const std::string& soundId) const;
|
2012-03-16 22:12:17 -07:00
|
|
|
///< Is the given sound currently playing on the given object?
|
2010-08-14 07:54:51 +02:00
|
|
|
|
2012-12-18 04:19:35 -08:00
|
|
|
virtual void pauseSounds(int types=Play_TypeMask);
|
2012-12-12 02:33:12 -08:00
|
|
|
///< Pauses all currently playing sounds, including music.
|
|
|
|
|
2012-12-18 04:19:35 -08:00
|
|
|
virtual void resumeSounds(int types=Play_TypeMask);
|
2012-12-12 02:33:12 -08:00
|
|
|
///< Resumes all previously paused sounds.
|
|
|
|
|
2012-08-09 14:33:21 +02:00
|
|
|
virtual void update(float duration);
|
2012-08-09 17:01:03 +04:00
|
|
|
|
2012-09-30 17:23:05 -07:00
|
|
|
virtual void setListenerPosDir(const Ogre::Vector3 &pos, const Ogre::Vector3 &dir, const Ogre::Vector3 &up);
|
2012-03-16 22:12:17 -07:00
|
|
|
};
|
2010-07-03 15:04:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|