From 0b9c9d75333702aad4423357b732323df71d88d2 Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Wed, 9 Feb 2022 13:37:57 -0500 Subject: [PATCH] stinky dipshit specto viz optimization --- source/SpectogramSprite.hx | 24 ++++++++++++++++++++++++ source/charting/ChartingState.hx | 2 +- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/source/SpectogramSprite.hx b/source/SpectogramSprite.hx index 7f5509d74..5ad530b97 100644 --- a/source/SpectogramSprite.hx +++ b/source/SpectogramSprite.hx @@ -46,6 +46,7 @@ class SpectogramSprite extends FlxTypedSpriteGroup { var lineShit:FlxSprite = new FlxSprite(100, i / lengthOfShit * daHeight).makeGraphic(1, 1, col); lineShit.active = false; + lineShit.ID = i; add(lineShit); } } @@ -56,6 +57,8 @@ class SpectogramSprite extends FlxTypedSpriteGroup var numSamples:Int = 0; + public var wavOptimiz:Int = 10; + override function update(elapsed:Float) { switch (visType) @@ -68,6 +71,11 @@ class SpectogramSprite extends FlxTypedSpriteGroup default: } + forEach(spr -> + { + spr.visible = FlxG.game.ticks % wavOptimiz == spr.ID % wavOptimiz; + }); + // if visType is static, call updateVisulizer() manually whenever you want to update it! super.update(elapsed); @@ -110,6 +118,8 @@ class SpectogramSprite extends FlxTypedSpriteGroup group.members[i].setGraphicSize(Std.int(Math.max(line.length, 1)), Std.int(1)); group.members[i].angle = line.degrees; } + + wavOptimiz = 1; // hard set wavOptimiz to 1 so its a pure thing } } @@ -234,6 +244,8 @@ class SpectogramSprite extends FlxTypedSpriteGroup } } + var curTime:Float = 0; + public function updateVisulizer():Void { if (vis.snd != null) @@ -247,7 +259,19 @@ class SpectogramSprite extends FlxTypedSpriteGroup if (vis.snd.playing) remappedShit = Std.int(FlxMath.remapToRange(vis.snd.time, 0, vis.snd.length, 0, numSamples)); else + { + if (curTime == Conductor.songPosition) + { + wavOptimiz = 3; + return; // already did shit, so finishes function early + } + + curTime = Conductor.songPosition; + remappedShit = Std.int(FlxMath.remapToRange(Conductor.songPosition, 0, vis.snd.length, 0, numSamples)); + } + + wavOptimiz = 8; var i = remappedShit; var prevLine:FlxPoint = new FlxPoint(); diff --git a/source/charting/ChartingState.hx b/source/charting/ChartingState.hx index 84f9b38ae..185c3dee6 100644 --- a/source/charting/ChartingState.hx +++ b/source/charting/ChartingState.hx @@ -1166,7 +1166,7 @@ class ChartingState extends MusicBeatState } // generates the cool sidebar shit - if (sidePreview != null) + if (sidePreview != null && sidePreview.active) { sidePreview.drawRect(0, 0, 40, FlxG.height, 0xFF444444);