|
|
|
@ -21,103 +21,122 @@ namespace MWWorld
|
|
|
|
|
|
|
|
|
|
namespace MWSound
|
|
|
|
|
{
|
|
|
|
|
class Sound_Output;
|
|
|
|
|
|
|
|
|
|
class SoundManager
|
|
|
|
|
{
|
|
|
|
|
// 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;
|
|
|
|
|
|
|
|
|
|
std::auto_ptr<Sound_Output> Output;
|
|
|
|
|
|
|
|
|
|
void streamMusicFull(const std::string& filename);
|
|
|
|
|
///< Play a soundifle
|
|
|
|
|
/// \param absolute filename
|
|
|
|
|
|
|
|
|
|
// A list of all sound files used to lookup paths
|
|
|
|
|
Files::PathContainer mSoundFiles;
|
|
|
|
|
|
|
|
|
|
// A library of all Music file paths stored by the folder they are contained in
|
|
|
|
|
Files::FileLibrary mMusicLibrary;
|
|
|
|
|
|
|
|
|
|
// Points to the current playlist of music files stored in the music library
|
|
|
|
|
const Files::PathContainer* mCurrentPlaylist;
|
|
|
|
|
|
|
|
|
|
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,
|
|
|
|
|
bool loop, bool untracked=false);
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
SoundManager(Ogre::Root*, Ogre::Camera*,
|
|
|
|
|
const Files::PathContainer& dataDir, bool useSound, bool fsstrict,
|
|
|
|
|
MWWorld::Environment& environment);
|
|
|
|
|
~SoundManager();
|
|
|
|
|
|
|
|
|
|
// 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;
|
|
|
|
|
|
|
|
|
|
void streamMusicFull (const std::string& filename);
|
|
|
|
|
///< Play a soundifle
|
|
|
|
|
/// \param absolute filename
|
|
|
|
|
|
|
|
|
|
// A list of all sound files used to lookup paths
|
|
|
|
|
Files::PathContainer mSoundFiles;
|
|
|
|
|
|
|
|
|
|
// A library of all Music file paths stored by the folder they are contained in
|
|
|
|
|
Files::FileLibrary mMusicLibrary;
|
|
|
|
|
void stopMusic();
|
|
|
|
|
///< Stops music if it's playing
|
|
|
|
|
|
|
|
|
|
// Points to the current playlist of music files stored in the music library
|
|
|
|
|
const Files::PathContainer* mCurrentPlaylist;
|
|
|
|
|
void streamMusic(const std::string& filename);
|
|
|
|
|
///< Play a soundifle
|
|
|
|
|
/// \param filename name of a sound file in "Music/" in the data directory.
|
|
|
|
|
|
|
|
|
|
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,
|
|
|
|
|
bool loop, bool untracked=false);
|
|
|
|
|
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);
|
|
|
|
|
void startRandomTitle();
|
|
|
|
|
///< Starts a random track from the current playlist
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
bool isMusicPlaying();
|
|
|
|
|
///< Returns true if music is playing
|
|
|
|
|
|
|
|
|
|
SoundManager(Ogre::Root*, Ogre::Camera*,
|
|
|
|
|
const Files::PathContainer& dataDir, bool useSound, bool fsstrict,
|
|
|
|
|
MWWorld::Environment& environment);
|
|
|
|
|
~SoundManager();
|
|
|
|
|
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 stopMusic();
|
|
|
|
|
///< Stops music if it's playing
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
void streamMusic(const std::string& filename);
|
|
|
|
|
///< Play a soundifle
|
|
|
|
|
/// \param filename name of a sound file in "Music/" in the data directory.
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
|
|
void startRandomTitle();
|
|
|
|
|
///< Starts a random track from the current playlist
|
|
|
|
|
bool sayDone(MWWorld::Ptr reference) const;
|
|
|
|
|
///< Is actor not speaking?
|
|
|
|
|
|
|
|
|
|
bool isMusicPlaying();
|
|
|
|
|
///< Returns true if music is playing
|
|
|
|
|
void playSound(const std::string& soundId, float volume, float pitch, bool loop=false);
|
|
|
|
|
///< Play a sound, independently of 3D-position
|
|
|
|
|
|
|
|
|
|
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 playSound3D(MWWorld::Ptr reference, const std::string& soundId,
|
|
|
|
|
float volume, float pitch, bool loop,
|
|
|
|
|
bool untracked=false);
|
|
|
|
|
///< Play a sound from an object
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
void stopSound(MWWorld::Ptr::CellStore *cell);
|
|
|
|
|
///< Stop all sounds for the given cell.
|
|
|
|
|
|
|
|
|
|
bool sayDone (MWWorld::Ptr reference) const;
|
|
|
|
|
///< Is actor not speaking?
|
|
|
|
|
void stopSound(const std::string& soundId);
|
|
|
|
|
///< Stop a non-3d looping sound
|
|
|
|
|
|
|
|
|
|
void playSound (const std::string& soundId, float volume, float pitch, bool loop=false);
|
|
|
|
|
///< Play a sound, independently of 3D-position
|
|
|
|
|
bool getSoundPlaying(MWWorld::Ptr reference, const std::string& soundId) const;
|
|
|
|
|
///< Is the given sound currently playing on the given object?
|
|
|
|
|
|
|
|
|
|
void playSound3D (MWWorld::Ptr reference, const std::string& soundId,
|
|
|
|
|
float volume, float pitch, bool loop, bool untracked=false);
|
|
|
|
|
///< Play a sound from an object
|
|
|
|
|
void updateObject(MWWorld::Ptr reference);
|
|
|
|
|
///< Update the position of all sounds connected to the given object.
|
|
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
void update(float duration);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
void stopSound (MWWorld::Ptr::CellStore *cell);
|
|
|
|
|
///< Stop all sounds for the given cell.
|
|
|
|
|
class Sound_Output
|
|
|
|
|
{
|
|
|
|
|
SoundManager &mgr;
|
|
|
|
|
|
|
|
|
|
void stopSound(const std::string& soundId);
|
|
|
|
|
///< Stop a non-3d looping sound
|
|
|
|
|
virtual bool Initialize(const std::string &devname="") = 0;
|
|
|
|
|
virtual void Deinitialize() = 0;
|
|
|
|
|
|
|
|
|
|
bool getSoundPlaying (MWWorld::Ptr reference, const std::string& soundId) const;
|
|
|
|
|
///< Is the given sound currently playing on the given object?
|
|
|
|
|
Sound_Output(SoundManager &mgr) : mgr(mgr) { }
|
|
|
|
|
|
|
|
|
|
void updateObject(MWWorld::Ptr reference);
|
|
|
|
|
///< Update the position of all sounds connected to the given object.
|
|
|
|
|
public:
|
|
|
|
|
virtual ~Sound_Output() { }
|
|
|
|
|
|
|
|
|
|
void update (float duration);
|
|
|
|
|
friend class OpenAL_Output;
|
|
|
|
|
friend class SoundManager;
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|