2012-03-17 02:45:18 -07:00
|
|
|
#ifndef GAME_SOUND_SOUND_H
|
|
|
|
#define GAME_SOUND_SOUND_H
|
|
|
|
|
2012-08-09 14:33:21 +02:00
|
|
|
#include "soundmanagerimp.hpp"
|
2012-07-16 23:54:04 +04:00
|
|
|
|
2012-03-17 02:45:18 -07:00
|
|
|
namespace MWSound
|
|
|
|
{
|
|
|
|
class Sound
|
|
|
|
{
|
2012-03-30 07:01:37 -07:00
|
|
|
virtual void update() = 0;
|
2012-03-17 02:45:18 -07:00
|
|
|
|
2012-03-24 03:49:03 -07:00
|
|
|
Sound& operator=(const Sound &rhs);
|
|
|
|
Sound(const Sound &rhs);
|
|
|
|
|
2012-03-28 04:58:47 -07:00
|
|
|
protected:
|
2015-05-12 19:02:56 +02:00
|
|
|
osg::Vec3f mPos;
|
2012-03-28 04:58:47 -07:00
|
|
|
float mVolume; /* NOTE: Real volume = mVolume*mBaseVolume */
|
|
|
|
float mBaseVolume;
|
2012-03-31 10:41:12 -07:00
|
|
|
float mPitch;
|
2012-03-28 04:58:47 -07:00
|
|
|
float mMinDistance;
|
|
|
|
float mMaxDistance;
|
2012-03-31 08:14:39 -07:00
|
|
|
int mFlags;
|
2013-07-26 18:43:06 +02:00
|
|
|
float mFadeOutTime;
|
2012-03-28 04:58:47 -07:00
|
|
|
|
2014-07-29 00:26:26 +02:00
|
|
|
std::vector<float> mLoudnessVector;
|
|
|
|
float mLoudnessFPS;
|
|
|
|
|
2012-03-17 02:45:18 -07:00
|
|
|
public:
|
2012-03-28 06:08:25 -07:00
|
|
|
virtual void stop() = 0;
|
|
|
|
virtual bool isPlaying() = 0;
|
2012-12-12 16:50:35 -08:00
|
|
|
virtual double getTimeOffset() = 0;
|
2015-05-12 19:02:56 +02:00
|
|
|
void setPosition(const osg::Vec3f &pos) { mPos = pos; }
|
2012-03-30 07:10:34 -07:00
|
|
|
void setVolume(float volume) { mVolume = volume; }
|
2013-07-26 18:43:06 +02:00
|
|
|
void setFadeout(float duration) { mFadeOutTime=duration; }
|
2014-07-29 00:26:26 +02:00
|
|
|
void setLoudnessVector(const std::vector<float>& loudnessVector, float loudnessFPS);
|
|
|
|
|
|
|
|
/// Get loudness at the current time position on a [0,1] scale.
|
|
|
|
/// Requires that loudnessVector was filled in by the user.
|
|
|
|
float getCurrentLoudness();
|
|
|
|
|
2012-12-18 02:01:04 -08:00
|
|
|
MWBase::SoundManager::PlayType getPlayType() const
|
|
|
|
{ return (MWBase::SoundManager::PlayType)(mFlags&MWBase::SoundManager::Play_TypeMask); }
|
|
|
|
|
|
|
|
|
2015-05-12 19:02:56 +02:00
|
|
|
Sound(const osg::Vec3f& pos, float vol, float basevol, float pitch, float mindist, float maxdist, int flags)
|
2012-12-17 23:35:20 -08:00
|
|
|
: mPos(pos)
|
|
|
|
, mVolume(vol)
|
|
|
|
, mBaseVolume(basevol)
|
|
|
|
, mPitch(pitch)
|
|
|
|
, mMinDistance(mindist)
|
|
|
|
, mMaxDistance(maxdist)
|
|
|
|
, mFlags(flags)
|
2013-07-26 18:43:06 +02:00
|
|
|
, mFadeOutTime(0)
|
2014-07-29 00:26:26 +02:00
|
|
|
, mLoudnessFPS(20)
|
2012-03-28 04:58:47 -07:00
|
|
|
{ }
|
2012-03-17 02:45:18 -07:00
|
|
|
virtual ~Sound() { }
|
|
|
|
|
|
|
|
friend class OpenAL_Output;
|
|
|
|
friend class SoundManager;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|