2019-12-22 20:04:07 +00:00
|
|
|
#include "Runtime/World/CScriptRoomAcoustics.hpp"
|
|
|
|
|
|
|
|
#include "Runtime/Audio/CSfxManager.hpp"
|
|
|
|
|
2019-09-21 13:07:13 +00:00
|
|
|
#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() {
|
2020-05-07 16:28:45 +00:00
|
|
|
if (!x30_24_active) {
|
2018-12-08 05:30:43 +00:00
|
|
|
return;
|
2020-05-07 16:28:45 +00:00
|
|
|
}
|
2017-01-23 07:22:17 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
bool applied = true;
|
2020-05-07 16:28:45 +00:00
|
|
|
if (x38_revHi) {
|
2018-12-08 05:30:43 +00:00
|
|
|
CSfxManager::PrepareReverbHiCallback(x3c_revHiInfo);
|
2020-05-07 16:28:45 +00:00
|
|
|
} else if (x54_chorus) {
|
2018-12-08 05:30:43 +00:00
|
|
|
CSfxManager::PrepareChorusCallback(x58_chorusInfo);
|
2020-05-07 16:28:45 +00:00
|
|
|
} else if (x64_revStd) {
|
2018-12-08 05:30:43 +00:00
|
|
|
CSfxManager::PrepareReverbStdCallback(x68_revStdInfo);
|
2020-05-07 16:28:45 +00:00
|
|
|
} else if (x7c_delay) {
|
2018-12-08 05:30:43 +00:00
|
|
|
CSfxManager::PrepareDelayCallback(x80_delayInfo);
|
2020-05-07 16:28:45 +00:00
|
|
|
} else {
|
2018-12-08 05:30:43 +00:00
|
|
|
applied = false;
|
2020-05-07 16:28:45 +00:00
|
|
|
}
|
2017-01-23 07:22:17 +00:00
|
|
|
|
2020-05-07 16:28:45 +00:00
|
|
|
if (applied) {
|
2018-12-08 05:30:43 +00:00
|
|
|
CAudioSys::SetVolumeScale(x34_volumeScale);
|
2020-05-07 16:28:45 +00:00
|
|
|
}
|
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
|