Skip to content

Commit

Permalink
fix: fix the user song offsets being applied incorrectly
Browse files Browse the repository at this point in the history
  • Loading branch information
JustKolosaki authored and ninjamuffin99 committed Oct 4, 2024
1 parent 0f85951 commit e0b1b01
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
2 changes: 1 addition & 1 deletion source/funkin/Conductor.hx
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ class Conductor
}

// Take into account instrumental and file format song offsets.
songPos += applyOffsets ? (instrumentalOffset + formatOffset + audioVisualOffset) : 0;
songPos += applyOffsets ? (combinedOffset) : 0;

var oldMeasure:Float = this.currentMeasure;
var oldBeat:Float = this.currentBeat;
Expand Down
27 changes: 25 additions & 2 deletions source/funkin/play/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -1457,11 +1457,34 @@ 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.combinedOffset));
var playerVoicesError:Float = 0;
var opponentVoicesError:Float = 0;

if (!startingSong && (Math.abs(FlxG.sound.music.time - correctSync) > 5 || Math.abs(vocals.checkSyncError(correctSync)) > 5))
if (vocals != null)
{
@:privateAccess // todo: maybe make the groups public :thinking:
{
vocals.playerVoices.forEachAlive(function(voice:FunkinSound) {
var currentRawVoiceTime:Float = voice.time + vocals.playerVoicesOffset;
if (Math.abs(currentRawVoiceTime - correctSync) > Math.abs(playerVoicesError)) playerVoicesError = currentRawVoiceTime - correctSync;
});

vocals.opponentVoices.forEachAlive(function(voice:FunkinSound) {
var currentRawVoiceTime:Float = voice.time + vocals.opponentVoicesOffset;
if (Math.abs(currentRawVoiceTime - correctSync) > Math.abs(opponentVoicesError)) opponentVoicesError = currentRawVoiceTime - correctSync;
});
}
}

if (!startingSong
&& (Math.abs(FlxG.sound.music.time - correctSync) > 5 || Math.abs(playerVoicesError) > 5 || Math.abs(opponentVoicesError) > 5))
{
trace("VOCALS NEED RESYNC");
if (vocals != null) trace(vocals.checkSyncError(correctSync));
if (vocals != null)
{
trace(playerVoicesError);
trace(opponentVoicesError);
}
trace(FlxG.sound.music.time);
trace(correctSync);
resyncVocals();
Expand Down

0 comments on commit e0b1b01

Please sign in to comment.