From 681cfa0883d9ac823cc768301708bc5d14bf04d3 Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Tue, 13 Feb 2024 01:16:09 -0500 Subject: [PATCH] chart editor waveform fixes for single vocal audio files --- .../charting/toolboxes/ChartEditorFreeplayToolbox.hx | 2 +- .../charting/toolboxes/ChartEditorOffsetsToolbox.hx | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/source/funkin/ui/debug/charting/toolboxes/ChartEditorFreeplayToolbox.hx b/source/funkin/ui/debug/charting/toolboxes/ChartEditorFreeplayToolbox.hx index 8d3554a08..c384e7a6d 100644 --- a/source/funkin/ui/debug/charting/toolboxes/ChartEditorFreeplayToolbox.hx +++ b/source/funkin/ui/debug/charting/toolboxes/ChartEditorFreeplayToolbox.hx @@ -290,7 +290,7 @@ class ChartEditorFreeplayToolbox extends ChartEditorBaseToolbox // waveformMusic.waveform.forceUpdate = true; var perfStart = haxe.Timer.stamp(); var waveformData1 = playerVoice.waveformData; - var waveformData2 = opponentVoice.waveformData; + var waveformData2 = opponentVoice?.waveformData ?? playerVoice.waveformData; // this null check is for songs that only have 1 vocals file! var waveformData3 = chartEditorState.audioInstTrack.waveformData; var waveformData = waveformData1.merge(waveformData2).merge(waveformData3); trace('Waveform data merging took: ${haxe.Timer.stamp() - perfStart} seconds'); diff --git a/source/funkin/ui/debug/charting/toolboxes/ChartEditorOffsetsToolbox.hx b/source/funkin/ui/debug/charting/toolboxes/ChartEditorOffsetsToolbox.hx index 67ca82b1b..fd9209294 100644 --- a/source/funkin/ui/debug/charting/toolboxes/ChartEditorOffsetsToolbox.hx +++ b/source/funkin/ui/debug/charting/toolboxes/ChartEditorOffsetsToolbox.hx @@ -276,8 +276,13 @@ class ChartEditorOffsetsToolbox extends ChartEditorBaseToolbox // Build opponent waveform. // waveformOpponent.waveform.forceUpdate = true; - waveformOpponent.waveform.waveformData = opponentVoice.waveformData; - waveformOpponent.waveform.duration = opponentVoice.length / Constants.MS_PER_SEC; + // note: if song only has one set of vocals (Vocals.ogg/mp3) then this is null and crashes charting editor + // so we null check + if (opponentVoice != null) + { + waveformOpponent.waveform.waveformData = opponentVoice.waveformData; + waveformOpponent.waveform.duration = opponentVoice.length / Constants.MS_PER_SEC; + } // Build instrumental waveform. // waveformInstrumental.waveform.forceUpdate = true;