I am trying to convert a byteArray of an audio object to a floating point array. The sound object plays normally and full length, but the float array that I get from it is clipped (but it sounds right), so I have to do something wrong in the conversion:
var s:Sound = mySound;
s.play();
var bytes:ByteArray = new ByteArray();
bytes.endian = Endian.LITTLE_ENDIAN;
s.extract(bytes, s.bytesTotal, 0);
var leftChannel:Array = new Array();
var rightChannel:Array = new Array();
bytes.position = 0;
while (bytes.bytesAvailable)
{
leftChannel.push(bytes.readFloat());
rightChannel.push(bytes.readFloat());
}
and here is what I get:

The top two channels are the original sound object. The bottom two are floating-point array data. I aligned them so that you can see that the beginning is trimmed and obviously the length is wrong.
Thanks for any answers ...
iddqd source
share