From a750cc1620a4318c619b786189cb9c20892076f5 Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Fri, 1 Dec 2023 19:58:58 -0500 Subject: [PATCH] vis wips wips wips --- source/funkin/audio/visualize/PolygonSpectogram.hx | 5 +++-- source/funkin/audio/visualize/PolygonVisGroup.hx | 5 +++-- source/funkin/ui/debug/charting/ChartEditorState.hx | 9 +++++++++ .../debug/charting/handlers/ChartEditorAudioHandler.hx | 6 ++++++ 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/source/funkin/audio/visualize/PolygonSpectogram.hx b/source/funkin/audio/visualize/PolygonSpectogram.hx index 7bcebfd25..37a6c15d1 100644 --- a/source/funkin/audio/visualize/PolygonSpectogram.hx +++ b/source/funkin/audio/visualize/PolygonSpectogram.hx @@ -16,6 +16,7 @@ class PolygonSpectogram extends MeshRender public var visType:VISTYPE = UPDATED; public var daHeight:Float = FlxG.height; public var realtimeVisLenght:Float = 0.2; + public var realtimeStartOffset:Float = 0; var numSamples:Int = 0; var setBuffer:Bool = false; @@ -86,7 +87,7 @@ class PolygonSpectogram extends MeshRender var prevPoint:FlxPoint = new FlxPoint(); - var funnyPixels:Int = Std.int(daHeight); // sorta redundant but just need it for different var... + var funnyPixels:Int = Std.int(daHeight * detail); // sorta redundant but just need it for different var... if (prevAudioData == audioData.subarray(startSample, startSample + samplesToGen)) return; // optimize / finish funciton here, no need to re-render @@ -130,7 +131,7 @@ class PolygonSpectogram extends MeshRender curTime = vis.snd.time; - if (vis.snd.time < vis.snd.length - realtimeVisLenght) generateSection(vis.snd.time, realtimeVisLenght); + if (vis.snd.time < vis.snd.length - realtimeVisLenght) generateSection(vis.snd.time + realtimeStartOffset, realtimeVisLenght); } } } diff --git a/source/funkin/audio/visualize/PolygonVisGroup.hx b/source/funkin/audio/visualize/PolygonVisGroup.hx index 03522971c..2903eaccd 100644 --- a/source/funkin/audio/visualize/PolygonVisGroup.hx +++ b/source/funkin/audio/visualize/PolygonVisGroup.hx @@ -6,8 +6,9 @@ import flixel.sound.FlxSound; class PolygonVisGroup extends FlxTypedGroup { - var playerVis:PolygonSpectogram; - var opponentVis:PolygonSpectogram; + public var playerVis:PolygonSpectogram; + public var opponentVis:PolygonSpectogram; + var instVis:PolygonSpectogram; public function new() diff --git a/source/funkin/ui/debug/charting/ChartEditorState.hx b/source/funkin/ui/debug/charting/ChartEditorState.hx index 3528801de..28dbf54f3 100644 --- a/source/funkin/ui/debug/charting/ChartEditorState.hx +++ b/source/funkin/ui/debug/charting/ChartEditorState.hx @@ -330,6 +330,11 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState { gridTiledSprite.y = -scrollPositionInPixels + (MENU_BAR_HEIGHT + GRID_TOP_PAD); gridPlayheadScrollArea.y = gridTiledSprite.y; + + if (audioVisGroup != null && audioVisGroup.playerVis != null) + { + audioVisGroup.playerVis.y = Math.max(gridTiledSprite.y, MENU_BAR_HEIGHT); + } } } @@ -428,12 +433,16 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState function get_playheadPositionInMs():Float { + if (audioVisGroup != null && audioVisGroup.playerVis != null) + audioVisGroup.playerVis.realtimeStartOffset = -Conductor.getStepTimeInMs(playheadPositionInSteps); return Conductor.getStepTimeInMs(playheadPositionInSteps); } function set_playheadPositionInMs(value:Float):Float { playheadPositionInSteps = Conductor.getTimeInSteps(value); + + if (audioVisGroup != null && audioVisGroup.playerVis != null) audioVisGroup.playerVis.realtimeStartOffset = -value; return value; } diff --git a/source/funkin/ui/debug/charting/handlers/ChartEditorAudioHandler.hx b/source/funkin/ui/debug/charting/handlers/ChartEditorAudioHandler.hx index b524de0c8..74f9983f1 100644 --- a/source/funkin/ui/debug/charting/handlers/ChartEditorAudioHandler.hx +++ b/source/funkin/ui/debug/charting/handlers/ChartEditorAudioHandler.hx @@ -178,9 +178,15 @@ class ChartEditorAudioHandler case BF: state.audioVocalTrackGroup.addPlayerVoice(vocalTrack); state.audioVisGroup.addPlayerVis(vocalTrack); + state.audioVisGroup.playerVis.x = 885; + state.audioVisGroup.playerVis.realtimeVisLenght = Conductor.getStepTimeInMs(16) * 0.00195; + state.audioVisGroup.playerVis.daHeight = (ChartEditorState.GRID_SIZE) * 16; + state.audioVisGroup.playerVis.detail = 1; return true; case DAD: state.audioVocalTrackGroup.addOpponentVoice(vocalTrack); + state.audioVisGroup.addOpponentVis(vocalTrack); + state.audioVisGroup.opponentVis.x = 435; return true; case OTHER: state.audioVocalTrackGroup.add(vocalTrack);