diff --git a/source/funkin/Conductor.hx b/source/funkin/Conductor.hx index bd7c7196f..ff72b1e12 100644 --- a/source/funkin/Conductor.hx +++ b/source/funkin/Conductor.hx @@ -275,6 +275,13 @@ class Conductor return Save.instance.options.audioVisualOffset; } + public var combinedOffset(get, never):Float; + + function get_combinedOffset():Float + { + return instrumentalOffset + audioVisualOffset + inputOffset; + } + /** * The number of beats in a measure. May be fractional depending on the time signature. */ diff --git a/source/funkin/play/PlayState.hx b/source/funkin/play/PlayState.hx index e2bff164e..ad52dd6e6 100644 --- a/source/funkin/play/PlayState.hx +++ b/source/funkin/play/PlayState.hx @@ -861,7 +861,7 @@ class PlayState extends MusicBeatSubState // Reset music properly. if (FlxG.sound.music != null) { - FlxG.sound.music.time = startTimestamp - Conductor.instance.instrumentalOffset; + FlxG.sound.music.time = startTimestamp - Conductor.instance.combinedOffset; FlxG.sound.music.pitch = playbackRate; FlxG.sound.music.pause(); } @@ -878,7 +878,7 @@ class PlayState extends MusicBeatSubState } } vocals.pause(); - vocals.time = 0; + vocals.time = 0 - Conductor.instance.combinedOffset; if (FlxG.sound.music != null) FlxG.sound.music.volume = 1; vocals.volume = 1; @@ -919,7 +919,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.instrumentalOffset)) + if (Conductor.instance.songPosition >= (startTimestamp + Conductor.instance.combinedOffset)) { trace("started song at " + Conductor.instance.songPosition); startSong(); @@ -1401,7 +1401,7 @@ class PlayState extends MusicBeatSubState if (FlxG.sound.music != null) { - var correctSync:Float = Math.min(FlxG.sound.music.length, Math.max(0, Conductor.instance.songPosition - Conductor.instance.instrumentalOffset)); + var correctSync:Float = Math.min(FlxG.sound.music.length, Math.max(0, Conductor.instance.songPosition - Conductor.instance.combinedOffset)); if (!startingSong && (Math.abs(FlxG.sound.music.time - correctSync) > 5 || Math.abs(vocals.checkSyncError(correctSync)) > 5)) { @@ -1411,6 +1411,13 @@ class PlayState extends MusicBeatSubState trace(correctSync); resyncVocals(); } + else + { + trace("NO VOCAL SYNC NEEDED"); + if (vocals != null) trace(vocals.checkSyncError(correctSync)); + trace(FlxG.sound.music.time); + trace(correctSync); + } } // Only bop camera if zoom level is below 135% @@ -1967,7 +1974,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, startTimestamp - Conductor.instance.instrumentalOffset); + FlxG.sound.music.play(true, Math.max(0, startTimestamp - Conductor.instance.combinedOffset)); FlxG.sound.music.pitch = playbackRate; // Prevent the volume from being wrong. @@ -1979,7 +1986,9 @@ class PlayState extends MusicBeatSubState vocals.play(); vocals.volume = 1.0; vocals.pitch = playbackRate; - vocals.time = startTimestamp; + vocals.time = FlxG.sound.music.time; + trace('${FlxG.sound.music.time}'); + trace('${vocals.time}'); resyncVocals(); #if FEATURE_DISCORD_RPC @@ -1989,7 +1998,7 @@ class PlayState extends MusicBeatSubState if (startTimestamp > 0) { - // FlxG.sound.music.time = startTimestamp - Conductor.instance.instrumentalOffset; + // FlxG.sound.music.time = startTimestamp - Conductor.instance.combinedOffset; handleSkippedNotes(); } @@ -2006,7 +2015,7 @@ 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.instrumentalOffset)); + var timeToPlayAt:Float = Math.min(FlxG.sound.music.length, Math.max(0, Conductor.instance.songPosition - Conductor.instance.combinedOffset)); trace('Resyncing vocals to ${timeToPlayAt}'); FlxG.sound.music.pause(); vocals.pause();