snd_Sound3DEngine OK

This commit is contained in:
robojumper
2025-05-28 01:18:53 +02:00
parent 23fe65685a
commit 7dde7fec51
9 changed files with 178 additions and 54 deletions
+44
View File
@@ -0,0 +1,44 @@
#ifndef NW4R_SND_SOUND_3D_CALCULATOR_H
#define NW4R_SND_SOUND_3D_CALCULATOR_H
#include "nw4r/snd/snd_Sound3DManager.h"
namespace nw4r {
namespace snd {
class Sound3DCalculator {
public:
struct CalcPanParam {
#if 0
f32 mSpeakerAngleStereo; // at 0x04
f32 mFrontSpeakerAngleDpl2; // at 0x08
f32 mRearSpeakerAngleDpl2; // at 0x0C
f32 mInitPan; // at 0x10
#endif
f32 field_0x00;
f32 field_0x04;
f32 field_0x08;
f32 field_0x0C;
CalcPanParam()
: field_0x00(NW4R_MATH_PI / 4),
field_0x04(NW4R_MATH_PI / 6),
field_0x08(2 * NW4R_MATH_PI / 3),
field_0x0C(0.0f) {}
};
static void
CalcVolumeAndPriority(const Sound3DManager &, const Sound3DListener &, const Sound3DParam &, float *, int *);
static void
CalcPan(const Sound3DManager &, const Sound3DListener &, const Sound3DParam &, const Sound3DCalculator::CalcPanParam &, float *pan, float *surroundPan);
static void CalcPitch(const Sound3DManager &, const Sound3DListener &, const Sound3DParam &, float *);
static void CalcBiquadFilterValue(const Sound3DManager &, const Sound3DListener &, const Sound3DParam &, float *);
static void CalcPanDpl2(const nw4r::math::VEC3 &, float, float, float, float, float, float, float *, float *);
static void CalcPanStereo(const nw4r::math::VEC3 &, float, float, float, float, float *, float *);
static void CalcAngleAndDistance(const nw4r::math::VEC3 &, float, float, float *, float *);
};
} // namespace snd
} // namespace nw4r
#endif
+3 -5
View File
@@ -4,6 +4,7 @@
#include "nw4r/math.h"
#include "nw4r/types_nw4r.h"
#include "nw4r/snd/snd_Sound3DManager.h"
#include "nw4r/snd/snd_Sound3DCalculator.h"
namespace nw4r {
@@ -17,15 +18,12 @@ public:
virtual ~Sound3DEngine() {}
virtual void UpdateAmbientParam(const Sound3DManager*, const Sound3DParam*, u32, int, SoundAmbientParam*);
virtual void GetAmbientPriority(const Sound3DManager*, const Sound3DParam*, u32);
virtual s32 GetAmbientPriority(const Sound3DManager*, const Sound3DParam*, u32);
virtual s32 GetRequiredVoiceOutCount(const Sound3DManager*, const Sound3DParam*, u32);
virtual void UpdateAmbientParam(const Sound3DManager*, const Sound3DParam*, u32, u32, SoundAmbientParam*);
private:
f32 mSpeakerAngleStereo; // at 0x04
f32 mFrontSpeakerAngleDpl2; // at 0x08
f32 mRearSpeakerAngleDpl2; // at 0x0C
f32 mInitPan; // at 0x10
Sound3DCalculator::CalcPanParam mPanParam; // at 0x04
};
} // namespace snd
+2 -2
View File
@@ -2,6 +2,7 @@
#define NW4R_SND_SOUND_3D_LISTENER_H
#include "common.h"
#include "nw4r/types_nw4r.h"
#include "nw4r/ut/ut_LinkList.h"
#include "nw4r/math.h"
@@ -47,8 +48,7 @@ private:
u8 mSkipVelocityUpdate; // at 0x58
f32 mUnitBiquadFilterValue; // at 0x5C
f32 mUnitBiquadFilterMax; // at 0x60
UNKWORD field_0x64; // at 0x64
UNKWORD field_0x68; // at 0x68
ut::LinkListNode mNode; // at 0x64
};
} // namespace snd
+20 -8
View File
@@ -1,17 +1,17 @@
#ifndef NW4R_SND_SOUND_3D_MANAGER_H
#define NW4R_SND_SOUND_3D_MANAGER_H
#include "nw4r/math.h"
#include "nw4r/snd/snd_BasicSound.h"
#include "nw4r/snd/snd_InstancePool.h"
#include "nw4r/snd/snd_SoundArchive.h"
#include "nw4r/types_nw4r.h"
#include "nw4r/ut/ut_LinkList.h"
#include "nw4r/math.h"
namespace nw4r {
namespace snd {
struct Sound3DParam
{
struct Sound3DParam {
/* 0x00 */ u8 _0x00[0x18];
/* 0x18 */ UNKWORD field_0x18;
/* 0x1C */ u8 field_0x1C;
@@ -35,6 +35,8 @@ public:
};
public:
typedef ut::LinkList<Sound3DListener, 0x64> ListenerList;
Sound3DManager();
virtual void detail_Update(
@@ -53,8 +55,12 @@ public:
u32 GetRequiredMemSize(const SoundArchive *pArchive);
bool Setup(const SoundArchive *pArchive, void *pBuffer, u32 size);
Sound3DListener *GetListener() const {
return mListener;
const ListenerList &GetListenerList() const {
return mListenerList;
}
ListenerList &GetListenerList() {
return mListenerList;
}
int GetMaxPriorityReduction() const {
@@ -64,6 +70,10 @@ public:
mMaxPriorityReduction = max;
}
int GetBiquadFilterType() const {
return biquadFilterType;
}
private:
enum ParamDecayCurve {
DECAY_CURVE_NONE,
@@ -73,9 +83,11 @@ private:
private:
detail::InstancePool<Sound3DParam> mParamPool; // at 0x8
Sound3DListener *mListener; // at 0xC
u8 _0x10[0x1C - 0x10];
s32 mMaxPriorityReduction; // at 0x1C
ListenerList mListenerList; // at 0x0C
u8 _0x18[0x1C - 0x18];
s32 mMaxPriorityReduction; // at 0x1C
u8 _0x1C[0x28 - 0x20];
int biquadFilterType; // at 0x28
};
} // namespace snd