This commit is contained in:
Lasercar 2025-04-05 05:24:51 +10:00 committed by GitHub
commit 07ca0c9263
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -699,6 +699,11 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
// Audio
/**
* This is used rather than the audiotrack time if it's higher. Low playspeeds cause the audiotrack's time to sometimes be set ~10ms before somehow.
*/
var oldTime:Float;
/**
* Whether to play a metronome sound while the playhead is moving, and what volume.
*/
@ -3389,6 +3394,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
{
trace('Resetting instrumental time to ${- Conductor.instance.instrumentalOffset}ms');
audioInstTrack.time = -Conductor.instance.instrumentalOffset;
oldTime = audioInstTrack.time;
}
}
@ -3405,14 +3411,27 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
var oldStepTime:Float = Conductor.instance.currentStepTime;
var oldSongPosition:Float = Conductor.instance.songPosition + Conductor.instance.instrumentalOffset;
Conductor.instance.update(audioInstTrack.time);
// Don't go backwards in the song, only forwards
if (oldTime < audioInstTrack.time)
{
Conductor.instance.update(audioInstTrack.time);
oldTime = audioInstTrack.time;
}
else
{
Conductor.instance.update(oldTime);
trace('oldTime was used! audioInstTrack.time ${audioInstTrack.time} < oldTime ${oldTime}');
}
handleHitsounds(oldSongPosition, Conductor.instance.songPosition + Conductor.instance.instrumentalOffset);
// Resync vocals.
if (Math.abs(audioInstTrack.time - audioVocalTrackGroup.time) > 100)
{
audioVocalTrackGroup.time = audioInstTrack.time;
}
var diffStepTime:Float = Conductor.instance.currentStepTime - oldStepTime;
var diffStepTime:Float;
if ((Conductor.instance.currentStepTime - oldStepTime) < 0) diffStepTime = oldStepTime - Conductor.instance.currentStepTime;
else
diffStepTime = Conductor.instance.currentStepTime - oldStepTime;
// Move the playhead.
playheadPositionInPixels += diffStepTime * GRID_SIZE;
@ -3423,7 +3442,18 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
{
// Else, move the entire view.
var oldSongPosition:Float = Conductor.instance.songPosition + Conductor.instance.instrumentalOffset;
Conductor.instance.update(audioInstTrack.time);
// Don't go backwards in the song, only forwards
if (oldTime < audioInstTrack.time)
{
Conductor.instance.update(audioInstTrack.time);
oldTime = audioInstTrack.time;
}
else
{
Conductor.instance.update(oldTime);
trace('oldTime was used! audioInstTrack.time ${audioInstTrack.time} < oldTime ${oldTime}');
}
handleHitsounds(oldSongPosition, Conductor.instance.songPosition + Conductor.instance.instrumentalOffset);
// Resync vocals.
if (Math.abs(audioInstTrack.time - audioVocalTrackGroup.time) > 100)
@ -6093,6 +6123,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
// Update the songPosition in the Conductor.
Conductor.instance.update(audioInstTrack.time);
audioVocalTrackGroup.time = audioInstTrack.time;
oldTime = audioInstTrack.time;
}
// We need to update the note sprites because we changed the scroll position.
@ -6283,6 +6314,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
{
if (audioInstTrack != null) audioInstTrack.pause();
audioVocalTrackGroup.pause();
oldTime = 0;
playbarPlay.text = '>';
}