From 6cb7f3bfdc8b4f69e2443fad99fb7d807cf9ea7c Mon Sep 17 00:00:00 2001 From: robojumper Date: Sun, 15 Jun 2025 18:16:26 +0200 Subject: [PATCH] More sound effects and splits --- config/SOUE01/splits.txt | 29 ++++- config/SOUE01/symbols.txt | 32 +++--- configure.py | 10 +- include/d/snd/d_snd_3d_manager.h | 9 +- include/d/snd/d_snd_small_effect_mgr.h | 24 +++- include/nw4r/snd/snd_SoundHandle.h | 4 +- include/nw4r/snd/snd_SoundStartable.h | 17 +++ src/REL/d/t/d_t_sound_area.cpp | 3 +- src/d/snd/d_snd_3d_actor.cpp | 4 +- src/d/snd/d_snd_area_sound_effect_mgr.cpp | 2 +- src/d/snd/d_snd_player_mgr.cpp | 4 +- src/d/snd/d_snd_small_effect_mgr.cpp | 129 +++++++++++++++++++++- src/d/snd/d_snd_sound.cpp | 4 +- src/d/snd/d_snd_source.cpp | 2 +- 14 files changed, 227 insertions(+), 46 deletions(-) diff --git a/config/SOUE01/splits.txt b/config/SOUE01/splits.txt index 91d6b5b0..dd05ec91 100644 --- a/config/SOUE01/splits.txt +++ b/config/SOUE01/splits.txt @@ -2625,12 +2625,19 @@ d/snd/d_snd_state_mgr.cpp: .sbss start:0x80575D60 end:0x80575D78 .sdata2 start:0x8057D3F8 end:0x8057D450 +d/snd/d_snd_stage_reverb.cpp: + .text start:0x80366430 end:0x803665E4 align:16 + .sdata2 start:0x8057D450 end:0x8057D478 + d/snd/d_snd_stage_data.cpp: .rodata start:0x804F0D80 end:0x804F2308 .sdata2 start:0x8057D478 end:0x8057D7C0 -d/snd/d_snd_unk_component_2.cpp: - .text start:0x80366430 end:0x8036A3A4 align:16 +d/snd/d_snd_stage_callbacks.cpp: + .text start:0x803665F0 end:0x8036740C align:16 + +d/snd/d_snd_event_callbacks.cpp: + .text start:0x80367410 end:0x8036A3A4 align:16 d/snd/d_snd_area_sound_effect_mgr.cpp: .text start:0x8036A3B0 end:0x8036B8D0 align:16 @@ -2670,8 +2677,14 @@ d/snd/d_snd_bgm_sound.cpp: .text start:0x80379D20 end:0x8037BA68 align:16 .sbss start:0x80575D88 end:0x80575D90 -d/snd/d_snd_unk_15.cpp: - .text start:0x8037BA70 end:0x8037D800 align:16 +d/snd/d_snd_bgm_data_mgr.cpp: + .text start:0x8037BA70 end:0x8037C518 align:16 + +d/snd/d_snd_bgm_mml_parser_base.cpp: + .text start:0x8037C520 end:0x8037D014 align:16 + +d/snd/d_snd_bgm_mml_parsers.cpp: + .text start:0x8037D020 end:0x8037D800 align:16 d/snd/d_snd_small_effect_mgr.cpp: .text start:0x8037D800 end:0x8037F8B4 align:16 @@ -2783,8 +2796,14 @@ d/snd/d_snd_sound_npc_2_callbacks.cpp: d/snd/d_snd_sound_tgsound_callbacks.cpp: .text start:0x80399000 end:0x8039942C align:16 +d/snd/d_snd_mgr_unk_17.cpp: + .text start:0x80399430 end:0x80399574 align:16 + +d/snd/d_snd_fi_vocal_mgr.cpp: + .text start:0x80399580 end:0x80399A3C align:16 + d/snd/d_snd_mgr_unk_11.cpp: - .text start:0x80399430 end:0x8039A848 align:16 + .text start:0x80399A40 end:0x8039A848 align:16 .ctors start:0x804DB934 end:0x804DB938 d/snd/d_snd_calc_pitch.cpp: diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index 30306c22..963c921e 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -20797,17 +20797,17 @@ fn_8037C300 = .text:0x8037C300; // type:function size:0x68 fn_8037C370 = .text:0x8037C370; // type:function size:0x34 fn_8037C3B0 = .text:0x8037C3B0; // type:function size:0x58 fn_8037C410 = .text:0x8037C410; // type:function size:0x60 -fn_8037C470 = .text:0x8037C470; // type:function size:0xA8 +setHarpPitchSeqVars = .text:0x8037C470; // type:function size:0xA8 fn_8037C520 = .text:0x8037C520; // type:function size:0x20 fn_8037C540 = .text:0x8037C540; // type:function size:0x34 fn_8037C580 = .text:0x8037C580; // type:function size:0x98 fn_8037C620 = .text:0x8037C620; // type:function size:0x1E0 -fn_8037C800 = .text:0x8037C800; // type:function size:0x4F0 -fn_8037CCF0 = .text:0x8037CCF0; // type:function size:0x18C -fn_8037CE80 = .text:0x8037CE80; // type:function size:0x24 -fn_8037CEB0 = .text:0x8037CEB0; // type:function size:0x38 -fn_8037CEF0 = .text:0x8037CEF0; // type:function size:0x30 -fn_8037CF20 = .text:0x8037CF20; // type:function size:0xD8 +dSndMmlParser__Parse = .text:0x8037C800; // type:function size:0x4F0 +dSndMmlParser__CommandProc = .text:0x8037CCF0; // type:function size:0x18C +dSndMmlParser__Read16 = .text:0x8037CE80; // type:function size:0x24 +dSndMmlParser__Read24 = .text:0x8037CEB0; // type:function size:0x38 +dSndMmlParser__ReadVar = .text:0x8037CEF0; // type:function size:0x30 +dSndMmlParser__ReadArg = .text:0x8037CF20; // type:function size:0xD8 fn_8037D000 = .text:0x8037D000; // type:function size:0x4 fn_8037D010 = .text:0x8037D010; // type:function size:0x4 fn_8037D020 = .text:0x8037D020; // type:function size:0x64 @@ -20840,21 +20840,21 @@ fn_8037DA60 = .text:0x8037DA60; // type:function size:0x70 fn_8037DAD0 = .text:0x8037DAD0; // type:function size:0xDC fn_8037DBB0 = .text:0x8037DBB0; // type:function size:0x98 fn_8037DC50 = .text:0x8037DC50; // type:function size:0x70 -fn_8037DCC0 = .text:0x8037DCC0; // type:function size:0x48 -fn_8037DD10 = .text:0x8037DD10; // type:function size:0x1BC +playSoundInternalChecked__20dSndSmallEffectMgr_cFUlPQ34nw4r3snd11SoundHandle = .text:0x8037DCC0; // type:function size:0x48 +playSoundInternal__20dSndSmallEffectMgr_cFUlPQ34nw4r3snd11SoundHandle = .text:0x8037DD10; // type:function size:0x1BC playSound__20dSndSmallEffectMgr_cFUl = .text:0x8037DED0; // type:function size:0x2D0 playSoundWithPan__20dSndSmallEffectMgr_cFUlf = .text:0x8037E1A0; // type:function size:0x90 fn_8037E230 = .text:0x8037E230; // type:function size:0xEC playSoundInternal__20dSndSmallEffectMgr_cFUl = .text:0x8037E320; // type:function size:0x78 getHoldSoundHandle__20dSndSmallEffectMgr_cFUl = .text:0x8037E3A0; // type:function size:0x158 -fn_8037E500 = .text:0x8037E500; // type:function size:0x58 +holdSound__20dSndSmallEffectMgr_cFUl = .text:0x8037E500; // type:function size:0x58 holdSoundWithPitch__20dSndSmallEffectMgr_cFUlf = .text:0x8037E560; // type:function size:0xBC -fn_8037E620 = .text:0x8037E620; // type:function size:0xDC -fn_8037E700 = .text:0x8037E700; // type:function size:0x8 -fn_8037E710 = .text:0x8037E710; // type:function size:0x8 -fn_8037E720 = .text:0x8037E720; // type:function size:0xEC -fn_8037E810 = .text:0x8037E810; // type:function size:0x50 -fn_8037E860 = .text:0x8037E860; // type:function size:0x148 +holdSound__20dSndSmallEffectMgr_cFUlPQ34nw4r3snd11SoundHandle = .text:0x8037E620; // type:function size:0xDC +playSoundAtPosition__20dSndSmallEffectMgr_cFUlPCQ34nw4r4math4VEC3 = .text:0x8037E700; // type:function size:0x8 +playSoundAtPosition2__20dSndSmallEffectMgr_cFUlPCQ34nw4r4math4VEC3 = .text:0x8037E710; // type:function size:0x8 +holdBowChargeSound__20dSndSmallEffectMgr_cFf = .text:0x8037E720; // type:function size:0xEC +holdFinisherPromptSound__20dSndSmallEffectMgr_cFPCQ34nw4r4math4VEC3 = .text:0x8037E810; // type:function size:0x50 +playDowsingPingSound__20dSndSmallEffectMgr_cFff = .text:0x8037E860; // type:function size:0x148 fn_8037E9B0 = .text:0x8037E9B0; // type:function size:0xC fn_8037E9C0 = .text:0x8037E9C0; // type:function size:0x90 fn_8037EA50 = .text:0x8037EA50; // type:function size:0x8 diff --git a/configure.py b/configure.py index 13340373..f6585aee 100644 --- a/configure.py +++ b/configure.py @@ -745,7 +745,9 @@ config.libs = [ Object(Matching, "d/snd/d_snd_3d_manager.cpp"), Object(NonMatching, "d/snd/d_snd_state_mgr.cpp"), Object(Matching, "d/snd/d_snd_stage_data.cpp"), - Object(NonMatching, "d/snd/d_snd_unk_component_2.cpp"), + Object(NonMatching, "d/snd/d_snd_stage_reverb.cpp"), + Object(NonMatching, "d/snd/d_snd_stage_callbacks.cpp"), + Object(NonMatching, "d/snd/d_snd_event_callbacks.cpp"), Object(NonMatching, "d/snd/d_snd_area_sound_effect_mgr.cpp"), Object(NonMatching, "d/snd/d_snd_area_sound.cpp"), Object(Matching, "d/snd/d_snd_control_sound.cpp"), @@ -754,7 +756,9 @@ config.libs = [ Object(NonMatching, "d/snd/d_snd_bgm_sound_callbacks.cpp"), Object(NonMatching, "d/snd/d_snd_bgm_sound_battle_callbacks.cpp"), Object(NonMatching, "d/snd/d_snd_bgm_sound.cpp"), - Object(NonMatching, "d/snd/d_snd_unk_15.cpp"), + Object(NonMatching, "d/snd/d_snd_bgm_data_mgr.cpp"), + Object(NonMatching, "d/snd/d_snd_bgm_mml_parser_base.cpp"), + Object(NonMatching, "d/snd/d_snd_bgm_mml_parsers.cpp"), Object(NonMatching, "d/snd/d_snd_small_effect_mgr.cpp"), Object(NonMatching, "d/snd/d_snd_harp_mgr.cpp"), Object(NonMatching, "d/snd/d_snd_anim_sound.cpp"), @@ -782,6 +786,8 @@ config.libs = [ Object(NonMatching, "d/snd/d_snd_sound_npc_callbacks.cpp"), Object(NonMatching, "d/snd/d_snd_sound_npc_2_callbacks.cpp"), Object(NonMatching, "d/snd/d_snd_sound_tgsound_callbacks.cpp"), + Object(NonMatching, "d/snd/d_snd_mgr_unk_17.cpp"), + Object(NonMatching, "d/snd/d_snd_fi_vocal_mgr.cpp"), Object(NonMatching, "d/snd/d_snd_mgr_unk_11.cpp"), Object(NonMatching, "d/snd/d_snd_calc_pitch.cpp"), ], diff --git a/include/d/snd/d_snd_3d_manager.h b/include/d/snd/d_snd_3d_manager.h index 2ac0b062..af45af62 100644 --- a/include/d/snd/d_snd_3d_manager.h +++ b/include/d/snd/d_snd_3d_manager.h @@ -4,7 +4,6 @@ #include "d/snd/d_snd_3d_engine.h" #include "d/snd/d_snd_util.h" #include "egg/gfx/eggCamera.h" -#include "m/m_vec.h" #include "nw4r/math/math_types.h" #include "nw4r/snd/snd_Sound3DListener.h" #include "nw4r/snd/snd_Sound3DManager.h" @@ -28,11 +27,11 @@ public: return mManager; } - const mVec3_c &getCameraTargetPos() const { + const nw4r::math::VEC3 &getCameraTargetPos() const { return mCameraTargetPosition; } - const mVec3_c &getNrmCameraDirection() const { + const nw4r::math::VEC3 &getNrmCameraDirection() const { return mCameraDirectionNormalized; } @@ -52,8 +51,8 @@ private: /* 0x018 */ nw4r::snd::Sound3DManager mManager; /* 0x044 */ nw4r::snd::Sound3DListener mListener; /* 0xB0 */ EGG::LookAtCamera mCamera; - /* 0x138 */ mVec3_c mCameraDirectionNormalized; - /* 0x144 */ mVec3_c mCameraTargetPosition; + /* 0x138 */ nw4r::math::VEC3 mCameraDirectionNormalized; + /* 0x144 */ nw4r::math::VEC3 mCameraTargetPosition; /* 0x150 */ f32 mCameraPosSqVelocity; /* 0x154 */ f32 mCameraAtSqVelocity; /* 0x158 */ f32 mCamDistance; diff --git a/include/d/snd/d_snd_small_effect_mgr.h b/include/d/snd/d_snd_small_effect_mgr.h index a03c2b0e..b77ec967 100644 --- a/include/d/snd/d_snd_small_effect_mgr.h +++ b/include/d/snd/d_snd_small_effect_mgr.h @@ -4,9 +4,9 @@ #include "d/snd/d_snd_source.h" #include "d/snd/d_snd_util.h" #include "d/snd/d_snd_wzsound.h" // IWYU pragma: export +#include "nw4r/math/math_types.h" #include "nw4r/snd/snd_SoundHandle.h" - SND_DISPOSER_FORWARD_DECL(dSndSmallEffectMgr_c); /** @@ -35,18 +35,29 @@ public: // used for clawshots cursor, pan depends on where on the screen // your cursor is when it activates bool playSoundWithPan(u32 soundId, f32 pan); - void holdSoundWithPitch(u32 soundId, f32 pitch); - bool playSkbSound(u32 soundId); + bool holdSound(u32 soundId); + bool holdSoundWithPitch(u32 soundId, f32 pitch); + // These two do the exact same thing + bool playSoundAtPosition(u32 soundId, const nw4r::math::VEC3 *position); + bool playSoundAtPosition2(u32 soundId, const nw4r::math::VEC3 *position); + + bool holdBowChargeSound(f32 remainingChargeAmount); + bool holdFinisherPromptSound(const nw4r::math::VEC3 *position); + + bool playDowsingPingSound(f32 volume, f32 pitch); + bool holdDowsingNearestSound(); + + bool playSkbSound(u32 soundId); bool playButtonPressSoundWhenAdvancingTextBoxes(f32); void resetButtonPressSound(); void setButtonPressSound(dSoundSource_c *source); - - void playSound(u32 soundId, nw4r::snd::SoundHandle *handle); bool playBattleHitSound(BattleHitSound_e type, dSoundSource_c *source); private: + bool playSoundInternal(u32 soundId, nw4r::snd::SoundHandle *handle); + bool playSoundInternalChecked(u32 soundId, nw4r::snd::SoundHandle *handle); bool playSoundInternal(u32 soundId); void stopSounds(u32 playerIdx, u32 soundId, s32 fadeFrames); void stopSounds(u32 soundId, s32 fadeFrames); @@ -59,11 +70,12 @@ private: * or stops a lower-priority sound if needed and possible. */ nw4r::snd::SoundHandle *getHoldSoundHandle(u32 soundId); + bool holdSound(u32 soundId, nw4r::snd::SoundHandle *handle); /* 0x10 */ s32 field_0x10; // used for most sounds /* 0x14 */ nw4r::snd::SoundHandle mNormalSound; - /* 0x18 */ nw4r::snd::SoundHandle mHandle3; + /* 0x18 */ nw4r::snd::SoundHandle mDowsingSoundHandle; /* 0x1C */ nw4r::snd::SoundHandle mHoldSoundHandles[NUM_HOLD_SOUNDS]; /* 0x28 */ u32 mDelayedSoundIds[NUM_DELAYED_SOUNDS]; diff --git a/include/nw4r/snd/snd_SoundHandle.h b/include/nw4r/snd/snd_SoundHandle.h index 2be591f3..ab6f5e71 100644 --- a/include/nw4r/snd/snd_SoundHandle.h +++ b/include/nw4r/snd/snd_SoundHandle.h @@ -49,9 +49,9 @@ namespace nw4r { namespace snd mSound->SetVolume(volume, frames); } - void SetPitch(f32 volume) { + void SetPitch(f32 pitch) { if (IsAttachedSound()) - mSound->SetPitch(volume); + mSound->SetPitch(pitch); } void Stop(int fadeFrames) { diff --git a/include/nw4r/snd/snd_SoundStartable.h b/include/nw4r/snd/snd_SoundStartable.h index 86d62ec6..8ac1d55b 100644 --- a/include/nw4r/snd/snd_SoundStartable.h +++ b/include/nw4r/snd/snd_SoundStartable.h @@ -164,6 +164,23 @@ namespace nw4r { namespace snd return detail_PrepareSound(pHandle, id, NULL) == START_SUCCESS; } + // The detail_ functions above are probably not meant to be called directly from game code, + // so these inlines probably exist, but I haven't found them in Ketteiban or BBA. An inline + // fixes a regswap in d/snd so that's more evidence. Names are obviously made up. + // TODO: Do these exist in other variants for different ID types too??? + + StartResult StartSoundReturnStatus(SoundHandle *pHandle, u32 id, const StartInfo *pStartInfo) { + return detail_StartSound(pHandle, id, pStartInfo); + } + + StartResult HoldSoundReturnStatus(SoundHandle *pHandle, u32 id, const StartInfo *pStartInfo) { + return detail_HoldSound(pHandle, id, pStartInfo); + } + + StartResult PrepareSoundReturnStatus(SoundHandle *pHandle, u32 id, const StartInfo *pStartInfo) { + return detail_PrepareSound(pHandle, id, pStartInfo); + } + // members private: /* vtable */ // size 0x04, offset 0x00 diff --git a/src/REL/d/t/d_t_sound_area.cpp b/src/REL/d/t/d_t_sound_area.cpp index 655caa73..584a49d0 100644 --- a/src/REL/d/t/d_t_sound_area.cpp +++ b/src/REL/d/t/d_t_sound_area.cpp @@ -52,7 +52,8 @@ int dTgSndAr_c::actorExecute() { link->setBit_field_0xE8(params & 0xFF); } if (dSnd3DManager_c::GetInstance() != nullptr) { - mVec3_c pos = dSnd3DManager_c::GetInstance()->getCameraTargetPos(); + mVec3_c pos; + pos.copyFrom(dSnd3DManager_c::GetInstance()->getCameraTargetPos()); if (checkPosInArea(pos) && dTgSndMg_c::GetInstance() != nullptr) { dTgSndMg_c::GetInstance()->setBgmFlag(params & 0xFF); } diff --git a/src/d/snd/d_snd_3d_actor.cpp b/src/d/snd/d_snd_3d_actor.cpp index e55daee7..4c56b746 100644 --- a/src/d/snd/d_snd_3d_actor.cpp +++ b/src/d/snd/d_snd_3d_actor.cpp @@ -92,7 +92,7 @@ void dSnd3DActor_c::updateCameraDirectionDot() { updatePositionRelativeToListener(); nw4r::math::VEC3 norm; VECNormalize(mPositionRelativeToListener, norm); - mCameraDirectionDot = nw4r::math::VEC3Dot(&norm, dSnd3DManager_c::GetInstance()->getNrmCameraDirection()); + mCameraDirectionDot = nw4r::math::VEC3Dot(&norm, &dSnd3DManager_c::GetInstance()->getNrmCameraDirection()); setFlag(0x20); } } @@ -106,7 +106,7 @@ void dSnd3DActor_c::updatePositionRelativeToCameraTarget() { void dSnd3DActor_c::calculatePositionRelativeToCameraTarget() { nw4r::math::VEC3Sub( - &mPositionRelativeToCameraTarget, &GetPosition(), dSnd3DManager_c::GetInstance()->getCameraTargetPos() + &mPositionRelativeToCameraTarget, &GetPosition(), &dSnd3DManager_c::GetInstance()->getCameraTargetPos() ); } diff --git a/src/d/snd/d_snd_area_sound_effect_mgr.cpp b/src/d/snd/d_snd_area_sound_effect_mgr.cpp index bd0c7ef0..c21bdb69 100644 --- a/src/d/snd/d_snd_area_sound_effect_mgr.cpp +++ b/src/d/snd/d_snd_area_sound_effect_mgr.cpp @@ -40,7 +40,7 @@ bool dSndAreaSoundEffectMgr_c::startSound(u32 soundId, u32 handleIdx) { } dSndAreaSound_c *snd = &mSounds[handleIdx]; - nw4r::snd::SoundStartable::StartResult res = mActor.detail_StartSound(snd, soundId, nullptr); + nw4r::snd::SoundStartable::StartResult res = mActor.StartSoundReturnStatus(snd, soundId, nullptr); if (res == nw4r::snd::SoundStartable::START_SUCCESS) { snd->fadeIn(soundId, 30); } diff --git a/src/d/snd/d_snd_player_mgr.cpp b/src/d/snd/d_snd_player_mgr.cpp index df8b414d..c1284684 100644 --- a/src/d/snd/d_snd_player_mgr.cpp +++ b/src/d/snd/d_snd_player_mgr.cpp @@ -94,9 +94,9 @@ nw4r::snd::SoundStartable::StartResult dSndPlayerMgr_c::startSound( } nw4r::snd::SoundStartable::StartResult res; if (pStartInfo != nullptr) { - res = dSndMgr_c::getPlayer().detail_StartSound(pHandle, soundId, pStartInfo); + res = dSndMgr_c::getPlayer().StartSoundReturnStatus(pHandle, soundId, pStartInfo); } else { - res = dSndMgr_c::getPlayer().detail_StartSound(pHandle, soundId, nullptr); + res = dSndMgr_c::getPlayer().StartSoundReturnStatus(pHandle, soundId, nullptr); } return res; } diff --git a/src/d/snd/d_snd_small_effect_mgr.cpp b/src/d/snd/d_snd_small_effect_mgr.cpp index 6a4004ec..b100b8e8 100644 --- a/src/d/snd/d_snd_small_effect_mgr.cpp +++ b/src/d/snd/d_snd_small_effect_mgr.cpp @@ -4,13 +4,18 @@ #include "d/snd/d_snd_bgm_mgr.h" #include "d/snd/d_snd_checkers.h" #include "d/snd/d_snd_control_player_mgr.h" +#include "d/snd/d_snd_distant_sound_actor_pool.h" #include "d/snd/d_snd_mgr.h" #include "d/snd/d_snd_player_mgr.h" #include "d/snd/d_snd_source.h" #include "d/snd/d_snd_source_enums.h" #include "d/snd/d_snd_util.h" #include "d/snd/d_snd_wzsound.h" +#include "egg/audio/eggAudioRmtSpeakerMgr.h" #include "nw4r/snd/snd_SeqSoundHandle.h" +#include "nw4r/snd/snd_SoundHandle.h" +#include "nw4r/snd/snd_SoundStartable.h" +#include "nw4r/snd/snd_global.h" #include "rvl/OS/OSFastCast.h" #include "toBeSorted/music_mgrs.h" @@ -30,7 +35,7 @@ void dSndSmallEffectMgr_c::calc() { if (mDelayedSoundIds[i] != -1) { mDelayedSoundTimers[i]--; if (mDelayedSoundTimers[i] <= 0) { - playSound(mDelayedSoundIds[i], nullptr); + playSoundInternalChecked(mDelayedSoundIds[i], nullptr); mDelayedSoundIds[i] = -1; } } @@ -182,6 +187,128 @@ nw4r::snd::SoundHandle *dSndSmallEffectMgr_c::getHoldSoundHandle(u32 soundId) { return least; } +bool dSndSmallEffectMgr_c::holdSound(u32 soundId) { + nw4r::snd::SoundHandle *h = getHoldSoundHandle(soundId); + if (h != nullptr) { + return holdSound(soundId, h); + } + return false; +} + +bool dSndSmallEffectMgr_c::holdSoundWithPitch(u32 soundId, f32 pitch) { + nw4r::snd::SoundHandle *h = getHoldSoundHandle(soundId); + bool ok = false; + if (h != nullptr) { + ok = holdSound(soundId, h); + } + if (ok && soundId == SE_S_GAUGE_SHIELD_UP_LV) { + f32 actualPitch = pitch + 1.0f; + if (actualPitch > 2.0f) { + actualPitch = 2.0f; + } + h->SetPitch(actualPitch); + } + return ok; +} + +bool dSndSmallEffectMgr_c::holdSound(u32 soundId, nw4r::snd::SoundHandle *handle) { + if (handle == nullptr) { + return false; + } + u32 param = dSndPlayerMgr_c::GetInstance()->getSomeUserParam(soundId); + if ((param & 0x80000000) != 0) { + return false; + } + nw4r::snd::SoundStartable::StartResult result = + dSndMgr_c::GetInstance()->getPlayer().HoldSoundReturnStatus(handle, soundId, nullptr); + if (result == nw4r::snd::SoundStartable::START_SUCCESS) { + if ((param & 0x8) != 0) { + if (EGG::AudioRmtSpeakerMgr::getWpadVolume() != 0) { + handle->SetOutputLineFlag(nw4r::snd::OUTPUT_LINE_REMOTE_1); + } + } else if ((param & 0x4) != 0) { + handle->SetOutputLineFlag(nw4r::snd::OUTPUT_LINE_MAIN | nw4r::snd::OUTPUT_LINE_REMOTE_1); + } + } + + return result == nw4r::snd::SoundStartable::START_SUCCESS; +} + +bool dSndSmallEffectMgr_c::playSoundAtPosition(u32 soundId, const nw4r::math::VEC3 *position) { + return dSndDistantSoundActorPool_c::GetInstance()->startSound(soundId, position); +} + +bool dSndSmallEffectMgr_c::playSoundAtPosition2(u32 soundId, const nw4r::math::VEC3 *position) { + return dSndDistantSoundActorPool_c::GetInstance()->startSound(soundId, position); +} + +bool dSndSmallEffectMgr_c::holdBowChargeSound(f32 remainingChargeAmount) { + nw4r::snd::SoundHandle *pHandle = getHoldSoundHandle(SE_S_BW_FOCUS_LV); + bool ok = false; + if (pHandle != nullptr) { + ok = holdSound(SE_S_BW_FOCUS_LV, pHandle); + } + if (ok) { + f32 chargeProgress = 1.0f - remainingChargeAmount; + if (chargeProgress < 0.0f) { + chargeProgress = 0.0f; + } + + // Bow charge sound increases in volume as it's charging up + f32 volume = chargeProgress / 2.0f; + volume += 0.5f; + if (volume > 1.0f) { + volume = 1.0f; + } + pHandle->SetVolume(volume, 0); + + // Bow charge sound pitches up by 25% until it's complete + f32 pitch = chargeProgress / 4.0f + 1.0f; + pHandle->SetPitch(pitch); + } + return ok; +} + +bool dSndSmallEffectMgr_c::holdFinisherPromptSound(const nw4r::math::VEC3 *position) { + if (fn_80364DA0(ENEMY_SOUND_MGR)) { + return false; + } + return dSndDistantSoundActorPool_c::GetInstance()->holdSound(SE_S_FOCUS_FINISHER_LV, position); +} + +bool dSndSmallEffectMgr_c::playDowsingPingSound(f32 volume, f32 pitch) { + bool result = playSoundInternal(SE_S_DOWSING_SOUND, &mDowsingSoundHandle); + if (result) { + mDowsingSoundHandle.SetVolume(volume, 0); + if (pitch < 0.8408964f) { + pitch = 0.8408964f; + } else if (pitch < 1.0594631f) { + pitch = 1.0f; + } else if (pitch < 1.122462f) { + pitch = 1.0594631f; + } else if (pitch < 1.1892071f) { + pitch = 1.122462f; + } else if (pitch < 1.2599211f) { + pitch = 1.1892071f; + } else if (pitch < 1.3348398f) { + pitch = 1.2599211f; + } else if (pitch < 1.4142135f) { + pitch = 1.3348398f; + } else if (pitch < 1.4983071f) { + pitch = 1.4142135f; // sqrt(2) + } else if (pitch > 1.4983071f) { + pitch = 1.4983071f; + } + mDowsingSoundHandle.SetPitch(pitch); + } + + return result; +} + +bool dSndSmallEffectMgr_c::holdDowsingNearestSound() { + return holdSound(SE_S_DOWSING_SOUND_NEAREST, &mDowsingSoundHandle); +} + bool dSndSmallEffectMgr_c::playSkbSound(u32 soundId) { switch (soundId) { case SE_S_SK_POINT: diff --git a/src/d/snd/d_snd_sound.cpp b/src/d/snd/d_snd_sound.cpp index 2a6ecda0..11d1dc63 100644 --- a/src/d/snd/d_snd_sound.cpp +++ b/src/d/snd/d_snd_sound.cpp @@ -348,13 +348,13 @@ nw4r::snd::SoundStartable::StartResult dSndSound_c::prepareSound(u32 soundId, u3 nw4r::snd::SoundStartable::StartResult res; if (startOffset == 0) { - res = dSndMgr_c::GetInstance()->getPlayer().detail_PrepareSound(this, soundId, nullptr); + res = dSndMgr_c::GetInstance()->getPlayer().PrepareSoundReturnStatus(this, soundId, nullptr); } else { nw4r::snd::SoundStartable::StartInfo info; info.enableFlag |= nw4r::snd::SoundStartable::StartInfo::ENABLE_START_OFFSET; info.startOffsetType = nw4r::snd::SoundStartable::StartInfo::START_OFFSET_TYPE_MILLISEC; info.startOffset = startOffset; - res = dSndMgr_c::GetInstance()->getPlayer().detail_PrepareSound(this, soundId, &info); + res = dSndMgr_c::GetInstance()->getPlayer().PrepareSoundReturnStatus(this, soundId, &info); } if (res == nw4r::snd::SoundStartable::START_SUCCESS) { diff --git a/src/d/snd/d_snd_source.cpp b/src/d/snd/d_snd_source.cpp index 5bd17935..184635e8 100644 --- a/src/d/snd/d_snd_source.cpp +++ b/src/d/snd/d_snd_source.cpp @@ -198,7 +198,7 @@ dSoundSource_c::startSound(u32 soundId, nw4r::snd::SoundHandle *handle, nw4r::sn } field_0x11C |= 0x80000000; - result = detail_StartSound(handle, soundId, nullptr); + result = StartSoundReturnStatus(handle, soundId, nullptr); if (result == START_SUCCESS) { addSeHandleType1(seHandle); d_vt_0x58(*handle, seHandle, soundId);