mirror of
https://github.com/FunkinCrew/Funkin.git
synced 2024-11-30 11:26:53 -05:00
24 lines
680 B
Haxe
24 lines
680 B
Haxe
package funkin.util.assets;
|
|
|
|
import haxe.io.Bytes;
|
|
import openfl.media.Sound as OpenFLSound;
|
|
import funkin.audio.FunkinSound;
|
|
|
|
class SoundUtil
|
|
{
|
|
/**
|
|
* Convert byte data into a playable sound.
|
|
*
|
|
* @param input The byte data.
|
|
* @return The playable sound, or `null` if loading failed.
|
|
*/
|
|
public static function buildSoundFromBytes(input:Null<Bytes>):Null<FunkinSound>
|
|
{
|
|
if (input == null) return null;
|
|
|
|
var openflSound:OpenFLSound = new OpenFLSound();
|
|
openflSound.loadCompressedDataFromByteArray(openfl.utils.ByteArray.fromBytes(input), input.length);
|
|
var output:FunkinSound = FunkinSound.load(openflSound, 1.0, false);
|
|
return output;
|
|
}
|
|
}
|