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
This commit is contained in:
GitRan
2025-06-11 19:24:46 -05:00
committed by Abnormal
parent 8cae34eed7
commit 1f75a641e0
+6 -5
View File
@@ -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();