1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2025-09-04 04:38:09 +00:00
Funkin/source/funkin/util/assets/SoundUtil.hx
Hyper_ 88ed66affa chore: Add null safety to various utility and plugin classes
And add a bit of error handling to CharSelectGF & CharSelectSubState

Co-Authored-By: Linus Torvalds <torvalds@linux-foundation.org>
2025-06-23 14:13:35 -04:00

26 lines
665 B
Haxe

package funkin.util.assets;
import haxe.io.Bytes;
import openfl.media.Sound as OpenFLSound;
import funkin.audio.FunkinSound;
import lime.media.AudioBuffer;
@:nullSafety
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));
if (openflSound == null) return null;
return FunkinSound.load(openflSound, 1.0, false);
}
}