mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-09 06:27:43 +00:00
Working SFX playback
This commit is contained in:
@@ -13,12 +13,13 @@ class CSfxManager
|
||||
{
|
||||
static std::vector<s16>* mpSfxTranslationTable;
|
||||
public:
|
||||
CSfxManager();
|
||||
|
||||
enum class ESfxChannels
|
||||
{
|
||||
Zero,
|
||||
One
|
||||
Invalid = -1,
|
||||
Default = 0,
|
||||
Game,
|
||||
PauseScreen
|
||||
};
|
||||
|
||||
enum class ESfxAudibility
|
||||
@@ -29,16 +30,37 @@ public:
|
||||
Aud3
|
||||
};
|
||||
|
||||
class CSfxChannel
|
||||
enum class EAuxEffect
|
||||
{
|
||||
None = -1,
|
||||
ReverbHi = 0,
|
||||
Chorus,
|
||||
ReverbStd,
|
||||
Delay
|
||||
};
|
||||
|
||||
class CBaseSfxWrapper;
|
||||
using CSfxHandle = std::shared_ptr<CBaseSfxWrapper>;
|
||||
|
||||
class CSfxChannel
|
||||
{
|
||||
friend class CSfxManager;
|
||||
zeus::CVector3f x0_pos;
|
||||
zeus::CVector3f xc_;
|
||||
zeus::CVector3f x18_;
|
||||
zeus::CVector3f x24_;
|
||||
float x30_ = 0.f;
|
||||
float x34_ = 0.f;
|
||||
float x38_ = 0.f;
|
||||
u32 x3c_ = 0;
|
||||
bool x40_ = false;
|
||||
bool x44_listenerActive = false;
|
||||
std::unordered_set<CSfxHandle> x48_handles;
|
||||
};
|
||||
|
||||
class CBaseSfxWrapper : public std::enable_shared_from_this<CBaseSfxWrapper>
|
||||
{
|
||||
float x4_ = 15.f;
|
||||
float x4_timeRemaining = 15.f;
|
||||
s16 x8_rank = 0;
|
||||
s16 xa_prio;
|
||||
//CSfxHandle xc_handle;
|
||||
@@ -76,10 +98,17 @@ public:
|
||||
virtual bool Ready()=0;
|
||||
virtual ESfxAudibility GetAudible(const zeus::CVector3f&)=0;
|
||||
virtual const std::shared_ptr<amuse::Voice>& GetVoice() const=0;
|
||||
virtual u16 GetSfxId() const=0;
|
||||
virtual void UpdateEmitterSilent()=0;
|
||||
virtual void UpdateEmitter()=0;
|
||||
virtual void SetReverb(float rev)=0;
|
||||
|
||||
void Release() { x14_28_available = true; }
|
||||
void Release() { x14_28_available = true; x4_timeRemaining = 15.f; }
|
||||
bool Available() const { return x14_28_available; }
|
||||
|
||||
float GetTimeRemaining() const { return x4_timeRemaining; }
|
||||
void SetTimeRemaining(float t) { x4_timeRemaining = t; }
|
||||
|
||||
CBaseSfxWrapper(bool looped, s16 prio, /*const CSfxHandle& handle,*/ bool useAcoustics, TAreaId area)
|
||||
: x8_rank(0), xa_prio(prio), /*xc_handle(handle),*/ x10_area(area), x14_24_isActive(true), x14_25_isPlaying(false),
|
||||
x14_26_looped(looped), x14_27_inArea(true), x14_28_available(false), x14_29_useAcoustics(useAcoustics) {}
|
||||
@@ -91,6 +120,7 @@ public:
|
||||
CAudioSys::C3DEmitterParmData x24_parmData;
|
||||
std::shared_ptr<amuse::Emitter> x50_emitterHandle;
|
||||
bool x54_ready = true;
|
||||
float x55_cachedMaxVol;
|
||||
public:
|
||||
bool IsPlaying() const;
|
||||
void Play();
|
||||
@@ -98,6 +128,10 @@ public:
|
||||
bool Ready();
|
||||
ESfxAudibility GetAudible(const zeus::CVector3f&);
|
||||
const std::shared_ptr<amuse::Voice>& GetVoice() const { return x50_emitterHandle->getVoice(); }
|
||||
u16 GetSfxId() const;
|
||||
void UpdateEmitterSilent();
|
||||
void UpdateEmitter();
|
||||
void SetReverb(float rev);
|
||||
|
||||
const std::shared_ptr<amuse::Emitter>& GetHandle() const { return x50_emitterHandle; }
|
||||
|
||||
@@ -120,6 +154,10 @@ public:
|
||||
bool Ready();
|
||||
ESfxAudibility GetAudible(const zeus::CVector3f&) { return ESfxAudibility::Aud3; }
|
||||
const std::shared_ptr<amuse::Voice>& GetVoice() const { return x1c_voiceHandle; }
|
||||
u16 GetSfxId() const;
|
||||
void UpdateEmitterSilent();
|
||||
void UpdateEmitter();
|
||||
void SetReverb(float rev);
|
||||
|
||||
void SetVolume(s16 vol) { x20_vol = vol; }
|
||||
|
||||
@@ -130,14 +168,14 @@ public:
|
||||
};
|
||||
|
||||
static CSfxChannel m_channels[4];
|
||||
static rstl::reserved_vector<std::shared_ptr<CSfxEmitterWrapper>, 128> m_emitterWrapperPool;
|
||||
static rstl::reserved_vector<std::shared_ptr<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 float m_reverbAmount;
|
||||
static EAuxEffect m_activeEffect;
|
||||
static EAuxEffect m_nextEffect;
|
||||
|
||||
static u16 kMaxPriority;
|
||||
static u16 kMedPriority;
|
||||
@@ -146,9 +184,10 @@ public:
|
||||
|
||||
static bool LoadTranslationTable(CSimplePool* pool, const SObjectTag* tag);
|
||||
static bool IsAuxProcessingEnabled() { return m_auxProcessingEnabled; }
|
||||
static void SetChannel(ESfxChannels) {}
|
||||
static void SetChannel(ESfxChannels);
|
||||
static void KillAll(ESfxChannels) {}
|
||||
static void TurnOnChannel(ESfxChannels) {}
|
||||
static void TurnOnChannel(ESfxChannels);
|
||||
static void TurnOffChannel(ESfxChannels);
|
||||
static ESfxChannels GetCurrentChannel() {return m_currentChannel;}
|
||||
static void AddListener(ESfxChannels,
|
||||
const zeus::CVector3f& pos, const zeus::CVector3f& dir,
|
||||
@@ -159,19 +198,26 @@ public:
|
||||
const zeus::CVector3f& heading, const zeus::CVector3f& up,
|
||||
u8 vol);
|
||||
|
||||
static void StopSound(const CSfxHandle& handle);
|
||||
static s16 GetRank(CBaseSfxWrapper* sfx);
|
||||
static void ApplyReverb();
|
||||
static float GetReverbAmount();
|
||||
static void RemoveEmitter(const CSfxHandle&) {}
|
||||
static void PitchBend(const CSfxHandle&, s32) {}
|
||||
static u16 TranslateSFXID(u16);
|
||||
static void SfxStop(const CSfxHandle& handle);
|
||||
static CSfxHandle SfxStart(u16 id, float vol, float pan, bool useAcoustics, s16 prio, bool looped, s32 areaId);
|
||||
static void StopAndRemoveAllEmitters();
|
||||
static void DisableAuxCallbacks();
|
||||
static void DisableAuxCallback();
|
||||
static void EnableAuxCallback();
|
||||
static void PrepareDelayCallback(const amuse::EffectDelayInfo& info);
|
||||
static void PrepareReverbStdCallback(const amuse::EffectReverbStdInfo& info);
|
||||
static void PrepareChorusCallback(const amuse::EffectChorusInfo& info);
|
||||
static void PrepareReverbHiCallback(const amuse::EffectReverbHiInfo& info);
|
||||
static void DisableAuxProcessing();
|
||||
|
||||
static void Update();
|
||||
static void Update(float dt);
|
||||
static void Shutdown();
|
||||
|
||||
private:
|
||||
static std::shared_ptr<CSfxWrapper>* AllocateCSfxWrapper();
|
||||
};
|
||||
|
||||
using CSfxHandle = CSfxManager::CSfxHandle;
|
||||
|
||||
Reference in New Issue
Block a user