11package funkin .ui .debug ;
22
3+ import funkin .util .assets .SoundUtil ;
34import flixel .math .FlxRect ;
45import flixel .FlxSprite ;
56import flixel .util .FlxColor ;
67import funkin .audio .FunkinSound ;
78import funkin .audio .waveform .WaveformData ;
89import funkin .audio .waveform .WaveformDataParser ;
10+ import funkin .audio .waveform .WaveformSprite ;
911import funkin .graphics .rendering .MeshRender ;
1012
1113class WaveformTestState extends MusicBeatState
@@ -20,7 +22,7 @@ class WaveformTestState extends MusicBeatState
2022
2123 var waveformAudio : FunkinSound ;
2224
23- // var waveformSprite:WaveformSprite;
25+ var waveformSprite : WaveformSprite ;
2426 // var waveformSprite2:WaveformSprite;
2527 var timeMarker : FlxSprite ;
2628
@@ -37,30 +39,34 @@ class WaveformTestState extends MusicBeatState
3739 testSprite .clipRect = new FlxRect (0 , 0 , FlxG .width , FlxG .height );
3840 // add(testSprite);
3941
40- waveformAudio = FunkinSound .load (Paths .inst (' bopeebo' , ' -erect' ));
41-
42- waveformData = WaveformDataParser .interpretFlxSound (waveformAudio );
42+ Assets .loadSound (Paths .music (' chartEditorLoop/chartEditorLoop' )).onComplete (sound -> {
43+ waveformAudio = FunkinSound .load (sound );
44+ waveformData = WaveformDataParser .interpretFlxSound (waveformAudio );
45+
46+ waveformSprite = WaveformSprite .buildFromWaveformData (waveformData , HORIZONTAL , FlxColor .fromString (" #ADD8E6" ));
47+ waveformSprite .duration = 5.0 * 160 ;
48+ waveformSprite .width = FlxG .width * 160 ;
49+ waveformSprite .height = FlxG .height ; // / 2;
50+ waveformSprite .amplitude = 2.0 ;
51+ waveformSprite .minWaveformSize = 25 ;
52+ waveformSprite .clipRect = new FlxRect (0 , 0 , FlxG .width , FlxG .height );
53+ add (waveformSprite );
54+
55+ //
56+ // waveformSprite2 = WaveformSprite.buildFromWaveformData(waveformData2, HORIZONTAL, FlxColor.fromString("#FF0000"), 5.0);
57+ // waveformSprite2.width = FlxG.width;
58+ // waveformSprite2.height = FlxG.height / 2;
59+ // waveformSprite2.y = FlxG.height / 2;
60+ // add(waveformSprite2);
61+ }).onError (e -> {
62+ throw ' FUCKKKK $e ' ;
63+ });
4364
4465 polygonSprite = new MeshRender (FlxG .width / 2 , FlxG .height / 2 , FlxColor .WHITE );
4566
4667 setPolygonVertices (vertexCount );
4768 add (polygonSprite );
4869
49- // waveformSprite = WaveformSprite.buildFromWaveformData(waveformData, HORIZONTAL, FlxColor.fromString("#ADD8E6"));
50- // waveformSprite.duration = 5.0 * 160;
51- // waveformSprite.width = FlxG.width * 160;
52- // waveformSprite.height = FlxG.height; // / 2;
53- // waveformSprite.amplitude = 2.0;
54- // waveformSprite.minWaveformSize = 25;
55- // waveformSprite.clipRect = new FlxRect(0, 0, FlxG.width, FlxG.height);
56- // add(waveformSprite);
57- //
58- // waveformSprite2 = WaveformSprite.buildFromWaveformData(waveformData2, HORIZONTAL, FlxColor.fromString("#FF0000"), 5.0);
59- // waveformSprite2.width = FlxG.width;
60- // waveformSprite2.height = FlxG.height / 2;
61- // waveformSprite2.y = FlxG.height / 2;
62- // add(waveformSprite2);
63-
6470 timeMarker = new FlxSprite (0 , FlxG .height * 1 / 6 );
6571 timeMarker .makeGraphic (1 , Std .int (FlxG .height * 2 / 3 ), FlxColor .RED );
6672 add (timeMarker );
@@ -74,13 +80,13 @@ class WaveformTestState extends MusicBeatState
7480
7581 if (FlxG .keys .justPressed .SPACE )
7682 {
77- if (waveformAudio .isPlaying )
83+ if (waveformAudio != null && waveformAudio .isPlaying )
7884 {
79- waveformAudio .stop ();
85+ waveformAudio ? .stop ();
8086 }
8187 else
8288 {
83- waveformAudio .play ();
89+ waveformAudio ? .play ();
8490 }
8591 }
8692
@@ -98,11 +104,11 @@ class WaveformTestState extends MusicBeatState
98104 // }
99105 }
100106
101- if (waveformAudio .isPlaying )
107+ if (waveformAudio ? .isPlaying ?? false )
102108 {
103109 // waveformSprite takes a time in fractional seconds, not milliseconds.
104110 var timeSeconds = waveformAudio .time / 1000 ;
105- // waveformSprite.time = timeSeconds;
111+ waveformSprite .time = timeSeconds ;
106112 // waveformSprite2.time = timeSeconds;
107113 }
108114
0 commit comments