Chart Seek Bugfix (#545)

* fix lag spike when starting playback from middle of chart

further optimization to GameManager which considerably reduces garbage generation

* let dsp offset be calculated on playback start if needed
This commit is contained in:
minenice55
2023-09-12 16:38:28 -04:00
committed by GitHub
parent 60d29f19c6
commit dd461216d9
5 changed files with 90 additions and 37 deletions

View File

@ -170,11 +170,8 @@ namespace HeavenStudio
var chart = GameManager.instance.Beatmap;
double offset = chart.data.offset;
double dspTime = AudioSettings.dspTime;
absTimeAdjust = 0;
dspStart = dspTime;
startTime = DateTime.Now;
GameManager.instance.SortEventsList();
dspStart = dspTime;
startPos = GetSongPosFromBeat(beat);
firstBeatOffset = offset;
@ -188,20 +185,21 @@ namespace HeavenStudio
{
musicScheduledTime = dspTime + musicStartDelay / SongPitch;
musicScheduledPitch = SongPitch;
musicSource.PlayScheduled(musicScheduledTime);
}
else
{
musicScheduledTime = dspTime;
musicScheduledPitch = SongPitch;
musicSource.Play();
}
musicSource.PlayScheduled(musicScheduledTime);
}
songPosBeat = GetBeatFromSongPos(time);
startBeat = songPosBeat;
absTimeAdjust = 0;
startTime = DateTime.Now;
isPlaying = true;
isPaused = false;
}