make it compile on html5
Windows Builds / Windows Build (push) Has been cancelled
Windows Builds / Windows Debug Build (push) Has been cancelled
Mac OS Builds / Mac OS Build (push) Has been cancelled
Mac OS Builds / Mac OS Debug Build (push) Has been cancelled
Linux Builds / Linux Build (push) Has been cancelled
Linux Builds / Linux Debug Build (push) Has been cancelled
Windows Builds / Windows Build (push) Has been cancelled
Windows Builds / Windows Debug Build (push) Has been cancelled
Mac OS Builds / Mac OS Build (push) Has been cancelled
Mac OS Builds / Mac OS Debug Build (push) Has been cancelled
Linux Builds / Linux Build (push) Has been cancelled
Linux Builds / Linux Debug Build (push) Has been cancelled
This commit is contained in:
@@ -2,7 +2,9 @@ package funkin.backend.utils;
|
||||
|
||||
import flixel.sound.FlxSound;
|
||||
import lime.media.AudioBuffer;
|
||||
#if !js
|
||||
import lime.utils.ArrayBufferView.ArrayBufferIO;
|
||||
#end
|
||||
import lime.utils.ArrayBuffer;
|
||||
|
||||
#if (lime_cffi && lime_vorbis)
|
||||
@@ -30,6 +32,7 @@ final class AudioAnalyzer {
|
||||
* @param wordSize How many bytes to get with to one byte (Usually it's bitsPerSample / 8 or bitsPerSample >> 3).
|
||||
* @return Byte from the audio buffer with specified position.
|
||||
*/
|
||||
#if sys
|
||||
public static function getByte(buffer:ArrayBuffer, position:Int, wordSize:Int):Int {
|
||||
if (wordSize == 2) return inline ArrayBufferIO.getInt16(buffer, position);
|
||||
else if (wordSize == 3) {
|
||||
@@ -40,6 +43,19 @@ final class AudioAnalyzer {
|
||||
else if (wordSize == 4) return inline ArrayBufferIO.getInt32(buffer, position);
|
||||
else return inline ArrayBufferIO.getUint8(buffer, position) - 128;
|
||||
}
|
||||
#elseif js
|
||||
public static function getByte(buffer:lime.utils.UInt8Array, position:Int, wordSize:Int):Int {
|
||||
var view = new lime.utils.DataView(buffer.buffer);
|
||||
if (wordSize == 2) return inline view.getInt16(position, true);
|
||||
else if (wordSize == 3) {
|
||||
var b = inline view.getUint16(position, true) | (view.getUint8(position + 2) << 16);
|
||||
if (b & 0x800000 != 0) return b - 0x1000000;
|
||||
else return b;
|
||||
}
|
||||
else if (wordSize == 4) return inline view.getInt32(position, true);
|
||||
else return inline view.getUint8(position) - 128;
|
||||
}
|
||||
#end
|
||||
|
||||
/**
|
||||
* Gets levels from the frequencies with specified sample rate.
|
||||
@@ -450,12 +466,16 @@ final class AudioAnalyzer {
|
||||
}
|
||||
|
||||
inline function __readData(startPos:Float, endPos:Float, callback:AudioAnalyzerCallback) {
|
||||
var pos = Math.floor(startPos * __toBits), end = Math.min(Math.floor(endPos * __toBits), buffer.data.buffer.length), c = 0;
|
||||
var pos = Math.floor(startPos * __toBits), end = Math.min(Math.floor(endPos * __toBits), buffer.data.buffer.byteLength), c = 0;
|
||||
pos -= pos % __sampleSize;
|
||||
end -= end % __sampleSize;
|
||||
|
||||
while (pos < end) {
|
||||
#if sys
|
||||
callback(getByte(buffer.data.buffer, pos, __wordSize), c);
|
||||
#elseif js
|
||||
callback(getByte(buffer.data, pos, __wordSize), c);
|
||||
#end
|
||||
if (++c > buffer.channels) c = 0;
|
||||
pos += __wordSize;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package funkin.backend.utils;
|
||||
|
||||
import lime.utils.AssetType;
|
||||
#if cpp
|
||||
import cpp.Float64;
|
||||
#end
|
||||
@@ -1240,9 +1241,9 @@ final class CoolUtil
|
||||
* @return Bool
|
||||
*/
|
||||
public static function imageHasFrameData(path:String):String {
|
||||
if (FileSystem.exists(Path.withExtension(path, "xml"))) return "xml";
|
||||
if (FileSystem.exists(Path.withExtension(path, "txt"))) return "txt";
|
||||
if (FileSystem.exists(Path.withExtension(path, "json"))) return "json";
|
||||
if (Paths.assetsTree.existsSpecific(Path.withExtension(path, "xml"), AssetType.TEXT)) return "xml";
|
||||
if (Paths.assetsTree.existsSpecific(Path.withExtension(path, "txt"), AssetType.TEXT)) return "txt";
|
||||
if (Paths.assetsTree.existsSpecific(Path.withExtension(path, "json"), AssetType.TEXT)) return "json";
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package funkin.backend.utils;
|
||||
|
||||
#if !macro
|
||||
import funkin.backend.system.Logs;
|
||||
#end
|
||||
#if (target.threaded)
|
||||
import sys.thread.Deque;
|
||||
import sys.thread.Thread;
|
||||
@@ -8,9 +11,6 @@ import sys.thread.Mutex;
|
||||
private typedef Thread = Dynamic;
|
||||
#end
|
||||
|
||||
#if !macro
|
||||
import funkin.backend.system.Logs;
|
||||
#end
|
||||
|
||||
final class ThreadUtil {
|
||||
inline static function error(text:String) {
|
||||
|
||||
@@ -254,6 +254,7 @@ final class TranslationUtil
|
||||
|
||||
// todo make it load the default languages in a second string map
|
||||
|
||||
#if MOD_SUPPORT
|
||||
for(mod in ModsFolder.getLoadedModsLibs(true)) for(file in mod.getFiles("assets/" + mainPath).sortAlphabetically().map((v)->'$mainPath/$v')) {
|
||||
if(Path.extension(file).toLowerCase() != "xml") continue;
|
||||
|
||||
@@ -277,6 +278,7 @@ final class TranslationUtil
|
||||
|
||||
parseXml(langNode, prefix);
|
||||
}
|
||||
#end
|
||||
|
||||
for(pair in translations) {
|
||||
var node = pair.node;
|
||||
|
||||
Reference in New Issue
Block a user