metaforce/Runtime/World/CScriptRoomAcoustics.cpp

87 lines
3.2 KiB
C++
Raw Permalink Normal View History

#include "Runtime/World/CScriptRoomAcoustics.hpp"
#include "Runtime/Audio/CSfxManager.hpp"
#include "TCastTo.hpp" // Generated file, do not modify include path
2017-01-23 07:22:17 +00:00
2021-04-10 08:42:06 +00:00
namespace metaforce {
2017-01-23 07:22:17 +00:00
static TAreaId s_ActiveAcousticsAreaId = kInvalidAreaId;
2018-12-08 05:30:43 +00:00
CScriptRoomAcoustics::CScriptRoomAcoustics(TUniqueId uid, std::string_view name, const CEntityInfo& info, bool active,
u32 volScale, bool revHi, bool revHiDis, float revHiColoration,
float revHiMix, float revHiTime, float revHiDamping, float revHiPreDelay,
float revHiCrosstalk, bool chorus, float baseDelay, float variation,
float period, bool revStd, bool revStdDis, float revStdColoration,
float revStdMix, float revStdTime, float revStdDamping, float revStdPreDelay,
bool delay, u32 delayL, u32 delayR, u32 delayS, u32 feedbackL, u32 feedbackR,
u32 feedbackS, u32 outputL, u32 outputR, u32 outputS)
: CEntity(uid, info, active, name)
, x34_volumeScale(volScale)
, x38_revHi(revHi)
, x39_revHiDis(revHiDis)
, x3c_revHiInfo(revHiColoration, revHiMix, revHiTime, revHiDamping, revHiPreDelay, revHiCrosstalk)
, x54_chorus(chorus)
, x58_chorusInfo(baseDelay, variation, period)
, x64_revStd(revStd)
, x65_revStdDis(revStdDis)
, x68_revStdInfo(revStdColoration, revStdMix, revStdTime, revStdDamping, revStdPreDelay)
, x7c_delay(delay)
, x80_delayInfo(delayL, delayR, delayS, feedbackL, feedbackR, feedbackS, outputL, outputR, outputS) {}
2017-01-23 07:22:17 +00:00
2018-12-08 05:30:43 +00:00
void CScriptRoomAcoustics::DisableAuxCallbacks() {
CSfxManager::DisableAuxProcessing();
s_ActiveAcousticsAreaId = kInvalidAreaId;
CAudioSys::SetVolumeScale(CAudioSys::GetDefaultVolumeScale());
2017-01-23 07:22:17 +00:00
}
2018-12-08 05:30:43 +00:00
void CScriptRoomAcoustics::EnableAuxCallbacks() {
if (!x30_24_active) {
2018-12-08 05:30:43 +00:00
return;
}
2017-01-23 07:22:17 +00:00
2018-12-08 05:30:43 +00:00
bool applied = true;
if (x38_revHi) {
2018-12-08 05:30:43 +00:00
CSfxManager::PrepareReverbHiCallback(x3c_revHiInfo);
} else if (x54_chorus) {
2018-12-08 05:30:43 +00:00
CSfxManager::PrepareChorusCallback(x58_chorusInfo);
} else if (x64_revStd) {
2018-12-08 05:30:43 +00:00
CSfxManager::PrepareReverbStdCallback(x68_revStdInfo);
} else if (x7c_delay) {
2018-12-08 05:30:43 +00:00
CSfxManager::PrepareDelayCallback(x80_delayInfo);
} else {
2018-12-08 05:30:43 +00:00
applied = false;
}
2017-01-23 07:22:17 +00:00
if (applied) {
2018-12-08 05:30:43 +00:00
CAudioSys::SetVolumeScale(x34_volumeScale);
}
2018-12-08 05:30:43 +00:00
s_ActiveAcousticsAreaId = x4_areaId;
2017-01-23 07:22:17 +00:00
}
2021-06-07 19:29:18 +00:00
void CScriptRoomAcoustics::Think(float dt, CStateManager& stateMgr) { /* Intentionally empty */
}
2017-01-23 07:22:17 +00:00
2018-12-08 05:30:43 +00:00
void CScriptRoomAcoustics::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& stateMgr) {
CEntity::AcceptScriptMsg(msg, objId, stateMgr);
2017-01-23 07:22:17 +00:00
2018-12-08 05:30:43 +00:00
switch (msg) {
case EScriptObjectMessage::Activate:
EnableAuxCallbacks();
break;
case EScriptObjectMessage::Deactivate:
if (s_ActiveAcousticsAreaId == x4_areaId) {
s_ActiveAcousticsAreaId = kInvalidAreaId;
CSfxManager::DisableAuxProcessing();
CAudioSys::SetVolumeScale(CAudioSys::GetDefaultVolumeScale());
2017-01-23 07:22:17 +00:00
}
2018-12-08 05:30:43 +00:00
break;
default:
break;
}
2017-01-23 07:22:17 +00:00
}
2018-12-08 05:30:43 +00:00
void CScriptRoomAcoustics::Accept(IVisitor& visitor) { visitor.Visit(this); }
2017-01-23 07:22:17 +00:00
2021-04-10 08:42:06 +00:00
} // namespace metaforce