summaryrefslogtreecommitdiff
path: root/src/d
diff options
context:
space:
mode:
authorrobojumper <robojumper@gmail.com>2025-06-15 18:16:26 +0200
committerrobojumper <robojumper@gmail.com>2025-09-13 10:51:36 +0200
commit6cb7f3bfdc8b4f69e2443fad99fb7d807cf9ea7c (patch)
tree10871e545d45c2d2afe624d7c0d737bc5b0005c1 /src/d
parent7d333a8d8e468dd891d380248af03387af672e17 (diff)
More sound effects and splits
Diffstat (limited to 'src/d')
-rw-r--r--src/d/snd/d_snd_3d_actor.cpp4
-rw-r--r--src/d/snd/d_snd_area_sound_effect_mgr.cpp2
-rw-r--r--src/d/snd/d_snd_player_mgr.cpp4
-rw-r--r--src/d/snd/d_snd_small_effect_mgr.cpp129
-rw-r--r--src/d/snd/d_snd_sound.cpp4
-rw-r--r--src/d/snd/d_snd_source.cpp2
6 files changed, 136 insertions, 9 deletions
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);