From 151c96afc81058dd4707fcd0035051824947b6c8 Mon Sep 17 00:00:00 2001 From: MtH Date: Thu, 10 Mar 2022 01:07:39 +0100 Subject: [PATCH 1/2] voicesgroup resync --- source/PlayState.hx | 4 ++-- source/VoicesGroup.hx | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/source/PlayState.hx b/source/PlayState.hx index 7fd5c64d2..a504c498a 100644 --- a/source/PlayState.hx +++ b/source/PlayState.hx @@ -1839,7 +1839,6 @@ class PlayState extends MusicBeatState { if (_exiting) return; - vocals.pause(); FlxG.sound.music.play(); Conductor.songPosition = FlxG.sound.music.time + Conductor.offset; @@ -2895,8 +2894,9 @@ class PlayState extends MusicBeatState override function stepHit() { super.stepHit(); + if (Math.abs(FlxG.sound.music.time - (Conductor.songPosition - Conductor.offset)) > 20 - || (SONG.needsVoices && Math.abs(vocals.time - (Conductor.songPosition - Conductor.offset)) > 20)) + || Math.abs(vocals.checkSyncError(Conductor.songPosition - Conductor.offset)) > 20) { resyncVocals(); } diff --git a/source/VoicesGroup.hx b/source/VoicesGroup.hx index 459b952da..86f22d1d8 100644 --- a/source/VoicesGroup.hx +++ b/source/VoicesGroup.hx @@ -36,6 +36,31 @@ class VoicesGroup extends FlxTypedGroup } } + /** + * Finds the largest deviation from the desired time inside this VoicesGroup. + * + * @param targetTime The time to check against. + * If none is provided, it checks the time of all members against the first member of this VoicesGroup. + * @return The largest deviation from the target time found. + */ + public function checkSyncError(?targetTime:Float):Float + { + var error:Float = 0; + + forEachAlive(function(snd) + { + if (targetTime == null) + targetTime = snd.time; + else + { + var diff:Float = snd.time - targetTime; + if (Math.abs(diff) > Math.abs(error)) + error = diff; + } + }); + return error; + } + // prob a better / cleaner way to do all these forEach stuff? public function pause() { From 449af0ea186e134a48db36199959c1b2ee8c1779 Mon Sep 17 00:00:00 2001 From: MtH Date: Thu, 10 Mar 2022 01:33:05 +0100 Subject: [PATCH 2/2] rise from your grave --- source/NoteSplash.hx | 2 ++ source/PlayState.hx | 1 + 2 files changed, 3 insertions(+) diff --git a/source/NoteSplash.hx b/source/NoteSplash.hx index 36acc86a0..b23daefe6 100644 --- a/source/NoteSplash.hx +++ b/source/NoteSplash.hx @@ -22,6 +22,8 @@ class NoteSplash extends FlxSprite setupNoteSplash(x, y, noteData); + antialiasing = true; + // alpha = 0.75; } diff --git a/source/PlayState.hx b/source/PlayState.hx index a504c498a..345db7912 100644 --- a/source/PlayState.hx +++ b/source/PlayState.hx @@ -1839,6 +1839,7 @@ class PlayState extends MusicBeatState { if (_exiting) return; + vocals.pause(); FlxG.sound.music.play(); Conductor.songPosition = FlxG.sound.music.time + Conductor.offset;