summaryrefslogtreecommitdiff
path: root/src/nw4r
diff options
context:
space:
mode:
authorrobojumper <robojumper@gmail.com>2025-05-28 00:25:36 +0200
committerrobojumper <robojumper@gmail.com>2025-05-28 00:25:36 +0200
commit23fe65685a9662f1047726c8cf83ec757234b0ce (patch)
tree6749a299e3e841da31282f55d1e4e13867cad9b1 /src/nw4r
parente95b03506bf3e6419dd7beaf9870d6771246fbd0 (diff)
snd_Sound3DListener OK
Diffstat (limited to 'src/nw4r')
-rw-r--r--src/nw4r/snd/snd_Sound3DEngine.cpp35
-rw-r--r--src/nw4r/snd/snd_Sound3DListener.cpp61
-rw-r--r--src/nw4r/snd/snd_Sound3DManager.cpp26
3 files changed, 111 insertions, 11 deletions
diff --git a/src/nw4r/snd/snd_Sound3DEngine.cpp b/src/nw4r/snd/snd_Sound3DEngine.cpp
index e6ddfd4d..f398c5a4 100644
--- a/src/nw4r/snd/snd_Sound3DEngine.cpp
+++ b/src/nw4r/snd/snd_Sound3DEngine.cpp
@@ -1 +1,34 @@
-// #include "nw4r/snd/snd_Sound3DEngine.h"
+#include "nw4r/snd/snd_Sound3DEngine.h"
+
+namespace nw4r { namespace snd {
+
+Sound3DEngine::Sound3DEngine()
+ : mSpeakerAngleStereo(NW4R_MATH_PI / 4),
+ mFrontSpeakerAngleDpl2(NW4R_MATH_PI / 6),
+ mRearSpeakerAngleDpl2(2 * NW4R_MATH_PI / 3),
+ mInitPan(0.0f) {}
+
+void Sound3DEngine::UpdateAmbientParam(
+ const Sound3DManager *mgr, const Sound3DParam *pParam, u32, u32 flags, SoundAmbientParam *pAmbientParam
+) {
+ if (flags & 1)
+ pAmbientParam->volume = 0.0f;
+
+ if (flags & 8)
+ pAmbientParam->priority = - mgr->GetMaxPriorityReduction();
+}
+
+void Sound3DEngine::UpdateAmbientParam(const Sound3DManager* mgr, const Sound3DParam* param, u32, int, SoundAmbientParam*) {
+
+}
+
+void Sound3DEngine::GetAmbientPriority(const Sound3DManager*, const Sound3DParam*, u32) {
+
+}
+
+s32 Sound3DEngine::GetRequiredVoiceOutCount(const Sound3DManager*, const Sound3DParam*, u32) {
+ return 1;
+}
+
+
+}}
diff --git a/src/nw4r/snd/snd_Sound3DListener.cpp b/src/nw4r/snd/snd_Sound3DListener.cpp
index 9d6a9533..08d64440 100644
--- a/src/nw4r/snd/snd_Sound3DListener.cpp
+++ b/src/nw4r/snd/snd_Sound3DListener.cpp
@@ -1 +1,62 @@
#include "nw4r/snd/snd_Sound3DListener.h"
+
+namespace nw4r {
+namespace snd {
+
+Sound3DListener::Sound3DListener() {
+ mPosition.x = 0.0f;
+ mPosition.y = 0.0f;
+ mPosition.z = 0.0f;
+ mVelocity.x = 0.0f;
+ mVelocity.y = 0.0f;
+ mVelocity.z = 0.0f;
+ mInteriorSize = 1.0f;
+ mMaxVolumeDistance = 1.0f;
+ mUnitDistance = 1.0f;
+ field_0x54 = 0;
+ mSkipVelocityUpdate = 1;
+ mUnitBiquadFilterValue = 0.5f;
+ mUnitBiquadFilterMax = 1.0f;
+ field_0x64 = 0;
+ field_0x68 = 0;
+ math::MTX34Zero(&mMtx);
+}
+
+void Sound3DListener::SetMatrix(const math::MTX34 &mtx) {
+ math::VEC3 prevPosition = mPosition;
+
+ mPosition.x = -(mtx._00 * mtx._03 + mtx._10 * mtx._13 + mtx._20 * mtx._23);
+ mPosition.y = -(mtx._01 * mtx._03 + mtx._11 * mtx._13 + mtx._21 * mtx._23);
+ mPosition.z = -(mtx._02 * mtx._03 + mtx._12 * mtx._13 + mtx._22 * mtx._23);
+
+ if (mSkipVelocityUpdate) {
+ mMtx = mtx;
+ mSkipVelocityUpdate = 0;
+ } else {
+ mMtx = mtx;
+ VEC3Sub(&mVelocity, &mPosition, &prevPosition);
+ }
+}
+
+void Sound3DListener::SetInteriorSize(f32 size) {
+ mInteriorSize = size;
+}
+
+void Sound3DListener::SetMaxVolumeDistance(f32 distance) {
+ mMaxVolumeDistance = distance;
+}
+
+void Sound3DListener::SetUnitDistance(f32 distance) {
+ mUnitDistance = distance;
+}
+
+void Sound3DListener::SetUnitBiquadFilterValue(f32 value) {
+ mUnitBiquadFilterValue = value;
+}
+
+void Sound3DListener::SetUnitBiquadFilterMax(f32 value) {
+ mUnitBiquadFilterMax = value;
+}
+
+} // namespace snd
+} // namespace nw4r
diff --git a/src/nw4r/snd/snd_Sound3DManager.cpp b/src/nw4r/snd/snd_Sound3DManager.cpp
index 8a75b573..9fe22d6d 100644
--- a/src/nw4r/snd/snd_Sound3DManager.cpp
+++ b/src/nw4r/snd/snd_Sound3DManager.cpp
@@ -36,12 +36,7 @@ inline f32 SolveLinerFunction(f32 x, f32 dAngle, f32 cAngle, f32 dFactor,
} // namespace
Sound3DManager::Sound3DManager()
- : mMaxPriorityReduction(32),
- mSpeakerAngleStereo(NW4R_MATH_PI / 4),
- mFrontSpeakerAngleDpl2(NW4R_MATH_PI / 6),
- mRearSpeakerAngleDpl2(2 * NW4R_MATH_PI / 3),
- mInitPan(0.0f),
- mPanRange(0.9f) {}
+ {}
u32 Sound3DManager::GetRequiredMemSize(const SoundArchive* pArchive) {
u32 numParam = 0;
@@ -53,7 +48,7 @@ u32 Sound3DManager::GetRequiredMemSize(const SoundArchive* pArchive) {
numParam += playerInfo.waveSoundCount;
}
- return numParam * sizeof(Sound3DActorParam);
+ return numParam * sizeof(Sound3DParam);
}
bool Sound3DManager::Setup(const SoundArchive* pArchive, void* pBuffer,
@@ -83,7 +78,7 @@ void Sound3DManager::Update(SoundParam* pParam, u32 id, SoundHandle* pHandle,
f32 angle;
f32 panLR, panFR;
f32 pan, surroundPan;
-
+#if 0
const Sound3DActorParam* pActorParam =
static_cast<const Sound3DActorParam*>(pArg);
@@ -267,10 +262,11 @@ void Sound3DManager::Update(SoundParam* pParam, u32 id, SoundHandle* pHandle,
pParam->priority =
-static_cast<int>((1.0f - volume) * GetMaxPriorityReduction());
}
+#endif
}
void* Sound3DManager::detail_AllocAmbientArg(u32 size) {
- if (size != sizeof(Sound3DActorParam)) {
+ if (size != sizeof(Sound3DParam)) {
return NULL;
}
@@ -281,7 +277,17 @@ void Sound3DManager::detail_FreeAmbientArg(void* pArg,
const detail::BasicSound* pSound) {
#pragma unused(pSound)
- mParamPool.Free(static_cast<Sound3DActorParam*>(pArg));
+ mParamPool.Free(static_cast<Sound3DParam*>(pArg));
+}
+
+Sound3DParam::Sound3DParam()
+{
+ field_0x18 = 0;
+ field_0x1C = 1;
+ field_0x1D = 0x80;
+ field_0x1E = 0;
+ field_0x20 = 0;
+ field_0x24 = 0;
}
Sound3DManager::Sound3DActorParam::Sound3DActorParam() : userParam(-1) {