From 1f75a641e0c80d15f1af10bae7ee71a6ffecf219 Mon Sep 17 00:00:00 2001 From: GitRan <103583353+xenkap@users.noreply.github.com> Date: Sat, 19 Oct 2024 13:34:30 +0800 Subject: [PATCH] Fix audio offset interactions with song start Don't use combined offset here-- using it will cause the instrumental to skip forwards due to your offset. Just use instrumental offset, and don't play it when the song starts-- let resyncVocals do that --- source/funkin/play/PlayState.hx | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/source/funkin/play/PlayState.hx b/source/funkin/play/PlayState.hx index 2ea0d4a7b..e99048552 100644 --- a/source/funkin/play/PlayState.hx +++ b/source/funkin/play/PlayState.hx @@ -926,7 +926,7 @@ class PlayState extends MusicBeatSubState // Reset music properly. if (FlxG.sound.music != null) { - FlxG.sound.music.time = startTimestamp - Conductor.instance.combinedOffset; + FlxG.sound.music.time = startTimestamp; FlxG.sound.music.pitch = playbackRate; FlxG.sound.music.pause(); } @@ -943,7 +943,7 @@ class PlayState extends MusicBeatSubState } } vocals.pause(); - vocals.time = 0 - Conductor.instance.combinedOffset; + vocals.time = 0; if (FlxG.sound.music != null) FlxG.sound.music.volume = 1; vocals.volume = 1; @@ -1003,7 +1003,7 @@ class PlayState extends MusicBeatSubState { // Do NOT apply offsets at this point, because they already got applied the previous frame! Conductor.instance.update(Conductor.instance.songPosition + elapsed * 1000, false); - if (Conductor.instance.songPosition >= (startTimestamp + Conductor.instance.combinedOffset)) + if (Conductor.instance.songPosition >= (startTimestamp - Conductor.instance.instrumentalOffset)) { trace("started song at " + Conductor.instance.songPosition); startSong(); @@ -2288,7 +2288,7 @@ class PlayState extends MusicBeatSubState }; // A negative instrumental offset means the song skips the first few milliseconds of the track. // This just gets added into the startTimestamp behavior so we don't need to do anything extra. - FlxG.sound.music.play(true, Math.max(0, startTimestamp - Conductor.instance.combinedOffset)); + FlxG.sound.music.time = Math.max(0, startTimestamp - Conductor.instance.instrumentalOffset); FlxG.sound.music.pitch = playbackRate; // Prevent the volume from being wrong. @@ -2341,7 +2341,8 @@ class PlayState extends MusicBeatSubState // Skip this if the music is paused (GameOver, Pause menu, start-of-song offset, etc.) if (!(FlxG.sound.music?.playing ?? false)) return; - var timeToPlayAt:Float = Math.min(FlxG.sound.music.length, Math.max(0, Conductor.instance.songPosition - Conductor.instance.combinedOffset)); + // var timeToPlayAt:Float = Math.min(FlxG.sound.music.length, Math.max(0, Conductor.instance.songPosition - Conductor.instance.combinedOffset)); + var timeToPlayAt:Float = Math.min(FlxG.sound.music.length, Math.max(0, Conductor.instance.songPosition)); trace('Resyncing vocals to ${timeToPlayAt}'); FlxG.sound.music.pause(); vocals.pause();