1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2024-11-09 16:24:42 +00:00
Funkin/source/VisShit.hx

43 lines
827 B
Haxe
Raw Normal View History

package;
import flixel.system.FlxSound;
import lime.utils.Int16Array;
class VisShit
{
public var snd:FlxSound;
public var setBuffer:Bool = false;
public var audioData:Int16Array;
public var sampleRate:Int = 44100; // default, ez?
2021-10-08 01:01:46 +00:00
public var numSamples:Int = 0;
public function new(snd:FlxSound)
{
this.snd = snd;
}
public function checkAndSetBuffer()
{
if (snd != null && snd.playing)
{
if (!setBuffer)
{
// Math.pow3
@:privateAccess
var buf = snd._channel.__source.buffer;
// @:privateAccess
audioData = cast buf.data; // jank and hacky lol! kinda busted on HTML5 also!!
sampleRate = buf.sampleRate;
trace('got audio buffer shit');
trace(sampleRate);
trace(buf.bitsPerSample);
setBuffer = true;
2021-10-08 01:01:46 +00:00
numSamples = Std.int(audioData.length / 2);
}
}
}
}