Skip to content

Commit 735bb82

Browse files
committed
anal yzerswaveform fix?
1 parent b505aa1 commit 735bb82

4 files changed

Lines changed: 31 additions & 4 deletions

File tree

assets/shaders/engine/editorWaveforms.frag

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1+
// this causes issues apparently?? need to check GLSLSourceAssembler
2+
// but it could just be unnecessary too anyway
3+
// if not, put this also in editorWaveformsRainbow.frag
4+
//#version 120
5+
16
#pragma header
2-
#version 120 // this shader doesnt require expensive calculations
37

48
const vec3 gradient1 = vec3(114.0/255.0, 81.0/255.0, 135.0/255.0);
59
const vec3 gradient2 = vec3(144.0/255.0, 80.0/255.0, 186.0/255.0);

source/funkin/backend/utils/AudioAnalyzer.hx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ final class AudioAnalyzer {
392392
default: data.sampleRate / 1000;
393393
}
394394
for (i in 0...data.channels) _mins[i] = _maxs[i] = -0x7FFFFFFF;
395-
if (startPos > endPos) _read(Math.floor(startPos * conversion), Math.floor(endPos * conversion), _analyzeRead);
395+
if (startPos < endPos) _read(Math.floor(startPos * conversion), Math.floor(endPos * conversion), _analyzeRead);
396396

397397
var min = -0x7FFFFFFF, max = -0x7FFFFFFF, v = 1 / byteSize, f:Float;
398398
for (i in 0...data.channels) {
@@ -485,7 +485,7 @@ final class AudioAnalyzer {
485485
case SECOND: data.sampleRate;
486486
default: data.sampleRate / 1000;
487487
}
488-
if (startPos > endPos) _read(Math.floor(startPos * conversion), Math.floor(endPos * conversion), callback);
488+
if (startPos < endPos) _read(Math.floor(startPos * conversion), Math.floor(endPos * conversion), callback);
489489
}
490490

491491
function _read(startSample:Int, endSample:Int, callback:ReadCallback) {

source/funkin/editors/charter/Charter.hx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -622,8 +622,25 @@ class Charter extends UIState {
622622
noteTypes = PlayState.SONG.noteTypes;
623623

624624
FlxG.sound.setMusic(FlxG.sound.load(Paths.inst(__song, __diff, PlayState.SONG.meta.instSuffix)));
625-
if (Assets.exists(Paths.voices(__song, __diff, PlayState.SONG.meta.vocalsSuffix)))
625+
626+
// force full load the audio datas for waveform, maybe in the future dont do this and
627+
// make it so it continously loads the only necessary waveform data in preview?
628+
629+
if (FlxG.sound.music.data?.buffer?.data == null) {
630+
FlxG.sound.music.data.buffer.load();
631+
FlxG.sound.music.data.buffer.decoder?.dispose();
632+
FlxG.sound.music.data.buffer.decoder = null;
633+
}
634+
635+
if (Assets.exists(Paths.voices(__song, __diff, PlayState.SONG.meta.vocalsSuffix))) {
626636
vocals = FlxG.sound.load(Paths.voices(__song, __diff, PlayState.SONG.meta.vocalsSuffix));
637+
638+
if (vocals.data?.buffer?.data == null) {
639+
vocals.data.buffer.load();
640+
vocals.data.buffer.decoder?.dispose();
641+
vocals.data.buffer.decoder = null;
642+
}
643+
}
627644
else
628645
vocals = new FlxSound();
629646

source/funkin/editors/charter/CharterStrumline.hx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,12 @@ class CharterStrumline extends UISprite {
154154
}
155155
vocals.group = FlxG.sound.defaultMusicGroup;
156156

157+
if (vocals.data?.buffer?.data == null) {
158+
vocals.data.buffer.load();
159+
vocals.data.buffer.decoder?.dispose();
160+
vocals.data.buffer.decoder = null;
161+
}
162+
157163
highlightColor = 0xFFFFFFFF;
158164
if (icons[0] != null) {
159165
var characterXML = Character.getXMLFromCharName(icons[0]);

0 commit comments

Comments
 (0)