Hello
I would like to try to do a visual analyser (with interaction) of the sound variation with Heap (not sure that it’s the best tool for that, but I’d like to learn Heap too^^), but I’m facing an error in javascript when I try to manipulate haxe.io.Bytes
from the music loaded.
This is my code :
import hxd.res.Sound;
class Main extends hxd.App {
var music: Sound = null;
var channel: hxd.snd.Channel;
var bytes: haxe.io.Bytes;
override function init() {
if (hxd.res.Sound.supportedFormat(Mp3)) {
this.music = hxd.Res.my_sound;
}
if (this.music != null) {
this.music.getData().load(function() {
this.bytes = this.music.entry.getBytes();
this.channel = this.music.play(true, 0.2);
});
}
}
override function update(dt : Float) {
if (this.channel != null) {
// Crash
trace(this.music.entry.getBytes().sub(100, 200));
}
}
static function main() {
hxd.Res.initEmbed();
new Main();
}
}
This code breaks in javascript with the following error : Uncaught TypeError: Cannot perform ArrayBuffer.prototype.slice on a detached ArrayBuffer
(see update
function, it crashes in the init
function too). I get similar error with getDouble
, getFloat
, getUInt16
, etc… Only get()
and getData()
seems to work, but get()
always returns null, for all positions.
So, my question is, how to get the loaded music’s bytes (if it’s possible) ? Or is there a tool that can integrate with Heap that’s needed to do this kind of job ?
Thank you,
Peekmo