Skip to content

Commit bf37f44

Browse files
committed
Additional cleanup
1 parent d7df4aa commit bf37f44

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

src/funkin/vis/AudioBuffer.hx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import lime.utils.UInt16Array;
55
class AudioBuffer
66
{
77
public var data(default, null):UInt16Array;
8-
98
public var sampleRate(default, null):Float;
109
public var length(default, null):Int;
1110
public var bitsPerSample(default, null):Int;

src/funkin/vis/audioclip/frontends/LimeAudioClip.hx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class LimeAudioClip implements funkin.vis.AudioClip
4141
var bitsPerSample:Int = 0;
4242
var channels:Int = 0;
4343

44+
#if lime_vorbis
4445
// If we have a ref to a VorbisFile it should be safe to assume
4546
// this is a streamed sound!
4647
@:privateAccess
@@ -57,6 +58,7 @@ class LimeAudioClip implements funkin.vis.AudioClip
5758
channels = vorbisInfo.channels;
5859
}
5960
else
61+
#end
6062
{
6163
streamed = false;
6264

src/funkin/vis/dsp/SpectralAnalyzer.hx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package funkin.vis.dsp;
22

3-
import lime.media.vorbis.VorbisFile;
43
import haxe.io.Bytes;
54
import lime.utils.UInt8Array;
65
import flixel.FlxG;
@@ -11,6 +10,10 @@ import grig.audio.FFT;
1110
import grig.audio.FFTVisualization;
1211
import lime.media.AudioSource;
1312

13+
#if lime_vorbis
14+
import lime.media.vorbis.VorbisFile;
15+
#end
16+
1417
using grig.audio.lime.UInt8ArrayTools;
1518

1619
typedef Bar =
@@ -59,6 +62,9 @@ class SpectralAnalyzer
5962
private var barHistories = new Array<RecentPeakFinder>();
6063
private var blackmanWindow = new Array<Float>();
6164
#end
65+
#if lime_vorbis
66+
private var vorbisBuffer:UInt8Array;
67+
#end
6268

6369
private function freqToBin(freq:Float, mathType:MathType = Round):Int
6470
{
@@ -211,6 +217,8 @@ class SpectralAnalyzer
211217
#if lime_vorbis
212218
if (audioClip.streamed)
213219
{
220+
vorbisBuffer = null;
221+
214222
@:privateAccess
215223
var vorbisFile = audioSource.buffer.__srcVorbisFile;
216224

@@ -221,11 +229,11 @@ class SpectralAnalyzer
221229
vorbisFile.pcmSeek(Std.int(startFrame / (numOctets + audioClip.audioBuffer.channels)));
222230

223231
@:privateAccess
224-
_vorbisBuffer = readVorbisBuffer(vorbisFile, wantedLength);
232+
vorbisBuffer = readVorbisFileBuffer(vorbisFile, wantedLength);
225233

226234
vorbisFile.pcmSeek(prevPos);
227235

228-
signal = getSignal(_vorbisBuffer, audioClip.audioBuffer.bitsPerSample);
236+
signal = getSignal(vorbisBuffer, audioClip.audioBuffer.bitsPerSample);
229237
}
230238
else
231239
#end
@@ -284,8 +292,6 @@ class SpectralAnalyzer
284292
#end
285293
}
286294

287-
var _vorbisBuffer:UInt8Array;
288-
289295
// Prevents a memory leak by reusing array
290296
var _buffer:Array<Float> = [];
291297
function getSignal(data:lime.utils.UInt8Array, bitsPerSample:Int):Array<Float>
@@ -320,7 +326,7 @@ class SpectralAnalyzer
320326
#if lime_vorbis
321327
// Pretty much copied from
322328
// https://github.com/openfl/lime/blob/develop/src/lime/_internal/backend/native/NativeAudioSource.hx#L212
323-
function readVorbisBuffer(vorbisFile:VorbisFile, length:Int):UInt8Array
329+
function readVorbisFileBuffer(vorbisFile:VorbisFile, length:Int):UInt8Array
324330
{
325331
var buffer:UInt8Array = new UInt8Array(length);
326332

0 commit comments

Comments
 (0)