More sound effects and splits

This commit is contained in:
robojumper
2025-06-15 18:16:26 +02:00
parent 7d333a8d8e
commit 6cb7f3bfdc
14 changed files with 227 additions and 46 deletions
+2 -1
View File
@@ -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);
}
+2 -2
View File
@@ -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()
);
}
+1 -1
View File
@@ -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);
}
+2 -2
View File
@@ -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;
}
+128 -1
View File
@@ -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:
+2 -2
View File
@@ -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) {
+1 -1
View File
@@ -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);