From c283825ba66099ea2a6885b9bb557130229d36e0 Mon Sep 17 00:00:00 2001 From: robojumper Date: Tue, 27 May 2025 00:57:43 +0200 Subject: [PATCH] snd_BasicSound OK --- config/SOUE01/splits.txt | 3 ++ config/SOUE01/symbols.txt | 24 ++++++------ configure.py | 2 +- include/nw4r/snd/snd_BasicSound.h | 18 +++++++-- include/nw4r/snd/snd_MoveValue.h | 4 ++ src/nw4r/snd/snd_BasicSound.cpp | 63 +++++++++++++++++++++++++++++-- 6 files changed, 93 insertions(+), 21 deletions(-) diff --git a/config/SOUE01/splits.txt b/config/SOUE01/splits.txt index 587515b8..5887703a 100644 --- a/config/SOUE01/splits.txt +++ b/config/SOUE01/splits.txt @@ -2927,6 +2927,9 @@ nw4r/snd/snd_BasicPlayer.cpp: nw4r/snd/snd_BasicSound.cpp: .text start:0x80468B50 end:0x8046A36C align:16 .ctors start:0x804DB95C end:0x804DB960 + .data start:0x8056DB60 end:0x8056DB98 + .sbss start:0x80576678 end:0x80576680 + .sdata2 start:0x8057EF88 end:0x8057EF98 nw4r/snd/snd_BiquadFilterPreset.cpp: .text start:0x8046A370 end:0x8046A7B0 align:16 diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index b0c1735c..508ef954 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -25139,18 +25139,18 @@ AttachSoundActor__Q44nw4r3snd6detail10BasicSoundFPQ34nw4r3snd10SoundActor = .tex DetachSoundActor__Q44nw4r3snd6detail10BasicSoundFPQ34nw4r3snd10SoundActor = .text:0x80469EB0; // type:function size:0xC AttachExternalSoundPlayer__Q44nw4r3snd6detail10BasicSoundFPQ44nw4r3snd6detail19ExternalSoundPlayer = .text:0x80469EC0; // type:function size:0x8 DetachExternalSoundPlayer__Q44nw4r3snd6detail10BasicSoundFPQ44nw4r3snd6detail19ExternalSoundPlayer = .text:0x80469ED0; // type:function size:0xC -FUN_80469ee0 = .text:0x80469EE0; // type:function size:0x24 +GetRemainingFadeFrames__Q44nw4r3snd6detail10BasicSoundCFv = .text:0x80469EE0; // type:function size:0x24 GetVoiceOutCount__Q44nw4r3snd6detail10BasicSoundCFv = .text:0x80469F10; // type:function size:0x8 SetPlayerPriority__Q44nw4r3snd6detail10BasicSoundFi = .text:0x80469F20; // type:function size:0x58 -OnUpdatePlayerPriority__Q44nw4r3snd6detail10BasicSoundFv = .text:0x80469F80; // type:function size:0x4 +OnUpdatePlayerPriority__Q44nw4r3snd6detail10BasicSoundFv = .text:0x80469F80; // type:function size:0x4 scope:weak SetInitialVolume__Q44nw4r3snd6detail10BasicSoundFf = .text:0x80469F90; // type:function size:0x18 SetVolume__Q44nw4r3snd6detail10BasicSoundFfi = .text:0x80469FB0; // type:function size:0x90 SetPitch__Q44nw4r3snd6detail10BasicSoundFf = .text:0x8046A040; // type:function size:0x8 SetPan__Q44nw4r3snd6detail10BasicSoundFf = .text:0x8046A050; // type:function size:0x8 -FUN_8046a060 = .text:0x8046A060; // type:function size:0x8 -FUN_8046a070 = .text:0x8046A070; // type:function size:0x8 -FUN_8046a080 = .text:0x8046A080; // type:function size:0x8 -SetRemoteOutVolume__Q44nw4r3snd6detail10BasicSoundFif = .text:0x8046A090; // type:function size:0x10 +SetSurroundPan__Q44nw4r3snd6detail10BasicSoundFf = .text:0x8046A060; // type:function size:0x8 +SetLpfFreq__Q44nw4r3snd6detail10BasicSoundFf = .text:0x8046A070; // type:function size:0x8 +SetOutputLineFlag__Q44nw4r3snd6detail10BasicSoundFi = .text:0x8046A080; // type:function size:0x8 +SetFxSend__Q44nw4r3snd6detail10BasicSoundFQ34nw4r3snd6AuxBusf = .text:0x8046A090; // type:function size:0x10 SetRemoteFilter__Q44nw4r3snd6detail10BasicSoundFi = .text:0x8046A0A0; // type:function size:0x40 SetPanMode__Q44nw4r3snd6detail10BasicSoundFQ34nw4r3snd7PanMode = .text:0x8046A0E0; // type:function size:0x3C SetPanCurve__Q44nw4r3snd6detail10BasicSoundFQ34nw4r3snd8PanCurve = .text:0x8046A120; // type:function size:0x3C @@ -25161,7 +25161,7 @@ IsAttachedTempGeneralHandle__Q44nw4r3snd6detail10BasicSoundFv = .text:0x8046A290 DetachGeneralHandle__Q44nw4r3snd6detail10BasicSoundFv = .text:0x8046A2B0; // type:function size:0x8 DetachTempGeneralHandle__Q44nw4r3snd6detail10BasicSoundFv = .text:0x8046A2C0; // type:function size:0x8 SetId__Q44nw4r3snd6detail10BasicSoundFUl = .text:0x8046A2D0; // type:function size:0x40 -__dt__Q44nw4r3snd6detail10BasicSoundFv = .text:0x8046A310; // type:function size:0x40 +__dt__Q44nw4r3snd6detail10BasicSoundFv = .text:0x8046A310; // type:function size:0x40 scope:weak GetRuntimeTypeInfo__Q44nw4r3snd6detail10BasicSoundCFv = .text:0x8046A350; // type:function size:0x8 scope:weak __sinit_\snd_BasicSound_cpp = .text:0x8046A360; // type:function size:0xC scope:local GetCoef__Q44nw4r3snd6detail15BiquadFilterLpfCFifPQ44nw4r3snd20BiquadFilterCallback10BiquadCoef = .text:0x8046A370; // type:function size:0x88 @@ -38583,7 +38583,7 @@ __vt__Q34nw4r3g3d6ScnMdl = .data:0x8056DA70; // type:object size:0x48 @10666 = .data:0x8056DAB8; // type:object size:0x46 scope:local data:string __vt__Q34nw4r3g3d7ScnProc = .data:0x8056DB00; // type:object size:0x34 __vt__Q44nw4r3snd6detail11BasicPlayer = .data:0x8056DB38; // type:object size:0x24 scope:weak -lbl_8056DB60 = .data:0x8056DB60; // type:object size:0x38 +__vt__Q44nw4r3snd6detail10BasicSound = .data:0x8056DB60; // type:object size:0x38 __vt__Q44nw4r3snd6detail19BiquadFilterBpf2048 = .data:0x8056DB98; // type:object size:0x10 __vt__Q44nw4r3snd6detail19BiquadFilterBpf1024 = .data:0x8056DBA8; // type:object size:0x10 __vt__Q44nw4r3snd6detail18BiquadFilterBpf512 = .data:0x8056DBB8; // type:object size:0x10 @@ -42423,7 +42423,7 @@ sBiquadFilterBpf2048__Q44nw4r3snd6detail9AxManager = .sbss:0x80576660; // type:o @GUARD@GetInstance__Q44nw4r3snd6detail14AxVoiceManagerFv@instance = .sbss:0x80576668; // type:object size:0x1 scope:weak data:byte mCurrentFx__Q44nw4r3snd6detail8AxfxImpl = .sbss:0x80576670; // type:object size:0x4 data:4byte mAllocatedSize__Q44nw4r3snd6detail8AxfxImpl = .sbss:0x80576674; // type:object size:0x4 data:4byte -typeInfo__Q44nw4r3snd6detail10BasicSound = .sbss:0x80576678; // type:object size:0x8 data:4byte +typeInfo__Q44nw4r3snd6detail10BasicSound = .sbss:0x80576678; // type:object size:0x4 data:4byte @GUARD@GetInstance__Q44nw4r3snd6detail14ChannelManagerFv@instance = .sbss:0x80576680; // type:object size:0x1 scope:weak data:byte @GUARD@GetInstance__Q44nw4r3snd6detail22DisposeCallbackManagerFv@instance = .sbss:0x80576688; // type:object size:0x1 scope:weak data:byte mPrintVarEnabledFlag__Q44nw4r3snd6detail9MmlParser = .sbss:0x80576690; // type:object size:0x1 data:byte @@ -49662,9 +49662,9 @@ lbl_8057EF54 = .sdata2:0x8057EF54; // type:object size:0x4 align:4 data:float @1860 = .sdata2:0x8057EF78; // type:object size:0x4 scope:local align:4 data:float @608 = .sdata2:0x8057EF80; // type:object size:0x4 scope:local align:4 data:float @609 = .sdata2:0x8057EF84; // type:object size:0x4 scope:local align:4 data:float -lbl_8057EF88 = .sdata2:0x8057EF88; // type:object size:0x4 align:4 data:float -lbl_8057EF8C = .sdata2:0x8057EF8C; // type:object size:0x4 align:4 data:float -lbl_8057EF90 = .sdata2:0x8057EF90; // type:object size:0x8 align:8 data:double +@1976 = .sdata2:0x8057EF88; // type:object size:0x4 scope:local align:4 data:float +@1977 = .sdata2:0x8057EF8C; // type:object size:0x4 scope:local align:4 data:float +@2034 = .sdata2:0x8057EF90; // type:object size:0x8 scope:local align:8 data:double @212 = .sdata2:0x8057EF98; // type:object size:0x8 scope:local align:8 data:double @247 = .sdata2:0x8057EFA0; // type:object size:0x4 scope:local align:4 data:float @2816 = .sdata2:0x8057EFA8; // type:object size:0x4 scope:local align:4 data:float diff --git a/configure.py b/configure.py index cadd2c42..86b595c0 100644 --- a/configure.py +++ b/configure.py @@ -1020,7 +1020,7 @@ config.libs = [ Object(Matching, "nw4r/snd/snd_Bank.cpp"), Object(Matching, "nw4r/snd/snd_BankFile.cpp"), Object(Matching, "nw4r/snd/snd_BasicPlayer.cpp"), - Object(NonMatching, "nw4r/snd/snd_BasicSound.cpp"), + Object(Matching, "nw4r/snd/snd_BasicSound.cpp"), Object(Matching, "nw4r/snd/snd_BiquadFilterPreset.cpp"), Object(Matching, "nw4r/snd/snd_Channel.cpp"), Object(Matching, "nw4r/snd/snd_DisposeCallbackManager.cpp"), diff --git a/include/nw4r/snd/snd_BasicSound.h b/include/nw4r/snd/snd_BasicSound.h index c1fe052f..49d9b3a8 100644 --- a/include/nw4r/snd/snd_BasicSound.h +++ b/include/nw4r/snd/snd_BasicSound.h @@ -44,7 +44,8 @@ namespace nw4r { namespace snd lpf (0.0f), biquadFilterValue (0.0f), biquadFilterType (0), - priority (0) + priority (0), + field_0x24 (0) { } @@ -59,6 +60,7 @@ namespace nw4r { namespace snd f32 biquadFilterValue; // size 0x04, offset 0x18 int biquadFilterType; // size 0x04, offset 0x1c int priority; // size 0x04, offset 0x20 + UNKWORD field_0x24; }; // size 0x24 // [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x27514 @@ -76,7 +78,8 @@ namespace nw4r { namespace snd lpf (0.0f), biquadFilterValue (0.0f), biquadFilterType (0), - priority (0) + priority (0), + field_0x24 (0) { } @@ -91,6 +94,7 @@ namespace nw4r { namespace snd f32 biquadFilterValue; // size 0x04, offset 0x18 int biquadFilterType; // size 0x04, offset 0x1c int priority; // size 0x04, offset 0x20 + UNKWORD field_0x24; VoiceOutParam voiceOutParam[4]; // size 0x60, offset 0x24 }; // size 0x84 @@ -244,9 +248,10 @@ namespace nw4r { namespace snd { namespace detail void StartPrepared(); void Update(); void Pause(bool flag, int fadeFrames); - bool IsPaused() const; + bool IsPause() const; void Stop(int fadeFrames); void SetAutoStopCounter(int count); + void FadeIn(int fadeFrames); u32 GetId() const { return mId; } PlayerHeap *GetPlayerHeap() { return mPlayerHeap; } @@ -257,12 +262,16 @@ namespace nw4r { namespace snd { namespace detail void SetInitialVolume(f32 volume); void SetVolume(f32 volume, int frames); void SetPitch(f32 pitch); + void SetPan(f32 pan); + void SetSurroundPan(f32 pan); + void SetLpfFreq(f32 freq); void SetFxSend(AuxBus bus, f32 send); void SetRemoteFilter(int filter); void SetPanMode(PanMode mode); void SetPanCurve(PanCurve curve); void SetAmbientInfo(AmbientInfo const &ambientArgInfo); void SetId(u32 id); + void SetOutputLineFlag(int flag); void AttachPlayerHeap(PlayerHeap *heap); void AttachSoundPlayer(SoundPlayer *player); @@ -279,6 +288,8 @@ namespace nw4r { namespace snd { namespace detail void DetachGeneralHandle(); void DetachTempGeneralHandle(); + int GetRemainingFadeFrames() const; + int CalcCurrentPlayerPriority() const { return ut::Clamp(mPriority + mAmbientParam.priority, PRIORITY_MIN, @@ -308,7 +319,6 @@ namespace nw4r { namespace snd { namespace detail ExternalSoundPlayer *mExtSoundPlayer; // size 0x04, offset 0x18 AmbientInfo mAmbientInfo; // size 0x14, offset 0x1c SoundParam mAmbientParam; // size 0x24, offset 0x30 - UNKWORD field_0x54; SoundActorParam mActorParam; // size 0x0c, offset 0x54 MoveValue mFadeVolume; // size 0x10, offset 0x60 MoveValue mPauseFadeVolume; // size 0x10, offset 0x70 diff --git a/include/nw4r/snd/snd_MoveValue.h b/include/nw4r/snd/snd_MoveValue.h index 3d2def72..31592473 100644 --- a/include/nw4r/snd/snd_MoveValue.h +++ b/include/nw4r/snd/snd_MoveValue.h @@ -41,6 +41,10 @@ namespace nw4r { namespace snd { namespace detail bool IsFinished() const { return mCounter >= mFrame; } + TTime GetRemainingTime() const { + return IsFinished() ? 0 : mFrame - mCounter; + } + void InitValue(TValue value) { mOrigin = value; diff --git a/src/nw4r/snd/snd_BasicSound.cpp b/src/nw4r/snd/snd_BasicSound.cpp index 96014df5..db6b61fc 100644 --- a/src/nw4r/snd/snd_BasicSound.cpp +++ b/src/nw4r/snd/snd_BasicSound.cpp @@ -54,7 +54,6 @@ BasicSound::BasicSound(int priority, int ambientPriority) : mGeneralHandle (nullptr), mTempGeneralHandle (nullptr), mSoundPlayer (nullptr), - field_0x54 (0), mSoundActor (nullptr), mExtSoundPlayer (nullptr), mId (INVALID_ID) @@ -222,7 +221,16 @@ void BasicSound::SetAutoStopCounter(int count) mAutoStopFlag = count > 0; } -bool BasicSound::IsPaused() const +void BasicSound::FadeIn(int fadeFrames) +{ + if (!mFadeOutFlag) + { + int duration = fadeFrames * (1.0f - mFadeVolume.GetValue()); + mFadeVolume.SetTarget(1.0f, duration); + } +} + +bool BasicSound::IsPause() const { return mPauseState == PAUSE_STATE_PAUSING || mPauseState == PAUSE_STATE_PAUSED; @@ -293,6 +301,27 @@ void BasicSound::Update() { SoundAmbientParam ambientParam; + if (mUpdateCounter != 0) + { + ambientParam.volume = mAmbientParam.volume; + ambientParam.pitch = mAmbientParam.pitch; + ambientParam.pan = mAmbientParam.pan; + ambientParam.surroundPan = mAmbientParam.surroundPan; + ambientParam.fxSend = mAmbientParam.fxSend; + ambientParam.lpf = mAmbientParam.lpf; + ambientParam.biquadFilterValue = mAmbientParam.biquadFilterValue; + ambientParam.biquadFilterType = mAmbientParam.biquadFilterType; + ambientParam.priority = mAmbientParam.priority; + ambientParam.field_0x24 = mAmbientParam.field_0x24; + } + else + { + ambientParam.field_0x24 = 0; + } + + for (int i = 0; i < mVoiceOutCount; i++) + ambientParam.voiceOutParam[i] = basicPlayer.GetVoiceOutParam(i); + mAmbientInfo.paramUpdateCallback->at_0x0c( mAmbientInfo.arg, mId, mVoiceOutCount, &ambientParam); @@ -305,10 +334,11 @@ void BasicSound::Update() mAmbientParam.biquadFilterValue = ambientParam.biquadFilterValue; mAmbientParam.biquadFilterType = ambientParam.biquadFilterType; mAmbientParam.priority = ambientParam.priority; + mAmbientParam.field_0x24 = ambientParam.field_0x24; for (int i = 0; i < mVoiceOutCount; i++) basicPlayer.SetVoiceOutParam(i, ambientParam.voiceOutParam[i]); - } + } if (mSoundActor) mActorParam = mSoundActor->detail_GetActorParam(); @@ -562,6 +592,11 @@ void BasicSound::DetachExternalSoundPlayer(ExternalSoundPlayer *extPlayer) mExtSoundPlayer = nullptr; } +int BasicSound::GetRemainingFadeFrames() const +{ + return mPauseFadeVolume.GetRemainingTime(); +} + int BasicSound::GetVoiceOutCount() const { return mVoiceOutCount; @@ -608,12 +643,32 @@ void BasicSound::SetPitch(f32 pitch) mExtPitch = pitch; } +void BasicSound::SetPan(f32 pan) +{ + mExtPan = pan; +} + +void BasicSound::SetSurroundPan(f32 pan) +{ + mExtSurroundPan = pan; +} + +void BasicSound::SetLpfFreq(f32 freq) +{ + mLpfFreq = freq; +} + +void BasicSound::SetOutputLineFlag(int flag) +{ + mOutputLineFlag = flag; +} + void BasicSound::SetFxSend(AuxBus bus, f32 send) { // specifically not the source variant NW4RAssertHeaderClampedLValue_Line(979, bus, AUX_A, AUX_BUS_NUM); - GetBasicPlayer().SetFxSend(bus, send); + mFxSend[bus] = send; } void BasicSound::SetRemoteFilter(int filter)