From e10ce717296af0540745da9e9f0cc2e86f920e7c Mon Sep 17 00:00:00 2001 From: robojumper Date: Mon, 26 May 2025 01:24:28 +0200 Subject: [PATCH] Misc progress --- config/SOUE01/splits.txt | 3 +++ config/SOUE01/symbols.txt | 3 +-- include/nw4r/snd/snd_BasicSound.h | 4 ++-- include/nw4r/snd/snd_Channel.h | 3 ++- include/nw4r/snd/snd_SoundPlayer.h | 1 + include/nw4r/snd/snd_Voice.h | 1 + src/nw4r/snd/snd_AxVoice.cpp | 4 ++-- src/nw4r/snd/snd_BasicSound.cpp | 37 +++++++++++++++++++++++------- src/nw4r/snd/snd_Channel.cpp | 13 +++++++++++ src/nw4r/snd/snd_SeqPlayer.cpp | 4 ++++ src/nw4r/snd/snd_SoundThread.cpp | 2 +- 11 files changed, 59 insertions(+), 16 deletions(-) diff --git a/config/SOUE01/splits.txt b/config/SOUE01/splits.txt index 51606d7b..015756ec 100644 --- a/config/SOUE01/splits.txt +++ b/config/SOUE01/splits.txt @@ -3002,6 +3002,9 @@ nw4r/snd/snd_SeqFile.cpp: nw4r/snd/snd_SeqPlayer.cpp: .text start:0x80471020 end:0x804727F8 align:16 + .data start:0x8056E024 end:0x8056E088 + .sdata2 start:0x8057F068 end:0x8057F080 + .bss start:0x806596E8 end:0x80659708 nw4r/snd/snd_SeqSound.cpp: .text start:0x80472800 end:0x8047316C align:16 diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index 8265b693..794bff2d 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -25155,8 +25155,7 @@ SetRemoteFilter__Q44nw4r3snd6detail10BasicSoundFi = .text:0x8046A0A0; // type:fu SetPanMode__Q44nw4r3snd6detail10BasicSoundFQ34nw4r3snd7PanMode = .text:0x8046A0E0; // type:function size:0x3C SetPanCurve__Q44nw4r3snd6detail10BasicSoundFQ34nw4r3snd8PanCurve = .text:0x8046A120; // type:function size:0x3C SetAmbientInfo__Q44nw4r3snd6detail10BasicSoundFRCQ54nw4r3snd6detail10BasicSound11AmbientInfo = .text:0x8046A160; // type:function size:0xC4 -GetAmbientPriority__Q44nw4r3snd6detail10BasicSoundFRCQ54nw4r3snd6detail10BasicSound11AmbientInfoUl = .text:0x8046A230; // type:function size:0x34 -fn_8046A264 = .text:0x8046A264; // type:function size:0x4 +GetAmbientPriority__Q44nw4r3snd6detail10BasicSoundFRCQ54nw4r3snd6detail10BasicSound11AmbientInfoUl = .text:0x8046A230; // type:function size:0x38 IsAttachedGeneralHandle__Q44nw4r3snd6detail10BasicSoundFv = .text:0x8046A270; // type:function size:0x14 IsAttachedTempGeneralHandle__Q44nw4r3snd6detail10BasicSoundFv = .text:0x8046A290; // type:function size:0x14 DetachGeneralHandle__Q44nw4r3snd6detail10BasicSoundFv = .text:0x8046A2B0; // type:function size:0x8 diff --git a/include/nw4r/snd/snd_BasicSound.h b/include/nw4r/snd/snd_BasicSound.h index eca939cd..e57e704a 100644 --- a/include/nw4r/snd/snd_BasicSound.h +++ b/include/nw4r/snd/snd_BasicSound.h @@ -308,6 +308,7 @@ 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 @@ -336,8 +337,7 @@ namespace nw4r { namespace snd { namespace detail f32 mMainOutVolume; // size 0x04, offset 0xc8 f32 mMainSend; // size 0x04, offset 0xcc f32 mFxSend[AUX_BUS_NUM]; // size 0x0c, offset 0xd0 - // NOTE: Name is not from DWARF; derived from usage and other nearby names - u32 mPauseNestCounter; // size 0x04, offset 0xdc + f32 mRemoteOutVolume[4]; // size 0x10, offset 0xdc public: ut::LinkListNode mPriorityLink; // size 0x08, offset 0xe0 ut::LinkListNode mSoundPlayerPlayLink; // size 0x08, offset 0xe8 diff --git a/include/nw4r/snd/snd_Channel.h b/include/nw4r/snd/snd_Channel.h index 636d3a7c..9f75f540 100644 --- a/include/nw4r/snd/snd_Channel.h +++ b/include/nw4r/snd/snd_Channel.h @@ -63,7 +63,7 @@ namespace nw4r { namespace snd { namespace detail ChannelCallbackStatus status, u32 userData); - typedef ut::LinkList LinkList; + typedef ut::LinkList LinkList; // methods public: @@ -208,6 +208,7 @@ namespace nw4r { namespace snd { namespace detail f32 mMainOutVolume; // size 0x04, offset 0x5c f32 mMainSend; // size 0x04, offset 0x60 f32 mFxSend[AUX_BUS_NUM]; // size 0x0c, offset 0x64 + f32 mRemoteOutVolume[4]; f32 mUserPitch; // size 0x04, offset 0x70 f32 mSweepPitch; // size 0x04, offset 0x74 s32 mSweepCounter; // size 0x04, offset 0x78 diff --git a/include/nw4r/snd/snd_SoundPlayer.h b/include/nw4r/snd/snd_SoundPlayer.h index 33dd9fa3..45da6493 100644 --- a/include/nw4r/snd/snd_SoundPlayer.h +++ b/include/nw4r/snd/snd_SoundPlayer.h @@ -39,6 +39,7 @@ namespace nw4r { namespace snd f32 GetFxSend(int index) const { return mFxSend[index]; } void SetPlayableSoundCount(int count); + f32 GetRemoteOutVolume(int remote) const; int GetPlayingSoundCount() const { return mSoundList.GetSize(); } detail::BasicSound *GetLowestPrioritySound() diff --git a/include/nw4r/snd/snd_Voice.h b/include/nw4r/snd/snd_Voice.h index 32e6a690..0aee71a3 100644 --- a/include/nw4r/snd/snd_Voice.h +++ b/include/nw4r/snd/snd_Voice.h @@ -92,6 +92,7 @@ namespace nw4r { namespace snd { namespace detail void SetMainOutVolume(f32 volume); void SetMainSend(f32 send); void SetFxSend(AuxBus bus, f32 send); + void SetRemoteOutVolume(int remote, f32 volume); void SetPitch(f32 pitch); void SetVolume(f32 volume); void SetVeVolume(f32 targetVolume, f32 initVolume); diff --git a/src/nw4r/snd/snd_AxVoice.cpp b/src/nw4r/snd/snd_AxVoice.cpp index be050bd3..57e8adc4 100644 --- a/src/nw4r/snd/snd_AxVoice.cpp +++ b/src/nw4r/snd/snd_AxVoice.cpp @@ -921,10 +921,10 @@ void AxVoiceParamBlock::Sync() mVpb->pb.ve.currentDelta = -mPrevVeSetting.currentVolume / AX_SAMPLES_PER_FRAME; } - else if (nextVolume > 32767) + else if (nextVolume > 65535) { mVpb->pb.ve.currentDelta = - (32767 - mPrevVeSetting.currentVolume) / AX_SAMPLES_PER_FRAME; + (65535 - mPrevVeSetting.currentVolume) / AX_SAMPLES_PER_FRAME; } if (mVpb->pb.ve.currentDelta == 0 && mPrevVeSetting.currentDelta == 0) diff --git a/src/nw4r/snd/snd_BasicSound.cpp b/src/nw4r/snd/snd_BasicSound.cpp index 0aacd888..96014df5 100644 --- a/src/nw4r/snd/snd_BasicSound.cpp +++ b/src/nw4r/snd/snd_BasicSound.cpp @@ -54,10 +54,11 @@ BasicSound::BasicSound(int priority, int ambientPriority) : mGeneralHandle (nullptr), mTempGeneralHandle (nullptr), mSoundPlayer (nullptr), + field_0x54 (0), mSoundActor (nullptr), mExtSoundPlayer (nullptr), - mId (INVALID_ID), - mPauseNestCounter (0) + mId (INVALID_ID) + // mPauseNestCounter (0) { // specifically not the source variant NW4RAssertHeaderClampedLRValue_Line(53, priority, PRIORITY_MIN, @@ -108,6 +109,9 @@ void BasicSound::InitParam() for (int i = 0; i < AUX_BUS_NUM; i++) mFxSend[i] = 0.0f; + for (int i = 0; i < 4; i++) + mRemoteOutVolume[i] = 1.0f; + mAmbientParam.volume = 1.0f; mAmbientParam.pitch = 1.0f; mAmbientParam.pan = 0.0f; @@ -118,7 +122,7 @@ void BasicSound::InitParam() mAmbientParam.biquadFilterType = 0; mAmbientParam.priority = 0; - mPauseNestCounter = 0; + // mPauseNestCounter = 0; } void BasicSound::StartPrepared() @@ -155,7 +159,7 @@ void BasicSound::Pause(bool flag, int fadeFrames) if (flag) { - mPauseNestCounter++; + // mPauseNestCounter++; switch (mPauseState) { @@ -183,8 +187,8 @@ void BasicSound::Pause(bool flag, int fadeFrames) } else { - if (mPauseNestCounter && --mPauseNestCounter) - return; +// if (mPauseNestCounter && --mPauseNestCounter) +// return; switch (mPauseState) { @@ -410,6 +414,13 @@ void BasicSound::UpdateParam() mainOutVolume *= mMainOutVolume; mainOutVolume *= GetSoundPlayer()->GetMainOutVolume(); + f32 remoteOutVolume[4]; + for (int i = 0; i < 4; i++) { + remoteOutVolume[i] = 1.0f; + remoteOutVolume[i] *= GetSoundPlayer()->GetRemoteOutVolume(i); + remoteOutVolume[i] *= mRemoteOutVolume[i]; + } + f32 mainSend = 0.0f; mainSend += mMainSend; mainSend += GetSoundPlayer()->GetMainSend(); @@ -434,6 +445,10 @@ void BasicSound::UpdateParam() basicPlayer.SetOutputLine(outputLineFlag); basicPlayer.SetMainOutVolume(mainOutVolume); + for (int i = 0; i < 4; i++) { + basicPlayer.SetRemoteOutVolume(i, remoteOutVolume[i]); + } + basicPlayer.SetMainSend(mainSend); for (int i = 0; i < AUX_BUS_NUM; i++) @@ -569,15 +584,21 @@ void BasicSound::SetPlayerPriority(int priority) void BasicSound::SetInitialVolume(f32 volume) { NW4RAssert_Line(818, volume >= 0.0f); + if (volume < 0.0f) { + volume = 0.0f; + } - mInitVolume = ut::Clamp(volume, 0.0f, 1.0f); + mInitVolume = mInitVolume = volume; } void BasicSound::SetVolume(f32 volume, int frames) { NW4RAssert_Line(833, volume >= 0.0f); + if (volume < 0.0f) { + volume = 0.0f; + } - mExtMoveVolume.SetTarget(ut::Clamp(volume, 0.0f, 1.0f), frames); + mExtMoveVolume.SetTarget(volume, frames); } void BasicSound::SetPitch(f32 pitch) diff --git a/src/nw4r/snd/snd_Channel.cpp b/src/nw4r/snd/snd_Channel.cpp index c55d4321..98b85285 100644 --- a/src/nw4r/snd/snd_Channel.cpp +++ b/src/nw4r/snd/snd_Channel.cpp @@ -150,6 +150,9 @@ void Channel::InitParam(Callback *callback, u32 callbackData) for (int i = 0; i < AUX_BUS_NUM; i++) mFxSend[i] = 0.0f; + for (int i = 0; i < 4; i++) + mRemoteOutVolume[i] = 1.0f; + mSilenceVolume.InitValue(SILENCE_VOLUME_MAX); mSweepPitch = 0.0f; @@ -244,6 +247,12 @@ void Channel::Update(bool doPeriodicProc) f32 mainSend = 0.0f; mainSend += mMainSend; + + f32 remoteOutVolume[4]; + for (int i = 0; i < 4; i++) { + remoteOutVolume[i] = 1.0f; + remoteOutVolume[i] *= mRemoteOutVolume[i]; + } f32 fxSend[AUX_BUS_NUM]; for (int i = 0; i < AUX_BUS_NUM; i++) @@ -285,6 +294,10 @@ void Channel::Update(bool doPeriodicProc) mVoice->SetMainOutVolume(mainOutVolume); mVoice->SetMainSend(mainSend); + for (int i = 0; i < 4; i++) { + mVoice->SetRemoteOutVolume(i, remoteOutVolume[i]); + } + for (int i = 0; i < AUX_BUS_NUM; i++) mVoice->SetFxSend(static_cast(i), fxSend[i]); } diff --git a/src/nw4r/snd/snd_SeqPlayer.cpp b/src/nw4r/snd/snd_SeqPlayer.cpp index 10264746..481c9e6b 100644 --- a/src/nw4r/snd/snd_SeqPlayer.cpp +++ b/src/nw4r/snd/snd_SeqPlayer.cpp @@ -238,8 +238,10 @@ void SeqPlayer::Skip(OffsetType offsetType, int offset) } } +#if 0 // SeqPlayer::SetTempoRatio ([R89JEL]:/bin/RVL/Debug/mainD.MAP:13781) DECOMP_FORCE(NW4RAssert_String(tempoRatio >= 0.0f)); +#endif void SeqPlayer::SetTempoRatio(f32 tempo) { mTempoRatio = tempo; @@ -284,6 +286,7 @@ void SeqPlayer::CallSeqUserprocCallback(u16 procId, SeqTrack *track) trackParam.cmpFlag = param.cmpFlag; } +#if 0 // SeqPlayer::GetLocalVariable? maybe all of them? DECOMP_FORCE(NW4RAssertHeaderClampedLValue_String(varNo)); @@ -321,6 +324,7 @@ DECOMP_FORCE(&SeqTrack::SetModDepth); // SeqPlayer::SetTrackModSpeed ([R89JEL]:/bin/RVL/Debug/mainD.MAP:13801) DECOMP_FORCE(&SeqTrack::SetModSpeed); +#endif void SeqPlayer::InvalidateData(void const *start, void const *end) { diff --git a/src/nw4r/snd/snd_SoundThread.cpp b/src/nw4r/snd/snd_SoundThread.cpp index 153d3492..571458af 100644 --- a/src/nw4r/snd/snd_SoundThread.cpp +++ b/src/nw4r/snd/snd_SoundThread.cpp @@ -126,7 +126,7 @@ void *SoundThread::SoundThreadFunc(void *arg) return nullptr; } -#ifdef DEBUG +#if 0 /* SoundThread::RegisterSoundFrameCallback * ([R89JEL]:/bin/RVL/Debug/mainD.MAP:14509) */