25 lines
647 B
Haxe
25 lines
647 B
Haxe
package funkin.util.assets;
|
|
|
|
import haxe.io.Bytes;
|
|
import openfl.media.Sound as OpenFLSound;
|
|
import funkin.audio.FunkinSound;
|
|
import lime.media.AudioBuffer;
|
|
|
|
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 = OpenFLSound.fromAudioBuffer(AudioBuffer.fromBytes(input));
|
|
var output:FunkinSound = FunkinSound.load(openflSound, 1.0, false);
|
|
return output;
|
|
}
|
|
}
|