1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-10 06:39:49 +00:00
OpenMW/apps/openmw/mwsound/soundmanager.hpp

125 lines
4.5 KiB
C++
Raw Normal View History

#ifndef GAME_SOUND_SOUNDMANAGER_H
#define GAME_SOUND_SOUNDMANAGER_H
#include <string>
#include <components/files/filelibrary.hpp>
#include "../mwworld/ptr.hpp"
namespace Ogre
{
class Root;
class Camera;
}
namespace MWWorld
{
struct Environment;
}
namespace MWSound
{
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;
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
// 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,
2012-03-13 16:05:38 +00:00
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:
2011-06-12 00:01:21 +00:00
SoundManager(Ogre::Root*, Ogre::Camera*,
const Files::PathContainer& dataDir, bool useSound, bool fsstrict,
MWWorld::Environment& environment);
~SoundManager();
2010-11-12 00:47:26 +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();
///< 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();
///< Returns true if music is playing
2010-10-31 16:23:03 +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);
///< 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
bool sayDone (MWWorld::Ptr reference) const;
///< Is actor not speaking?
void playSound (const std::string& soundId, float volume, float pitch, bool loop=false);
///< Play a sound, independently of 3D-position
2010-08-14 05:54:51 +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);
///< 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-08-14 07:26:00 +00:00
void stopSound (MWWorld::Ptr::CellStore *cell);
///< Stop all sounds for the given cell.
void stopSound(const std::string& soundId);
///< Stop a non-3d looping sound
bool getSoundPlaying (MWWorld::Ptr reference, const std::string& soundId) const;
///< Is the given sound currently playing on the given object?
void updateObject(MWWorld::Ptr reference);
///< Update the position of all sounds connected to the given object.
void update (float duration);
};
}
#endif