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
|
|
|
|
{
|
2016-09-16 23:43:33 +00:00
|
|
|
float x4_ = 15.f;
|
|
|
|
s16 x8_rank = 0;
|
|
|
|
s16 xa_prio;
|
|
|
|
CSfxHandle xc_handle;
|
|
|
|
TAreaId x10_area;
|
|
|
|
union
|
|
|
|
{
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
bool x14_24_useAcoustics:1;
|
|
|
|
bool x14_25_available:1;
|
|
|
|
bool x14_26_inArea:1;
|
|
|
|
bool x14_27_looped:1;
|
|
|
|
bool x14_28_playing:1;
|
|
|
|
bool x14_29_active:1;
|
|
|
|
};
|
|
|
|
u16 _dummy = 0;
|
|
|
|
};
|
2015-08-20 02:52:07 +00:00
|
|
|
public:
|
|
|
|
virtual ~CBaseSfxWrapper() {}
|
2016-09-16 23:43:33 +00:00
|
|
|
virtual void SetActive(bool v) {x14_29_active = v;}
|
|
|
|
virtual void SetPlaying(bool v) {x14_28_playing = v;}
|
|
|
|
virtual void SetRank(short v) {x8_rank = v;}
|
|
|
|
virtual void SetInArea(bool v) {x14_26_inArea = v;}
|
|
|
|
virtual bool IsLooped() const {return x14_27_looped;}
|
|
|
|
virtual bool IsPlaying() const {return x14_28_playing;}
|
|
|
|
virtual bool IsActive() const {return x14_29_active;}
|
|
|
|
virtual bool IsInArea() const {return x14_26_inArea;}
|
|
|
|
virtual bool UseAcoustics() const {return x14_24_useAcoustics;}
|
|
|
|
virtual s16 GetRank() const {return x8_rank;}
|
|
|
|
virtual s16 GetPriority() const {return xa_prio;}
|
|
|
|
virtual TAreaId GetArea() const {return x10_area;}
|
|
|
|
virtual CSfxHandle GetSfxHandle() const {return xc_handle;}
|
2015-08-20 02:52:07 +00:00
|
|
|
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;
|
2016-09-16 23:43:33 +00:00
|
|
|
virtual const std::shared_ptr<amuse::Voice>& GetVoice() const=0;
|
2015-08-20 02:52:07 +00:00
|
|
|
|
2016-09-16 23:43:33 +00:00
|
|
|
void Release() {x14_25_available = true;}
|
|
|
|
bool Available() const {return x14_25_available;}
|
2015-08-20 02:52:07 +00:00
|
|
|
|
|
|
|
CBaseSfxWrapper(bool looped, s16 prio, const CSfxHandle& handle, bool useAcoustics, TAreaId area)
|
2016-09-16 23:43:33 +00:00
|
|
|
: x8_rank(0), xa_prio(prio), xc_handle(handle), x10_area(area), x14_24_useAcoustics(useAcoustics),
|
|
|
|
x14_26_inArea(0), x14_27_looped(looped), x14_28_playing(0), x14_29_active(0) {}
|
2015-08-20 02:52:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class CSfxEmitterWrapper : public CBaseSfxWrapper
|
|
|
|
{
|
2016-09-16 23:43:33 +00:00
|
|
|
CAudioSys::C3DEmitterParmData x24_parmData;
|
|
|
|
std::shared_ptr<amuse::Emitter> x50_emitterHandle;
|
|
|
|
bool x54_ready = true;
|
2015-08-20 02:52:07 +00:00
|
|
|
public:
|
|
|
|
bool IsPlaying() const;
|
|
|
|
void Play();
|
|
|
|
void Stop();
|
|
|
|
bool Ready();
|
2016-04-17 02:50:45 +00:00
|
|
|
ESfxAudibility GetAudible(const zeus::CVector3f&);
|
2016-09-16 23:43:33 +00:00
|
|
|
const std::shared_ptr<amuse::Voice>& GetVoice() const { return x50_emitterHandle->getVoice(); }
|
2015-08-20 02:52:07 +00:00
|
|
|
|
2016-09-16 23:43:33 +00:00
|
|
|
const std::shared_ptr<amuse::Emitter>& GetHandle() const { return x50_emitterHandle; }
|
2015-08-20 02:52:07 +00:00
|
|
|
|
|
|
|
CSfxEmitterWrapper(bool looped, s16 prio, const CAudioSys::C3DEmitterParmData& data,
|
|
|
|
const CSfxHandle& handle, bool useAcoustics, TAreaId area)
|
2016-09-16 23:43:33 +00:00
|
|
|
: CBaseSfxWrapper(looped, prio, handle, useAcoustics, area), x24_parmData(data) {}
|
2015-08-20 02:52:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class CSfxWrapper : public CBaseSfxWrapper
|
|
|
|
{
|
2016-09-16 23:43:33 +00:00
|
|
|
u16 x18_sfxId;
|
|
|
|
std::shared_ptr<amuse::Voice> x1c_voiceHandle;
|
|
|
|
s16 x20_vol;
|
|
|
|
s16 x22_pan;
|
|
|
|
bool x24_ready = true;
|
2015-08-20 02:52:07 +00:00
|
|
|
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;}
|
2016-09-16 23:43:33 +00:00
|
|
|
const std::shared_ptr<amuse::Voice>& GetVoice() const {return x1c_voiceHandle;}
|
2015-08-20 02:52:07 +00:00
|
|
|
|
2016-09-16 23:43:33 +00:00
|
|
|
void SetVolume(s16 vol) {x20_vol = vol;}
|
2015-08-20 02:52:07 +00:00
|
|
|
|
|
|
|
CSfxWrapper(bool looped, s16 prio, u16 sfxId, s16 vol, s16 pan,
|
|
|
|
const CSfxHandle& handle, bool useAcoustics, TAreaId area)
|
|
|
|
: CBaseSfxWrapper(looped, prio, handle, useAcoustics, area),
|
2016-09-16 23:43:33 +00:00
|
|
|
x18_sfxId(sfxId), x20_vol(vol), x22_pan(pan) {}
|
2015-08-20 02:52:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
2016-09-17 06:40:45 +00:00
|
|
|
static void SetChannel(ESfxChannels) {}
|
|
|
|
static void KillAll(ESfxChannels) {}
|
|
|
|
static void TurnOnChannel(ESfxChannels) {}
|
2015-08-20 02:52:07 +00:00
|
|
|
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-05-03 08:27:28 +00:00
|
|
|
static void PitchBend(const CSfxHandle&, s32) {}
|
2016-04-25 05:03:38 +00:00
|
|
|
static u16 TranslateSFXID(u16);
|
2016-09-16 23:43:33 +00:00
|
|
|
static CSfxHandle SfxStop(const CSfxHandle& handle);
|
2016-12-13 05:22:30 +00:00
|
|
|
static CSfxHandle SfxStart(u16 id, float vol, float pan, bool active, s16 prio, bool inArea, s32 areaId);
|
2015-08-20 02:52:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-04-13 06:07:23 +00:00
|
|
|
#endif // __URDE_CSFXMANAGER_HPP__
|