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