2010-07-03 13:04:00 +00:00
|
|
|
#ifndef GAME_SOUND_SOUNDMANAGER_H
|
|
|
|
#define GAME_SOUND_SOUNDMANAGER_H
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
2012-03-20 17:34:36 +00:00
|
|
|
#include <OgreResourceGroupManager.h>
|
|
|
|
|
2012-03-07 15:46:51 +00:00
|
|
|
#include <components/files/filelibrary.hpp>
|
2010-07-03 15:59:30 +00:00
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2011-10-09 07:28:36 +00:00
|
|
|
namespace MWWorld
|
|
|
|
{
|
|
|
|
struct Environment;
|
|
|
|
}
|
|
|
|
|
2010-07-03 13:04:00 +00:00
|
|
|
namespace MWSound
|
|
|
|
{
|
2012-03-17 05:12:17 +00:00
|
|
|
class Sound_Output;
|
2012-03-17 06:18:15 +00:00
|
|
|
class 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;
|
|
|
|
|
2010-07-03 13:04:00 +00:00
|
|
|
class SoundManager
|
|
|
|
{
|
2012-03-20 17:34:36 +00:00
|
|
|
Ogre::ResourceGroupManager *mResourceMgr;
|
|
|
|
|
2012-03-17 05:12:17 +00:00
|
|
|
// This is used for case insensitive and slash-type agnostic file
|
|
|
|
// finding. It takes DOS paths (any case, \\ slashes or / slashes)
|
|
|
|
// relative to the sound dir, and translates them into full paths
|
|
|
|
// of existing files in the filesystem, if they exist.
|
|
|
|
bool mFSStrict;
|
|
|
|
|
|
|
|
MWWorld::Environment& mEnvironment;
|
|
|
|
|
2012-03-18 18:17:45 +00:00
|
|
|
std::auto_ptr<Sound_Output> mOutput;
|
2012-03-17 05:12:17 +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-17 15:02:46 +00:00
|
|
|
typedef boost::shared_ptr<Sound> SoundPtr;
|
|
|
|
typedef std::map<std::string,SoundPtr> IDMap;
|
|
|
|
typedef std::map<MWWorld::Ptr,IDMap> SoundMap;
|
2012-03-18 18:17:45 +00:00
|
|
|
SoundMap mActiveSounds;
|
|
|
|
IDMap mLooseSounds;
|
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-17 15:02:46 +00:00
|
|
|
void play3d(const std::string &file,
|
2012-03-17 05:12:17 +00:00
|
|
|
MWWorld::Ptr ptr, const std::string &id,
|
|
|
|
float volume, float pitch, float min, float max,
|
|
|
|
bool loop, bool untracked=false);
|
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-17 13:18:59 +00:00
|
|
|
void updateRegionSound(float duration);
|
2012-03-17 05:12:17 +00:00
|
|
|
|
2012-03-18 06:30:43 +00:00
|
|
|
protected:
|
|
|
|
DecoderPtr getDecoder();
|
|
|
|
friend class OpenAL_Output;
|
|
|
|
|
2012-03-17 05:12:17 +00:00
|
|
|
public:
|
|
|
|
SoundManager(Ogre::Root*, Ogre::Camera*,
|
|
|
|
const Files::PathContainer& dataDir, bool useSound, bool fsstrict,
|
|
|
|
MWWorld::Environment& environment);
|
|
|
|
~SoundManager();
|
2012-03-07 00:20:15 +00:00
|
|
|
|
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.
|
|
|
|
/// \param filename name of a sound file in "Sound/Vo/" in the data directory.
|
2011-06-15 20:33:31 +00:00
|
|
|
|
2012-03-17 05:12:17 +00:00
|
|
|
bool sayDone(MWWorld::Ptr reference) const;
|
|
|
|
///< Is actor not speaking?
|
2011-06-15 20:33:31 +00:00
|
|
|
|
2012-03-17 05:12:17 +00:00
|
|
|
void playSound(const std::string& soundId, float volume, float pitch, bool loop=false);
|
|
|
|
///< Play a sound, independently of 3D-position
|
2010-10-31 16:23:03 +00:00
|
|
|
|
2012-03-17 05:12:17 +00:00
|
|
|
void playSound3D(MWWorld::Ptr reference, const std::string& soundId,
|
|
|
|
float volume, float pitch, bool loop,
|
|
|
|
bool untracked=false);
|
|
|
|
///< Play a sound from an object
|
2012-03-07 15:46:51 +00:00
|
|
|
|
2012-03-17 05:12:17 +00:00
|
|
|
void stopSound3D(MWWorld::Ptr reference, const std::string& soundId="");
|
|
|
|
///< Stop the given object from playing the given sound, If no soundId is given,
|
|
|
|
/// all sounds for this reference will stop.
|
2012-03-07 15:46:51 +00:00
|
|
|
|
2012-03-17 05:12:17 +00:00
|
|
|
void stopSound(MWWorld::Ptr::CellStore *cell);
|
|
|
|
///< 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
|