summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrobojumper <robojumper@gmail.com>2025-05-28 22:19:53 +0200
committerrobojumper <robojumper@gmail.com>2025-05-28 22:21:32 +0200
commitbd2adcab70991550f79ba76e035381e03ce89f60 (patch)
tree476b7b4722d1ff05501cfeb752985999c8fc26c5
parentd004459b3c8af2e5ada3b44093feff260c8d9e35 (diff)
snd_Sound3DManager OK
-rw-r--r--config/SOUE01/symbols.txt48
-rw-r--r--configure.py2
-rw-r--r--include/nw4r/snd/snd_BasicSound.h16
-rw-r--r--include/nw4r/snd/snd_Sound3DManager.h21
-rw-r--r--src/nw4r/snd/snd_BasicSound.cpp10
-rw-r--r--src/nw4r/snd/snd_Sound3DManager.cpp246
6 files changed, 77 insertions, 266 deletions
diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt
index d8b54fc0..d3cfc41e 100644
--- a/config/SOUE01/symbols.txt
+++ b/config/SOUE01/symbols.txt
@@ -20038,7 +20038,7 @@ fn_80360C30 = .text:0x80360C30; // type:function size:0x78
fn_80360CB0 = .text:0x80360CB0; // type:function size:0x48
fn_80360D00 = .text:0x80360D00; // type:function size:0x10
fn_80360D10 = .text:0x80360D10; // type:function size:0xE4
-fn_80360E00 = .text:0x80360E00; // type:function size:0x60
+__dt__Q34nw4r3snd14Sound3DManagerFv = .text:0x80360E00; // type:function size:0x60
fn_80360E60 = .text:0x80360E60; // type:function size:0x118
fn_80360F80 = .text:0x80360F80; // type:function size:0xC
fn_80360F90 = .text:0x80360F90; // type:function size:0x20
@@ -25470,10 +25470,10 @@ detail_AllocAmbientArg__Q34nw4r3snd14Sound3DManagerFUl = .text:0x80475E70; // ty
detail_FreeAmbientArg__Q34nw4r3snd14Sound3DManagerFPvPCQ44nw4r3snd6detail10BasicSound = .text:0x80475EE0; // type:function size:0x14
SetBiquadFilterType__Q34nw4r3snd14Sound3DManagerFi = .text:0x80475F00; // type:function size:0x8
__ct__Q34nw4r3snd12Sound3DParamFv = .text:0x80475F10; // type:function size:0x28
-__sinit_snd_Sound3DManager_cpp = .text:0x80475F40; // type:function size:0xC scope:local
-@4@detail_FreeAmbientArg__Q34nw4r3snd14Sound3DManagerFPvPCQ44nw4r3snd6detail10BasicSound = .text:0x80475F50; // type:function size:0x8
-@4@detail_AllocAmbientArg__Q34nw4r3snd14Sound3DManagerFUl = .text:0x80475F60; // type:function size:0x8
-@4@__dt__Q34nw4r3snd14Sound3DManagerFv = .text:0x80475F70; // type:function size:0x8
+__sinit_\snd_Sound3DManager_cpp = .text:0x80475F40; // type:function size:0xC scope:local
+@4@detail_FreeAmbientArg__Q34nw4r3snd14Sound3DManagerFPvPCQ44nw4r3snd6detail10BasicSound = .text:0x80475F50; // type:function size:0x8 scope:weak
+@4@detail_AllocAmbientArg__Q34nw4r3snd14Sound3DManagerFUl = .text:0x80475F60; // type:function size:0x8 scope:weak
+@4@__dt__Q34nw4r3snd14Sound3DManagerFv = .text:0x80475F70; // type:function size:0x8 scope:weak
__ct__Q34nw4r3snd10SoundActorFRQ34nw4r3snd18SoundArchivePlayer = .text:0x80475F80; // type:function size:0xC0
__dt__Q34nw4r3snd10SoundActorFv = .text:0x80476040; // type:function size:0xAC
StopAllSound__Q34nw4r3snd10SoundActorFi = .text:0x804760F0; // type:function size:0x5C
@@ -38611,7 +38611,7 @@ __vt__Q54nw4r3snd6detail8SeqSound11SeqLoadTask = .data:0x8056E0C0; // type:objec
__vt__Q44nw4r3snd6detail8SeqTrack = .data:0x8056E0D8; // type:object size:0x10
lbl_8056E0E8 = .data:0x8056E0E8; // type:object size:0x30
__vt__Q34nw4r3snd13Sound3DEngine = .data:0x8056E118; // type:object size:0x1C
-lbl_8056E138 = .data:0x8056E138; // type:object size:0x38
+__vt__Q34nw4r3snd14Sound3DManager = .data:0x8056E138; // type:object size:0x34
__vt__Q34nw4r3snd10SoundActor = .data:0x8056E170; // type:object size:0x1C
__vt__Q34nw4r3snd12SoundArchive = .data:0x8056E190; // type:object size:0x20
lbl_8056E1B0 = .data:0x8056E1B0; // type:object size:0x30
@@ -49718,21 +49718,21 @@ lbl_8057F014 = .sdata2:0x8057F014; // type:object size:0x4 align:4 data:float
@3319 = .sdata2:0x8057F0A0; // type:object size:0x8 scope:local align:8 data:double
@3320 = .sdata2:0x8057F0A8; // type:object size:0x8 scope:local align:8 data:double
lbl_8057F0B0 = .sdata2:0x8057F0B0; // type:object size:0x4 align:4 data:float
-lbl_8057F0B8 = .sdata2:0x8057F0B8; // type:object size:0x4 align:4 data:float
-lbl_8057F0BC = .sdata2:0x8057F0BC; // type:object size:0x4 align:4 data:float
-lbl_8057F0C0 = .sdata2:0x8057F0C0; // type:object size:0x4 align:4 data:float
-lbl_8057F0C8 = .sdata2:0x8057F0C8; // type:object size:0x8 align:8 data:double
-lbl_8057F0D0 = .sdata2:0x8057F0D0; // type:object size:0x8 align:8 data:double
-lbl_8057F0D8 = .sdata2:0x8057F0D8; // type:object size:0x4 align:4 data:float
-lbl_8057F0DC = .sdata2:0x8057F0DC; // type:object size:0x4 align:4 data:float
-lbl_8057F0E0 = .sdata2:0x8057F0E0; // type:object size:0x4 align:4 data:float
-lbl_8057F0E4 = .sdata2:0x8057F0E4; // type:object size:0x4 align:4 data:float
-lbl_8057F0E8 = .sdata2:0x8057F0E8; // type:object size:0x4 align:4 data:float
-lbl_8057F0EC = .sdata2:0x8057F0EC; // type:object size:0x4 align:4 data:float
-lbl_8057F0F0 = .sdata2:0x8057F0F0; // type:object size:0x4 align:4 data:float
-lbl_8057F0F4 = .sdata2:0x8057F0F4; // type:object size:0x4 align:4 data:float
-lbl_8057F0F8 = .sdata2:0x8057F0F8; // type:object size:0x4 align:4 data:float
-lbl_8057F0FC = .sdata2:0x8057F0FC; // type:object size:0x4 align:4 data:float
+@2828 = .sdata2:0x8057F0B8; // type:object size:0x4 scope:local align:4 data:float
+@2829 = .sdata2:0x8057F0BC; // type:object size:0x4 scope:local align:4 data:float
+@2830 = .sdata2:0x8057F0C0; // type:object size:0x4 scope:local align:4 data:float
+@2837 = .sdata2:0x8057F0C8; // type:object size:0x8 scope:local align:8 data:double
+@2838 = .sdata2:0x8057F0D0; // type:object size:0x8 scope:local align:8 data:double
+@2902 = .sdata2:0x8057F0D8; // type:object size:0x4 scope:local align:4 data:float
+@2903 = .sdata2:0x8057F0DC; // type:object size:0x4 scope:local align:4 data:float
+@2962 = .sdata2:0x8057F0E0; // type:object size:0x4 scope:local align:4 data:float
+@2963 = .sdata2:0x8057F0E4; // type:object size:0x4 scope:local align:4 data:float
+@2964 = .sdata2:0x8057F0E8; // type:object size:0x4 scope:local align:4 data:float
+@2965 = .sdata2:0x8057F0EC; // type:object size:0x4 scope:local align:4 data:float
+@2966 = .sdata2:0x8057F0F0; // type:object size:0x4 scope:local align:4 data:float
+@2967 = .sdata2:0x8057F0F4; // type:object size:0x4 scope:local align:4 data:float
+@2968 = .sdata2:0x8057F0F8; // type:object size:0x4 scope:local align:4 data:float
+@2969 = .sdata2:0x8057F0FC; // type:object size:0x4 scope:local align:4 data:float
@2216 = .sdata2:0x8057F100; // type:object size:0x4 scope:local align:4 data:float
@2217 = .sdata2:0x8057F104; // type:object size:0x4 scope:local align:4 data:float
@2218 = .sdata2:0x8057F108; // type:object size:0x4 scope:local align:4 data:float
@@ -49741,8 +49741,8 @@ lbl_8057F0FC = .sdata2:0x8057F0FC; // type:object size:0x4 align:4 data:float
@1266 = .sdata2:0x8057F118; // type:object size:0x4 scope:local align:4 data:float
@1267 = .sdata2:0x8057F11C; // type:object size:0x4 scope:local align:4 data:float
@1268 = .sdata2:0x8057F120; // type:object size:0x4 scope:local align:4 data:float
-lbl_8057F128 = .sdata2:0x8057F128; // type:object size:0x4 align:4 data:float
-lbl_8057F12C = .sdata2:0x8057F12C; // type:object size:0x4 align:4 data:float
+@2580 = .sdata2:0x8057F128; // type:object size:0x4 scope:local align:4 data:float
+@2581 = .sdata2:0x8057F12C; // type:object size:0x4 scope:local align:4 data:float
@3454 = .sdata2:0x8057F130; // type:object size:0x4 scope:local align:4 data:float
@3455 = .sdata2:0x8057F134; // type:object size:0x4 scope:local align:4 data:float
lbl_8057F138 = .sdata2:0x8057F138; // type:object size:0x4 align:4 data:float
@@ -51940,7 +51940,7 @@ sBiquadFilterCallbackTable__Q44nw4r3snd6detail9AxManager = .bss:0x80659080; // t
@LOCAL@GetInstance__Q44nw4r3snd6detail22DisposeCallbackManagerFv@instance = .bss:0x80659404; // type:object size:0xC scope:weak data:4byte
@LOCAL@GetInstance__Q44nw4r3snd6detail20RemoteSpeakerManagerFv@instance = .bss:0x80659410; // type:object size:0x2D8 scope:weak data:byte
mGlobalVariable__Q44nw4r3snd6detail9SeqPlayer = .bss:0x806596E8; // type:object size:0x20 data:2byte
-lbl_80659708 = .bss:0x80659708; // type:object size:0x18
+sEngine__Q34nw4r3snd32@unnamed@snd_Sound3DManager_cpp@ = .bss:0x80659708; // type:object size:0x14 scope:local
@1420 = .bss:0x80659720; // type:object size:0xC scope:local
@LOCAL@detail_SortPriorityList__Q34nw4r3snd11SoundPlayerFv@tmplist = .bss:0x80659730; // type:object size:0x600 scope:weak data:4byte
@2786 = .bss:0x80659D40; // type:object size:0xC scope:local
diff --git a/configure.py b/configure.py
index 79551cb7..30d11743 100644
--- a/configure.py
+++ b/configure.py
@@ -1056,7 +1056,7 @@ config.libs = [
Object(Matching, "nw4r/snd/snd_Sound3DCalculator.cpp"),
Object(Matching, "nw4r/snd/snd_Sound3DEngine.cpp"),
Object(Matching, "nw4r/snd/snd_Sound3DListener.cpp"),
- Object(NonMatching, "nw4r/snd/snd_Sound3DManager.cpp"),
+ Object(Matching, "nw4r/snd/snd_Sound3DManager.cpp"),
Object(Matching, "nw4r/snd/snd_SoundActor.cpp"),
Object(Matching, "nw4r/snd/snd_SoundArchive.cpp"),
Object(NonMatching, "nw4r/snd/snd_SoundArchiveFile.cpp"),
diff --git a/include/nw4r/snd/snd_BasicSound.h b/include/nw4r/snd/snd_BasicSound.h
index 84a4d5e4..fcfa1366 100644
--- a/include/nw4r/snd/snd_BasicSound.h
+++ b/include/nw4r/snd/snd_BasicSound.h
@@ -169,10 +169,10 @@ namespace nw4r { namespace snd { namespace detail
};
// methods
public:
- virtual void at_0x08();
- virtual void at_0x0c(void *, int, int, void *);
- virtual int at_0x10(void *, int);
- virtual int at_0x14(void *, int);
+ virtual ~AmbientParamUpdateCallback() {}
+ virtual void detail_UpdateAmbientParam(const void*, u32, int, SoundAmbientParam*);
+ virtual int detail_GetAmbientPriority(const void*, u32);
+ virtual int detail_GetRequiredVoiceOutCount(const void*, u32);
// members
private:
@@ -202,9 +202,11 @@ namespace nw4r { namespace snd { namespace detail
public:
// virtual function ordering
// vtable AmbientArgAllocaterCallback
- virtual void at_0x08();
- virtual void *at_0x0c(int);
- virtual void at_0x10(void *, void *);
+ virtual ~AmbientArgAllocaterCallback() {}
+ virtual void *detail_AllocAmbientArg(u32 size); // at 0x8
+
+ virtual void detail_FreeAmbientArg(void *pArg,
+ const detail::BasicSound *pSound); // at 0xC
// members
private:
diff --git a/include/nw4r/snd/snd_Sound3DManager.h b/include/nw4r/snd/snd_Sound3DManager.h
index a8f8df43..f3674247 100644
--- a/include/nw4r/snd/snd_Sound3DManager.h
+++ b/include/nw4r/snd/snd_Sound3DManager.h
@@ -32,18 +32,14 @@ public:
Sound3DManager();
- virtual void detail_Update(
- SoundParam *pParam, u32 id, detail::BasicSound *pSound, const void *pArg,
- u32 flags
- ); // at 0x8
+ virtual void detail_UpdateAmbientParam(const void*, u32, int, SoundAmbientParam*) override;
+ virtual int detail_GetAmbientPriority(const void*, u32) override;
+ virtual int detail_GetRequiredVoiceOutCount(const void*, u32) override;
- virtual void Update(SoundParam *pParam, u32 id, SoundHandle *pHandle, const void *pArg,
- u32 flags); // at 0x10
-
- virtual void *detail_AllocAmbientArg(u32 size); // at 0x14
+ virtual void *detail_AllocAmbientArg(u32 size) override;
virtual void detail_FreeAmbientArg(void *pArg,
- const detail::BasicSound *pSound); // at 0x18
+ const detail::BasicSound *pSound) override;
u32 GetRequiredMemSize(const SoundArchive *pArchive);
bool Setup(const SoundArchive *pArchive, void *pBuffer, u32 size);
@@ -64,8 +60,9 @@ public:
}
int GetBiquadFilterType() const {
- return biquadFilterType;
+ return mBiquadFilterType;
}
+ void SetBiquadFilterType(int type);
f32 GetField0x20() const {
return field_0x20;
@@ -75,6 +72,8 @@ public:
return field_0x24;
}
+ void SetEngine(Sound3DEngine *engine);
+
enum ParamDecayCurve {
DECAY_CURVE_NONE,
DECAY_CURVE_LOGARITHMIC,
@@ -88,7 +87,7 @@ private:
s32 mMaxPriorityReduction; // at 0x1C
f32 field_0x20; // at 0x20
f32 field_0x24; // at 0x24
- int biquadFilterType; // at 0x28
+ int mBiquadFilterType; // at 0x28
};
} // namespace snd
diff --git a/src/nw4r/snd/snd_BasicSound.cpp b/src/nw4r/snd/snd_BasicSound.cpp
index db6b61fc..d6e29c09 100644
--- a/src/nw4r/snd/snd_BasicSound.cpp
+++ b/src/nw4r/snd/snd_BasicSound.cpp
@@ -322,7 +322,7 @@ void BasicSound::Update()
for (int i = 0; i < mVoiceOutCount; i++)
ambientParam.voiceOutParam[i] = basicPlayer.GetVoiceOutParam(i);
- mAmbientInfo.paramUpdateCallback->at_0x0c(
+ mAmbientInfo.paramUpdateCallback->detail_UpdateAmbientParam(
mAmbientInfo.arg, mId, mVoiceOutCount, &ambientParam);
mAmbientParam.volume = ambientParam.volume;
@@ -519,7 +519,7 @@ void BasicSound::Shutdown()
if (mAmbientInfo.argAllocaterCallback)
{
- mAmbientInfo.argAllocaterCallback->at_0x10(mAmbientInfo.arg, this);
+ mAmbientInfo.argAllocaterCallback->detail_FreeAmbientArg(mAmbientInfo.arg, this);
mAmbientInfo.arg = nullptr;
}
@@ -691,7 +691,7 @@ void BasicSound::SetAmbientInfo(AmbientInfo const &ambientArgInfo)
NW4RAssertPointerNonnull_Line(1090, ambientArgInfo.argAllocaterCallback);
void *ambientArg =
- ambientArgInfo.argAllocaterCallback->at_0x0c(ambientArgInfo.argSize);
+ ambientArgInfo.argAllocaterCallback->detail_AllocAmbientArg(ambientArgInfo.argSize);
if (!ambientArg)
{
NW4RCheckMessage_Line(1093, ambientArg, "Failed to alloc AmbientArg.");
@@ -705,7 +705,7 @@ void BasicSound::SetAmbientInfo(AmbientInfo const &ambientArgInfo)
if (ambientArgInfo.paramUpdateCallback)
{
int voiceOutCount =
- mAmbientInfo.paramUpdateCallback->at_0x14(mAmbientInfo.arg, mId);
+ mAmbientInfo.paramUpdateCallback->detail_GetRequiredVoiceOutCount(mAmbientInfo.arg, mId);
if (voiceOutCount > 4)
voiceOutCount = 4;
@@ -720,7 +720,7 @@ int BasicSound::GetAmbientPriority(AmbientInfo const &ambientInfo, u32 soundId)
return PRIORITY_MIN;
int priority =
- ambientInfo.paramUpdateCallback->at_0x10(ambientInfo.arg, soundId);
+ ambientInfo.paramUpdateCallback->detail_GetAmbientPriority(ambientInfo.arg, soundId);
return priority;
}
diff --git a/src/nw4r/snd/snd_Sound3DManager.cpp b/src/nw4r/snd/snd_Sound3DManager.cpp
index ebd0771c..1c8172e7 100644
--- a/src/nw4r/snd/snd_Sound3DManager.cpp
+++ b/src/nw4r/snd/snd_Sound3DManager.cpp
@@ -15,30 +15,10 @@ namespace {
static Sound3DEngine sEngine;
-/**
- * Solves the linear equation:
- * a*x + b*y + c = d
- *
- * Where:
- * a = dFactor - cFactor
- * b = dAngle - cAngle
- * c = cAngle * cFactor
- * d = dAngle * dFactor
- */
-inline f32 SolveLinerFunction(f32 x, f32 dAngle, f32 cAngle, f32 dFactor,
- f32 cFactor) { // @typo
- if (dAngle == cAngle) {
- return (dFactor + cFactor) / 2;
- }
-
- f32 b = dAngle - cAngle;
-
- return x * (cFactor - dFactor) / b + (dAngle * dFactor - cAngle * cFactor) / b;
-}
-
} // namespace
-Sound3DManager::Sound3DManager() : mpEngine(&sEngine), mMaxPriorityReduction(32), field_0x20(0.9f), field_0x24(0.0f), biquadFilterType(0) {}
+Sound3DManager::Sound3DManager()
+ : mpEngine(&sEngine), mMaxPriorityReduction(32), field_0x20(0.9f), field_0x24(0.0f), mBiquadFilterType(0) {}
u32 Sound3DManager::GetRequiredMemSize(const SoundArchive *pArchive) {
u32 numParam = 0;
@@ -60,209 +40,35 @@ bool Sound3DManager::Setup(const SoundArchive *pArchive, void *pBuffer, u32 size
return true;
}
-void Sound3DManager::detail_Update(
- SoundParam *pParam, u32 id, detail::BasicSound *pSound, const void *pArg, u32 flags
-) {
- SoundHandle handle;
- if (pSound != NULL) {
- handle.detail_AttachSoundAsTempHandle(pSound);
- }
-
- Update(pParam, id, pSound != NULL ? &handle : NULL, pArg, flags);
+void Sound3DManager::SetEngine(Sound3DEngine *engine) {
+ mpEngine = engine;
}
-void Sound3DManager::Update(SoundParam *pParam, u32 id, SoundHandle *pHandle, const void *pArg, u32 flags) {
-#pragma unused(id)
-#pragma unused(pHandle)
-
- f32 angle;
- f32 panLR, panFR;
- f32 pan, surroundPan;
-#if 0
- const Sound3DActorParam* pActorParam =
- static_cast<const Sound3DActorParam*>(pArg);
-
- Sound3DListener* pListener = GetListener();
- if (pListener == NULL) {
- pParam->volume = 0.0f;
- return;
- }
-
- math::VEC3 relativePos;
- VEC3Transform(&relativePos, &pListener->GetMatrix(),
- &pActorParam->position);
-
- f32 distance = VEC3Len(&relativePos);
- f32 volume = 1.0f;
-
- if ((flags & (PARAM_UPDATE_VOLUME | PARAM_UPDATE_PRIORITY)) &&
- distance > pListener->GetMaxVolumeDistance()) {
-
- switch (pActorParam->soundParam.decayCurve) {
- case DECAY_CURVE_LOGARITHMIC: {
- f32 units = (distance - pListener->GetMaxVolumeDistance()) /
- pListener->GetUnitDistance();
-
- volume =
- std::pow(pActorParam->soundParam.decayRatio / 256.0f, units);
- break;
- }
-
- case DECAY_CURVE_LINEAR: {
- f32 units = (distance - pListener->GetMaxVolumeDistance()) /
- pListener->GetUnitDistance() *
- pActorParam->soundParam.decayRatio;
-
- units = units / 256.0f;
- volume = ut::Max(0.0f, 1.0f - units);
- break;
- }
- }
- }
-
- if ((flags & PARAM_UPDATE_VOLUME) &&
- !(pActorParam->soundParam.flags & PARAM_UPDATE_VOLUME)) {
-
- pParam->volume = volume;
- }
-
- if (flags & (PARAM_UPDATE_PAN | PARAM_UPDATE_SURROUND_PAN)) {
- math::VEC3 adjustedPos;
-
- if (0.0f == distance) {
- adjustedPos.z = 0.0f;
- adjustedPos.y = 0.0f;
- adjustedPos.x = 0.0f;
- } else {
- math::VEC3 relativeXZ(relativePos.x, 0.0f, relativePos.z);
-
- f32 distanceXZ = VEC3Len(&relativeXZ);
- if (distanceXZ > pListener->GetInteriorSize()) {
- relativeXZ.x *= pListener->GetInteriorSize() / distanceXZ;
- relativeXZ.z *= pListener->GetInteriorSize() / distanceXZ;
- }
-
- f32 ratioXZ = VEC3Len(&relativeXZ);
- adjustedPos.x = relativePos.x * ratioXZ / distance;
- adjustedPos.y = 0.0f;
- adjustedPos.z = relativePos.z * ratioXZ / distance;
- }
-
- angle = atan2(adjustedPos.x, -adjustedPos.z);
- f32 distanceNrm = VEC3Len(&adjustedPos) / pListener->GetInteriorSize();
-
- switch (detail::AxManager::GetInstance().GetOutputMode()) {
- case OUTPUT_MODE_SURROUND:
- case OUTPUT_MODE_DPL2: {
- static f32 angleRearLeft = -mRearSpeakerAngleDpl2;
- static f32 angleFrontLeft = -mFrontSpeakerAngleDpl2;
- static f32 angleFrontRight = mFrontSpeakerAngleDpl2;
- static f32 angleRearRight = mRearSpeakerAngleDpl2;
-
- // clang-format off
- if (angle < angleRearLeft) {
- panLR = SolveLinerFunction(angle, -NW4R_MATH_PI, angleRearLeft, -1.0f, 0.0f);
- panFR = 1.0f;
- } else if (angle < -NW4R_MATH_PI / 2) {
- panLR = -1.0f;
- panFR = SolveLinerFunction(angle, angleRearLeft, -NW4R_MATH_PI / 2, 0.0f, 1.0f);
- } else if (angle < angleFrontLeft) {
- panLR = -1.0f;
- panFR = SolveLinerFunction(angle, -NW4R_MATH_PI / 2, angleFrontLeft, -1.0f, 0.0f);
- } else if (angle < angleFrontRight) {
- panLR = SolveLinerFunction(angle, angleFrontLeft, angleFrontRight, 1.0f, -1.0f);
- panFR = -1.0f;
- } else if (angle < NW4R_MATH_PI / 2) {
- panLR = 1.0f;
- panFR = SolveLinerFunction(angle, angleFrontRight, NW4R_MATH_PI / 2, 0.0f, -1.0f);
- } else if (angle < angleRearRight) {
- panLR = 1.0f;
- panFR = SolveLinerFunction(angle, NW4R_MATH_PI / 2, angleRearRight, 1.0f, 0.0f);
- } else {
- panLR = SolveLinerFunction(angle, angleRearRight, NW4R_MATH_PI, 0.0f, 1.0f);
- panFR = 1.0f;
- }
- // clang-format on
-
- f32 cosAvg = (std::cosf(mFrontSpeakerAngleDpl2) +
- std::cosf(mRearSpeakerAngleDpl2)) /
- 2.0f;
-
- f32 rearFactor =
- cosAvg / (cosAvg + -std::cosf(mRearSpeakerAngleDpl2));
-
- panLR *= mPanRange;
- panFR *= mPanRange;
-
- pan = panLR * distanceNrm;
-
- surroundPan =
- mInitPan + (1.0f + (panFR * distanceNrm +
- rearFactor * (1.0f - distanceNrm)));
- break;
- }
-
- case OUTPUT_MODE_STEREO: {
- static f32 angleRearLeft = -NW4R_MATH_PI + mSpeakerAngleStereo;
- static f32 angleFrontLeft = -mSpeakerAngleStereo;
- static f32 angleFrontRight = mSpeakerAngleStereo;
- static f32 angleRearRight = NW4R_MATH_PI - mSpeakerAngleStereo;
-
- // clang-format off
- if (angle < angleRearLeft) {
- panLR = SolveLinerFunction(angle, -NW4R_MATH_PI, angleRearLeft, -1.0f, 0.0f);
- panFR = 1.0f;
- } else if (angle < angleFrontLeft) {
- panLR = -1.0f;
- panFR = SolveLinerFunction(angle, angleRearLeft, angleFrontLeft, -1.0f, 1.0f);
- } else if (angle < angleFrontRight) {
- panLR = SolveLinerFunction(angle, angleFrontLeft, angleFrontRight, 1.0f, -1.0f);
- panFR = -1.0f;
- } else if (angle < angleRearRight) {
- panLR = 1.0f;
- panFR = SolveLinerFunction(angle, angleFrontRight, angleRearRight, 1.0f, -1.0f);
- } else {
- panLR = SolveLinerFunction(angle, angleRearRight, NW4R_MATH_PI, 0.0f, 1.0f);
- panFR = 1.0f;
- }
- // clang-format on
-
- panLR *= mPanRange;
- panFR *= mPanRange;
-
- surroundPan = 1.0f + panFR * distanceNrm;
- pan = panLR * distanceNrm;
- break;
- }
-
- case OUTPUT_MODE_MONO:
- default: {
- pan = 0.0f;
- surroundPan = 0.0f;
- break;
- }
- }
- }
-
- if ((flags & PARAM_UPDATE_PAN) &&
- !(pActorParam->soundParam.flags & PARAM_UPDATE_PAN)) {
-
- pParam->pan = pan;
+void Sound3DManager::detail_UpdateAmbientParam(
+ const void *param, u32 unused1, int unused2, SoundAmbientParam *ambientParam
+) {
+ const Sound3DParam *p = static_cast<const Sound3DParam *>(param);
+ if (mpEngine != NULL) {
+ mpEngine->UpdateAmbientParam(this, p, unused1, unused2, ambientParam);
}
+}
- if ((flags & PARAM_UPDATE_SURROUND_PAN) &&
- !(pActorParam->soundParam.flags & PARAM_UPDATE_SURROUND_PAN)) {
-
- pParam->surroundPan = surroundPan;
+int Sound3DManager::detail_GetAmbientPriority(const void *param, u32 arg) {
+ int result = 0;
+ if (mpEngine != NULL) {
+ const Sound3DParam *p = static_cast<const Sound3DParam *>(param);
+ result = mpEngine->GetAmbientPriority(this, p, arg);
}
+ return result;
+}
- if ((flags & PARAM_UPDATE_PRIORITY) &&
- !(pActorParam->soundParam.flags & PARAM_UPDATE_PRIORITY)) {
-
- pParam->priority =
- -static_cast<int>((1.0f - volume) * GetMaxPriorityReduction());
+int Sound3DManager::detail_GetRequiredVoiceOutCount(const void *param, u32 arg) {
+ int result = 1;
+ if (mpEngine != NULL) {
+ const Sound3DParam *p = static_cast<const Sound3DParam *>(param);
+ result = mpEngine->GetRequiredVoiceOutCount(this, p, arg);
}
-#endif
+ return result;
}
void *Sound3DManager::detail_AllocAmbientArg(u32 size) {
@@ -279,6 +85,10 @@ void Sound3DManager::detail_FreeAmbientArg(void *pArg, const detail::BasicSound
mParamPool.Free(static_cast<Sound3DParam *>(pArg));
}
+void Sound3DManager::SetBiquadFilterType(int type) {
+ mBiquadFilterType = type;
+}
+
Sound3DParam::Sound3DParam() {
field_0x18 = 0;
decayCurve = Sound3DManager::DECAY_CURVE_LOGARITHMIC;