Update Aura
This commit is contained in:
@ -30,15 +30,15 @@ class LoaderImpl {
|
||||
}
|
||||
|
||||
public static function loadSoundFromDescription(desc: Dynamic, done: kha.Sound->Void, failed: AssetError->Void) {
|
||||
var sound = Krom.loadSound(desc.files[0]);
|
||||
if (sound == null) {
|
||||
var sound = new kha.krom.Sound(desc.files[0]);
|
||||
if (sound.uncompressedData == null) {
|
||||
failed({
|
||||
url: desc.files.join(","),
|
||||
error: "Could not load sound(s)",
|
||||
});
|
||||
}
|
||||
else {
|
||||
done(new kha.krom.Sound(Bytes.ofData(sound)));
|
||||
done(sound);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -2,24 +2,28 @@ package kha.krom;
|
||||
|
||||
import haxe.io.Bytes;
|
||||
|
||||
using StringTools;
|
||||
|
||||
class Sound extends kha.Sound {
|
||||
public function new(bytes: Bytes) {
|
||||
public function new(filename: String) {
|
||||
super();
|
||||
|
||||
var count = Std.int(bytes.length / 4);
|
||||
uncompressedData = new kha.arrays.Float32Array(count);
|
||||
for (i in 0...count) {
|
||||
uncompressedData[i] = bytes.getFloat(i * 4);
|
||||
}
|
||||
var sound = Krom.loadSound(filename);
|
||||
if (sound != null) {
|
||||
var bytes = Bytes.ofData(sound.buffer);
|
||||
var count = Std.int(bytes.length / 4);
|
||||
uncompressedData = new kha.arrays.Float32Array(count);
|
||||
for (i in 0...count) {
|
||||
uncompressedData[i] = bytes.getFloat(i * 4);
|
||||
}
|
||||
|
||||
compressedData = null;
|
||||
this.sampleRate = sound.sampleRate;
|
||||
this.channels = sound.channels;
|
||||
this.length = sound.length;
|
||||
}
|
||||
}
|
||||
|
||||
override public function uncompress(done: Void->Void): Void {
|
||||
done();
|
||||
}
|
||||
|
||||
override public function unload(): Void {
|
||||
super.unload();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user