2016-04-13 06:07:23 +00:00
|
|
|
#ifndef __URDE_CSFXMANAGER_HPP__
|
|
|
|
#define __URDE_CSFXMANAGER_HPP__
|
2015-08-20 02:52:07 +00:00
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
#include "../RetroTypes.hpp"
|
|
|
|
#include "CSfxHandle.hpp"
|
2016-03-04 23:04:53 +00:00
|
|
|
#include "zeus/CVector3f.hpp"
|
2015-08-20 02:52:07 +00:00
|
|
|
#include "CAudioSys.hpp"
|
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
namespace urde
|
2015-08-20 02:52:07 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
class CSfxManager
|
|
|
|
{
|
2016-04-28 04:52:41 +00:00
|
|
|
static std::vector<s16>* mpSfxTranslationTable;
|
2016-04-17 02:50:45 +00:00
|
|
|
public:
|
2015-11-21 01:16:07 +00:00
|
|
|
enum class ESfxChannels
|
2015-08-20 02:52:07 +00:00
|
|
|
{
|
2016-04-17 02:50:45 +00:00
|
|
|
Zero,
|
|
|
|
One
|
2015-08-20 02:52:07 +00:00
|
|
|
};
|
|
|
|
|
2015-11-21 01:16:07 +00:00
|
|
|
enum class ESfxAudibility
|
2015-08-20 02:52:07 +00:00
|
|
|
{
|
|
|
|
Aud0,
|
|
|
|
Aud1,
|
|
|
|
Aud2,
|
|
|
|
Aud3
|
|
|
|
};
|
|
|
|
|
|
|
|
class CSfxChannel
|
|
|
|
{
|
|
|
|
};
|
|
|
|
|
|
|
|
class CBaseSfxWrapper
|
|
|
|
{
|
|
|
|
s16 m_rank;
|
|
|
|
s16 m_prio;
|
|
|
|
CSfxHandle m_handle;
|
|
|
|
TAreaId m_area;
|
|
|
|
bool m_useAcoustics:1;
|
|
|
|
bool m_available:1;
|
|
|
|
bool m_inArea:1;
|
|
|
|
bool m_looped:1;
|
|
|
|
bool m_playing:1;
|
|
|
|
bool m_active:1;
|
|
|
|
public:
|
|
|
|
virtual ~CBaseSfxWrapper() {}
|
|
|
|
virtual void SetActive(bool v) {m_active = v;}
|
|
|
|
virtual void SetPlaying(bool v) {m_playing = v;}
|
|
|
|
virtual void SetRank(short v) {m_rank = v;}
|
|
|
|
virtual void SetInArea(bool v) {m_inArea = v;}
|
|
|
|
virtual bool IsLooped() const {return m_looped;}
|
|
|
|
virtual bool IsPlaying() const {return m_playing;}
|
|
|
|
virtual bool IsActive() const {return m_active;}
|
|
|
|
virtual bool IsInArea() const {return m_inArea;}
|
|
|
|
virtual bool UseAcoustics() const {return m_useAcoustics;}
|
|
|
|
virtual s16 GetRank() const {return m_rank;}
|
|
|
|
virtual s16 GetPriority() const {return m_prio;}
|
|
|
|
virtual TAreaId GetArea() const {return m_area;}
|
|
|
|
virtual CSfxHandle GetSfxHandle() const {return m_handle;}
|
|
|
|
virtual void Play()=0;
|
|
|
|
virtual void Stop()=0;
|
|
|
|
virtual bool Ready()=0;
|
2016-04-17 02:50:45 +00:00
|
|
|
virtual ESfxAudibility GetAudible(const zeus::CVector3f&)=0;
|
2015-08-20 02:52:07 +00:00
|
|
|
virtual u32 GetVoice() const=0;
|
|
|
|
|
|
|
|
void Release() {m_available = true;}
|
|
|
|
bool Available() const {return m_available;}
|
|
|
|
|
|
|
|
CBaseSfxWrapper(bool looped, s16 prio, const CSfxHandle& handle, bool useAcoustics, TAreaId area)
|
|
|
|
: m_rank(0), m_prio(prio), m_handle(handle), m_area(area), m_useAcoustics(useAcoustics),
|
|
|
|
m_inArea(0), m_looped(looped), m_playing(0), m_active(0) {}
|
|
|
|
};
|
|
|
|
|
|
|
|
class CSfxEmitterWrapper : public CBaseSfxWrapper
|
|
|
|
{
|
|
|
|
CAudioSys::C3DEmitterParmData m_parmData;
|
|
|
|
u32 m_emitterHandle = -1;
|
|
|
|
public:
|
|
|
|
bool IsPlaying() const;
|
|
|
|
void Play();
|
|
|
|
void Stop();
|
|
|
|
bool Ready();
|
2016-04-17 02:50:45 +00:00
|
|
|
ESfxAudibility GetAudible(const zeus::CVector3f&);
|
2015-08-20 02:52:07 +00:00
|
|
|
u32 GetVoice() const;
|
|
|
|
|
|
|
|
u32 GetHandle() const {return m_emitterHandle;}
|
|
|
|
|
|
|
|
CSfxEmitterWrapper(bool looped, s16 prio, const CAudioSys::C3DEmitterParmData& data,
|
|
|
|
const CSfxHandle& handle, bool useAcoustics, TAreaId area)
|
|
|
|
: CBaseSfxWrapper(looped, prio, handle, useAcoustics, area), m_parmData(data) {}
|
|
|
|
};
|
|
|
|
|
|
|
|
class CSfxWrapper : public CBaseSfxWrapper
|
|
|
|
{
|
|
|
|
u16 m_sfxId;
|
|
|
|
u32 m_voiceHandle = -1;
|
|
|
|
s16 m_vol;
|
|
|
|
s16 m_pan;
|
|
|
|
public:
|
|
|
|
bool IsPlaying() const;
|
|
|
|
void Play();
|
|
|
|
void Stop();
|
|
|
|
bool Ready();
|
2016-04-17 02:50:45 +00:00
|
|
|
ESfxAudibility GetAudible(const zeus::CVector3f&) {return ESfxAudibility::Aud3;}
|
2015-08-20 02:52:07 +00:00
|
|
|
u32 GetVoice() const {return m_voiceHandle;}
|
|
|
|
|
|
|
|
void SetVolume(s16 vol) {m_vol = vol;}
|
|
|
|
|
|
|
|
CSfxWrapper(bool looped, s16 prio, u16 sfxId, s16 vol, s16 pan,
|
|
|
|
const CSfxHandle& handle, bool useAcoustics, TAreaId area)
|
|
|
|
: CBaseSfxWrapper(looped, prio, handle, useAcoustics, area),
|
|
|
|
m_sfxId(sfxId), m_vol(vol), m_pan(pan) {}
|
|
|
|
};
|
|
|
|
|
|
|
|
static CSfxChannel m_channels[4];
|
|
|
|
static rstl::reserved_vector<CSfxEmitterWrapper, 128> m_emitterWrapperPool;
|
|
|
|
static rstl::reserved_vector<CSfxWrapper, 128> m_wrapperPool;
|
|
|
|
static ESfxChannels m_currentChannel;
|
|
|
|
static bool m_doUpdate;
|
|
|
|
static void* m_usedSounds;
|
|
|
|
static bool m_muted;
|
|
|
|
static bool m_auxProcessingEnabled;
|
|
|
|
|
|
|
|
static u16 kMaxPriority;
|
|
|
|
static u16 kMedPriority;
|
|
|
|
static u16 kInternalInvalidSfxId;
|
|
|
|
static u32 kAllAreas;
|
|
|
|
|
|
|
|
static ESfxChannels GetCurrentChannel() {return m_currentChannel;}
|
2016-04-17 02:50:45 +00:00
|
|
|
static void AddListener(ESfxChannels,
|
|
|
|
const zeus::CVector3f& pos, const zeus::CVector3f& dir,
|
|
|
|
const zeus::CVector3f& heading, const zeus::CVector3f& up,
|
|
|
|
float frontRadius, float surroundRadius, float soundSpeed,
|
|
|
|
u32 flags /* 0x1 for doppler */, u8 vol);
|
|
|
|
static void UpdateListener(const zeus::CVector3f& pos, const zeus::CVector3f& dir,
|
|
|
|
const zeus::CVector3f& heading, const zeus::CVector3f& up,
|
|
|
|
u8 vol);
|
2016-04-25 05:03:38 +00:00
|
|
|
|
2016-04-29 10:08:46 +00:00
|
|
|
static void RemoveEmitter(const CSfxHandle&) {}
|
2016-04-25 05:03:38 +00:00
|
|
|
static u16 TranslateSFXID(u16);
|
2015-08-20 02:52:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-04-13 06:07:23 +00:00
|
|
|
#endif // __URDE_CSFXMANAGER_HPP__
|