From 0f6147f41dc64573d0455a776ba49bd96a3d9c59 Mon Sep 17 00:00:00 2001 From: RaelCappra Date: Fri, 7 Apr 2023 16:54:26 -0300 Subject: [PATCH] Link voice pitch v0 (#2430) * Link voice pitch v0 * Using a new variable instead * Move voice pitch slider to Options tab * fallback to original behavior if freqMultiplier is set to 1 * Move reset button to Options tab with its slider * Fix voice pitch slider width in Options tab * [Review] Always use freqMultiplier --- soh/soh/Enhancements/audio/AudioEditor.cpp | 12 ++++++++++++ soh/src/code/z_actor.c | 15 ++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/soh/soh/Enhancements/audio/AudioEditor.cpp b/soh/soh/Enhancements/audio/AudioEditor.cpp index e3f3bab51..d0cc13bb0 100644 --- a/soh/soh/Enhancements/audio/AudioEditor.cpp +++ b/soh/soh/Enhancements/audio/AudioEditor.cpp @@ -371,6 +371,18 @@ void DrawSfxEditor(bool& open) { "gSeqNameOverlayDuration", 1, 10, "", 5); ImGui::PopItemWidth(); ImGui::NewLine(); + ImGui::PopItemWidth(); + UIWidgets::EnhancementSliderFloat("Link's voice pitch multiplier: %f", "##linkVoiceFreqMultiplier", + "gLinkVoiceFreqMultiplier", 0.4, 2.5, "", 1.0, false, false); + ImGui::SameLine(); + const std::string resetButton = "Reset##linkVoiceFreqMultiplier"; + if (ImGui::Button(resetButton.c_str())) { + CVarSetFloat("gLinkVoiceFreqMultiplier", 1.0f); + SohImGui::RequestCvarSaveOnNextTick(); + } + + ImGui::NewLine(); + ImGui::PushItemWidth(-FLT_MIN); UIWidgets::PaddedSeparator(); UIWidgets::PaddedText("The following options are experimental and may cause music\nto sound odd or have other undesireable effects."); UIWidgets::EnhancementCheckbox("Lower Octaves of Unplayable High Notes", "gExperimentalOctaveDrop"); diff --git a/soh/src/code/z_actor.c b/soh/src/code/z_actor.c index 26e0b6dfe..ae2db5b78 100644 --- a/soh/src/code/z_actor.c +++ b/soh/src/code/z_actor.c @@ -82,6 +82,9 @@ static s32 sCurCeilingBgId; // Used for animating the ice trap on the "Get Item" model. f32 iceTrapScale; +// For Link's voice pitch SFX modifier +static f32 freqMultiplier = 1; + void ActorShape_Init(ActorShape* shape, f32 yOffset, ActorShadowFunc shadowDraw, f32 shadowScale) { shape->yOffset = yOffset; shape->shadowDraw = shadowDraw; @@ -2185,7 +2188,17 @@ void func_8002F7A0(PlayState* play, Actor* actor, f32 arg2, s16 arg3, f32 arg4) } void func_8002F7DC(Actor* actor, u16 sfxId) { - Audio_PlaySoundGeneral(sfxId, &actor->projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); + if (actor->id != ACTOR_PLAYER || sfxId < NA_SE_VO_LI_SWORD_N || sfxId > NA_SE_VO_LI_ELECTRIC_SHOCK_LV_KID) { + Audio_PlaySoundGeneral(sfxId, &actor->projectedPos, 4, &D_801333E0 , &D_801333E0, &D_801333E8); + } else { + freqMultiplier = CVarGetFloat("gLinkVoiceFreqMultiplier", 1.0); + if (freqMultiplier <= 0) { + freqMultiplier = 1; + } + // Authentic behavior uses D_801333E0 for both freqScale and a4 + // Audio_PlaySoundGeneral(sfxId, &actor->projectedPos, 4, &D_801333E0 , &D_801333E0, &D_801333E8); + Audio_PlaySoundGeneral(sfxId, &actor->projectedPos, 4, &freqMultiplier, &D_801333E0, &D_801333E8); + } } void Audio_PlayActorSound2(Actor* actor, u16 sfxId) {