2010-07-03 13:04:00 +00:00
|
|
|
#ifndef GAME_SOUND_SOUNDMANAGER_H
|
|
|
|
#define GAME_SOUND_SOUNDMANAGER_H
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
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
|
|
|
|
{
|
|
|
|
class SoundManager
|
|
|
|
{
|
2012-03-07 00:20:15 +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;
|
|
|
|
|
2011-10-09 07:28:36 +00:00
|
|
|
MWWorld::Environment& mEnvironment;
|
|
|
|
|
2011-06-15 20:33:31 +00:00
|
|
|
void streamMusicFull (const std::string& filename);
|
2011-06-12 20:36:18 +00:00
|
|
|
///< Play a soundifle
|
2011-06-15 17:09:47 +00:00
|
|
|
/// \param absolute filename
|
2011-06-15 20:33:31 +00:00
|
|
|
|
2012-03-09 01:22:16 +00:00
|
|
|
// A list of all sound files used to lookup paths
|
2012-03-07 00:20:15 +00:00
|
|
|
Files::PathContainer mSoundFiles;
|
|
|
|
|
2012-03-09 01:22:16 +00:00
|
|
|
// A library of all Music file paths stored by the folder they are contained in
|
2012-03-07 15:46:51 +00:00
|
|
|
Files::FileLibrary mMusicLibrary;
|
|
|
|
|
2012-03-09 01:22:16 +00:00
|
|
|
// Points to the current playlist of music files stored in the music library
|
2012-03-07 15:46:51 +00:00
|
|
|
const Files::PathContainer* mCurrentPlaylist;
|
2012-03-07 00:20:15 +00:00
|
|
|
|
2012-03-05 23:21:00 +00:00
|
|
|
std::string lookup(const std::string &soundId,
|
|
|
|
float &volume, float &min, float &max);
|
|
|
|
void add(const std::string &file,
|
|
|
|
MWWorld::Ptr ptr, const std::string &id,
|
|
|
|
float volume, float pitch, float min, float max,
|
2012-03-13 16:05:38 +00:00
|
|
|
bool loop, bool untracked=false);
|
2012-03-05 23:21:00 +00:00
|
|
|
void remove(MWWorld::Ptr ptr, const std::string &id = "");
|
|
|
|
bool isPlaying(MWWorld::Ptr ptr, const std::string &id) const;
|
|
|
|
void removeCell(const MWWorld::Ptr::CellStore *cell);
|
|
|
|
void updatePositions(MWWorld::Ptr ptr);
|
|
|
|
|
2010-07-03 13:04:00 +00:00
|
|
|
public:
|
2011-06-12 00:01:21 +00:00
|
|
|
|
2012-03-05 23:21:00 +00:00
|
|
|
SoundManager(Ogre::Root*, Ogre::Camera*,
|
2012-01-29 19:27:03 +00:00
|
|
|
const Files::PathContainer& dataDir, bool useSound, bool fsstrict,
|
2011-10-09 07:28:36 +00:00
|
|
|
MWWorld::Environment& environment);
|
2010-08-12 14:13:54 +00:00
|
|
|
~SoundManager();
|
2010-11-12 00:47:26 +00:00
|
|
|
|
2012-03-09 01:56:29 +00:00
|
|
|
void stopMusic();
|
|
|
|
///< Stops music if it's playing
|
|
|
|
|
2011-06-15 20:33:31 +00:00
|
|
|
void streamMusic(const std::string& filename);
|
|
|
|
///< Play a soundifle
|
2011-06-15 17:09:47 +00:00
|
|
|
/// \param filename name of a sound file in "Music/" in the data directory.
|
2011-06-15 20:33:31 +00:00
|
|
|
|
2011-01-05 21:18:21 +00:00
|
|
|
void startRandomTitle();
|
2012-03-09 01:22:16 +00:00
|
|
|
///< Starts a random track from the current playlist
|
2011-06-15 20:33:31 +00:00
|
|
|
|
2011-01-05 21:18:21 +00:00
|
|
|
bool isMusicPlaying();
|
2012-03-09 01:22:16 +00:00
|
|
|
///< Returns true if music is playing
|
2010-10-31 16:23:03 +00:00
|
|
|
|
2012-03-07 15:46:51 +00:00
|
|
|
bool setPlaylist(std::string playlist="");
|
|
|
|
///< Set the playlist to an existing folder
|
|
|
|
/// \param name of the folder that contains the playlist
|
|
|
|
/// if none is set then it is set to an empty playlist
|
|
|
|
/// \return Return true if the previous playlist was the same
|
|
|
|
|
|
|
|
void playPlaylist(std::string playlist="");
|
|
|
|
///< Start playing music from the selected folder
|
|
|
|
/// \param name of the folder that contains the playlist
|
|
|
|
/// if none is set then it plays from the current playlist
|
|
|
|
|
2010-08-12 15:58:29 +00:00
|
|
|
void say (MWWorld::Ptr reference, const std::string& filename);
|
2010-07-03 13:04:00 +00:00
|
|
|
///< Make an actor say some text.
|
|
|
|
/// \param filename name of a sound file in "Sound/Vo/" in the data directory.
|
2010-08-14 05:54:51 +00:00
|
|
|
|
2010-08-12 14:29:22 +00:00
|
|
|
bool sayDone (MWWorld::Ptr reference) const;
|
2010-07-03 13:04:00 +00:00
|
|
|
///< Is actor not speaking?
|
|
|
|
|
2012-03-09 16:10:23 +00:00
|
|
|
void playSound (const std::string& soundId, float volume, float pitch, bool loop=false);
|
2010-07-03 13:04:00 +00:00
|
|
|
///< Play a sound, independently of 3D-position
|
2010-08-14 05:54:51 +00:00
|
|
|
|
2010-07-03 15:59:30 +00:00
|
|
|
void playSound3D (MWWorld::Ptr reference, const std::string& soundId,
|
2012-03-13 16:05:38 +00:00
|
|
|
float volume, float pitch, bool loop, bool untracked=false);
|
2010-07-03 13:04:00 +00:00
|
|
|
///< Play a sound from an object
|
|
|
|
|
2010-08-14 05:54:51 +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.
|
2010-07-03 13:04:00 +00:00
|
|
|
|
2010-08-14 07:26:00 +00:00
|
|
|
void stopSound (MWWorld::Ptr::CellStore *cell);
|
|
|
|
///< Stop all sounds for the given cell.
|
|
|
|
|
2012-03-09 16:10:23 +00:00
|
|
|
void stopSound(const std::string& soundId);
|
|
|
|
///< Stop a non-3d looping sound
|
|
|
|
|
2010-08-12 14:29:22 +00:00
|
|
|
bool getSoundPlaying (MWWorld::Ptr reference, const std::string& soundId) const;
|
2010-07-03 13:04:00 +00:00
|
|
|
///< Is the given sound currently playing on the given object?
|
2010-08-14 12:28:17 +00:00
|
|
|
|
|
|
|
void updateObject(MWWorld::Ptr reference);
|
|
|
|
///< Update the position of all sounds connected to the given object.
|
2011-10-09 07:28:36 +00:00
|
|
|
|
|
|
|
void update (float duration);
|
2010-07-03 13:04:00 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|