mirror of
https://github.com/ninjamuffin99/Funkin.git
synced 2024-11-09 00:04:42 +00:00
Replace waveform renderer with the newer, more performant version.
This commit is contained in:
parent
e8fa7f9c70
commit
a1cff6be50
|
@ -23,6 +23,7 @@ import flixel.system.FlxAssets.FlxSoundAsset;
|
|||
import flixel.tweens.FlxEase;
|
||||
import flixel.tweens.FlxTween;
|
||||
import flixel.tweens.misc.VarTween;
|
||||
import funkin.audio.waveform.WaveformSprite;
|
||||
import haxe.ui.Toolkit;
|
||||
import flixel.util.FlxColor;
|
||||
import flixel.util.FlxSort;
|
||||
|
@ -129,7 +130,6 @@ import haxe.ui.focus.FocusManager;
|
|||
import openfl.display.BitmapData;
|
||||
import funkin.audio.visualize.PolygonSpectogram;
|
||||
import flixel.group.FlxGroup.FlxTypedGroup;
|
||||
import funkin.audio.visualize.PolygonVisGroup;
|
||||
import flixel.input.mouse.FlxMouseEvent;
|
||||
import flixel.text.FlxText;
|
||||
import flixel.system.debug.log.LogStyle;
|
||||
|
@ -395,13 +395,12 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
|
|||
gridTiledSprite.y = -scrollPositionInPixels + (GRID_INITIAL_Y_POS);
|
||||
measureTicks.y = gridTiledSprite.y;
|
||||
|
||||
if (audioVisGroup != null && audioVisGroup.playerVis != null)
|
||||
for (member in audioWaveforms.members)
|
||||
{
|
||||
audioVisGroup.playerVis.y = Math.max(gridTiledSprite.y, GRID_INITIAL_Y_POS - GRID_TOP_PAD);
|
||||
}
|
||||
if (audioVisGroup != null && audioVisGroup.opponentVis != null)
|
||||
{
|
||||
audioVisGroup.opponentVis.y = Math.max(gridTiledSprite.y, GRID_INITIAL_Y_POS - GRID_TOP_PAD);
|
||||
member.time = scrollPositionInMs / Constants.MS_PER_SEC;
|
||||
|
||||
// Doing this desyncs the waveforms from the grid.
|
||||
// member.y = Math.max(this.gridTiledSprite?.y ?? 0.0, ChartEditorState.GRID_INITIAL_Y_POS - ChartEditorState.GRID_TOP_PAD);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -503,8 +502,6 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
|
|||
|
||||
function get_playheadPositionInMs():Float
|
||||
{
|
||||
if (audioVisGroup != null && audioVisGroup.playerVis != null)
|
||||
audioVisGroup.playerVis.realtimeStartOffset = -Conductor.instance.getStepTimeInMs(playheadPositionInSteps);
|
||||
return Conductor.instance.getStepTimeInMs(playheadPositionInSteps);
|
||||
}
|
||||
|
||||
|
@ -512,7 +509,6 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
|
|||
{
|
||||
playheadPositionInSteps = Conductor.instance.getTimeInSteps(value);
|
||||
|
||||
if (audioVisGroup != null && audioVisGroup.playerVis != null) audioVisGroup.playerVis.realtimeStartOffset = -value;
|
||||
return value;
|
||||
}
|
||||
|
||||
|
@ -1134,11 +1130,11 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
|
|||
var audioVocalTrackGroup:Null<VoicesGroup> = null;
|
||||
|
||||
/**
|
||||
* The audio vis for the inst/vocals.
|
||||
* The audio waveform visualization for the inst/vocals.
|
||||
* `null` until vocal track(s) are loaded.
|
||||
* When switching characters, the elements of the PolygonVisGroup will be swapped to match the new character.
|
||||
* When switching characters, the elements will be swapped to match the new character.
|
||||
*/
|
||||
var audioVisGroup:Null<PolygonVisGroup> = null;
|
||||
var audioWaveforms:FlxTypedSpriteGroup<WaveformSprite> = new FlxTypedSpriteGroup<WaveformSprite>();
|
||||
|
||||
/**
|
||||
* A map of the audio tracks for each character's vocals.
|
||||
|
@ -2302,8 +2298,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
|
|||
add(healthIconBF);
|
||||
healthIconBF.zIndex = 30;
|
||||
|
||||
audioVisGroup = new PolygonVisGroup();
|
||||
add(audioVisGroup);
|
||||
add(audioWaveforms);
|
||||
}
|
||||
|
||||
function buildMeasureTicks():Void
|
||||
|
|
|
@ -3,11 +3,14 @@ package funkin.ui.debug.charting.handlers;
|
|||
import flixel.system.FlxAssets.FlxSoundAsset;
|
||||
import flixel.system.FlxSound;
|
||||
import funkin.audio.VoicesGroup;
|
||||
import funkin.audio.visualize.PolygonVisGroup;
|
||||
import funkin.audio.FunkinSound;
|
||||
import funkin.play.character.BaseCharacter.CharacterType;
|
||||
import funkin.util.FileUtil;
|
||||
import funkin.util.assets.SoundUtil;
|
||||
import funkin.audio.waveform.WaveformData;
|
||||
import funkin.audio.waveform.WaveformDataParser;
|
||||
import funkin.audio.waveform.WaveformSprite;
|
||||
import flixel.util.FlxColor;
|
||||
import haxe.io.Bytes;
|
||||
import haxe.io.Path;
|
||||
import openfl.utils.Assets;
|
||||
|
@ -175,7 +178,6 @@ class ChartEditorAudioHandler
|
|||
var vocalTrack:Null<FunkinSound> = SoundUtil.buildSoundFromBytes(vocalTrackData);
|
||||
|
||||
if (state.audioVocalTrackGroup == null) state.audioVocalTrackGroup = new VoicesGroup();
|
||||
if (state.audioVisGroup == null) state.audioVisGroup = new PolygonVisGroup();
|
||||
|
||||
if (vocalTrack != null)
|
||||
{
|
||||
|
@ -183,24 +185,47 @@ class ChartEditorAudioHandler
|
|||
{
|
||||
case BF:
|
||||
state.audioVocalTrackGroup.addPlayerVoice(vocalTrack);
|
||||
state.audioVisGroup.addPlayerVis(vocalTrack);
|
||||
state.audioVisGroup.playerVis.x = 885;
|
||||
state.audioVisGroup.playerVis.realtimeVisLenght = Conductor.instance.getStepTimeInMs(16) * 0.00195;
|
||||
state.audioVisGroup.playerVis.daHeight = (ChartEditorState.GRID_SIZE) * 16;
|
||||
state.audioVisGroup.playerVis.detail = 1;
|
||||
state.audioVisGroup.playerVis.y = Math.max(state.gridTiledSprite?.y ?? 0.0, ChartEditorState.GRID_INITIAL_Y_POS - ChartEditorState.GRID_TOP_PAD);
|
||||
|
||||
var waveformData:Null<WaveformData> = WaveformDataParser.interpretFlxSound(vocalTrack);
|
||||
if (waveformData != null)
|
||||
{
|
||||
var duration:Float = Conductor.instance.getStepTimeInMs(16) * 0.001;
|
||||
var waveformSprite:WaveformSprite = new WaveformSprite(waveformData, VERTICAL, FlxColor.WHITE);
|
||||
waveformSprite.x = 840;
|
||||
waveformSprite.y = Math.max(state.gridTiledSprite?.y ?? 0.0, ChartEditorState.GRID_INITIAL_Y_POS - ChartEditorState.GRID_TOP_PAD);
|
||||
waveformSprite.height = (ChartEditorState.GRID_SIZE) * 16;
|
||||
waveformSprite.width = (ChartEditorState.GRID_SIZE) * 2;
|
||||
waveformSprite.time = 0;
|
||||
waveformSprite.duration = duration;
|
||||
state.audioWaveforms.add(waveformSprite);
|
||||
}
|
||||
else
|
||||
{
|
||||
trace('[WARN] Failed to parse waveform data for vocal track.');
|
||||
}
|
||||
|
||||
state.audioVocalTrackGroup.playerVoicesOffset = state.currentSongOffsets.getVocalOffset(charId);
|
||||
return true;
|
||||
case DAD:
|
||||
state.audioVocalTrackGroup.addOpponentVoice(vocalTrack);
|
||||
state.audioVisGroup.addOpponentVis(vocalTrack);
|
||||
state.audioVisGroup.opponentVis.x = 405;
|
||||
|
||||
state.audioVisGroup.opponentVis.realtimeVisLenght = Conductor.instance.getStepTimeInMs(16) * 0.00195;
|
||||
state.audioVisGroup.opponentVis.daHeight = (ChartEditorState.GRID_SIZE) * 16;
|
||||
state.audioVisGroup.opponentVis.detail = 1;
|
||||
state.audioVisGroup.opponentVis.y = Math.max(state.gridTiledSprite?.y ?? 0.0, ChartEditorState.GRID_INITIAL_Y_POS - ChartEditorState.GRID_TOP_PAD);
|
||||
var waveformData:Null<WaveformData> = WaveformDataParser.interpretFlxSound(vocalTrack);
|
||||
if (waveformData != null)
|
||||
{
|
||||
var duration:Float = Conductor.instance.getStepTimeInMs(16) * 0.001;
|
||||
var waveformSprite:WaveformSprite = new WaveformSprite(waveformData, VERTICAL, FlxColor.WHITE);
|
||||
waveformSprite.x = 360;
|
||||
waveformSprite.y = Math.max(state.gridTiledSprite?.y ?? 0.0, ChartEditorState.GRID_INITIAL_Y_POS - ChartEditorState.GRID_TOP_PAD);
|
||||
waveformSprite.height = (ChartEditorState.GRID_SIZE) * 16;
|
||||
waveformSprite.width = (ChartEditorState.GRID_SIZE) * 2;
|
||||
waveformSprite.time = 0;
|
||||
waveformSprite.duration = duration;
|
||||
state.audioWaveforms.add(waveformSprite);
|
||||
}
|
||||
else
|
||||
{
|
||||
trace('[WARN] Failed to parse waveform data for vocal track.');
|
||||
}
|
||||
|
||||
state.audioVocalTrackGroup.opponentVoicesOffset = state.currentSongOffsets.getVocalOffset(charId);
|
||||
|
||||
|
|
Loading…
Reference in a new issue