From f95a68f4aadefc80c7ddd0e8aac5d9e283a7d692 Mon Sep 17 00:00:00 2001 From: EpicGamer2469 <62869918+Epicgamer2469@users.noreply.github.com> Date: Wed, 13 Mar 2024 20:18:13 -0500 Subject: [PATCH] Fix rockers pitch bend (#789) --- Assets/Scripts/Games/Rockers/RockersRocker.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Assets/Scripts/Games/Rockers/RockersRocker.cs b/Assets/Scripts/Games/Rockers/RockersRocker.cs index b992da2c..c8eabf69 100644 --- a/Assets/Scripts/Games/Rockers/RockersRocker.cs +++ b/Assets/Scripts/Games/Rockers/RockersRocker.cs @@ -220,9 +220,8 @@ namespace HeavenStudio.Games.Scripts_Rockers if (bending || !strumming) return; bending = true; lastBendPitch = pitch; - if (chordSound != null) - { - chordSound.BendUp(0.05f, SoundByte.GetPitchFromSemiTones(SoundByte.GetSemitonesFromPitch(chordSound.pitch, true) + pitch, true)); + if (chordSound != null) { + chordSound.BendUp(0.05f, GetBentPitch(chordSound.pitch, pitch)); } else { @@ -230,7 +229,7 @@ namespace HeavenStudio.Games.Scripts_Rockers { if (stringSounds[i] != null) { - stringSounds[i].BendUp(0.05f, SoundByte.GetPitchFromSemiTones(SoundByte.GetSemitonesFromPitch(stringSounds[i].pitch, true) + pitch, true)); + stringSounds[i].BendUp(0.05f, GetBentPitch(stringSounds[i].pitch, pitch)); } } } @@ -299,6 +298,14 @@ namespace HeavenStudio.Games.Scripts_Rockers { anim.DoScaledAnimationAsync((JJ ? "JJ" : "") + name, time); } + + private float GetBentPitch(float pitch, int bend) + { + float unscaledPitch = chordSound.pitch / Conductor.instance.musicSource.pitch; + float bendPitch = SoundByte.GetPitchFromSemiTones(bend, false); + + return (unscaledPitch * bendPitch) * Conductor.instance.musicSource.pitch; + } } }