Based on the resource here (defining the structure of a WAV file), I was able to get the audio data between the 44th byte and near the end of the file (some extra meta-data exists at the end which is not necessary).
But I'm having trouble loading it with the new Sound.loadPCMFromByteArray()
method available in Flash Player 11.
I get this error if I pass the number of samples:
_sound.loadPCMFromByteArray(pcm, pcm.length, "float", wav.isStereo, wav.sampleRate);
- [Fault] exception, information=ArgumentError: Error #2084: The AMF encoding of the arguments cannot exceed 40K
However, if I divide the pcm.length
by four (4), it seems to play "something" but isn't at all the sample that I passed it originally. Plus, it sounds like it's looping forever, is this the intended behavior? (I sure hope not!)
//Dividing by 4 (# >> 2 is the same) is playable, but incorrect!
_sound.loadPCMFromByteArray(pcm, pcm.length >> 2, "float", wav.isStereo, wav.sampleRate);
Does the ByteArray of WAV data need to be processed a certain way to conform to a readable PCM format? Do I need to insert an EOF character at the end so it knows when to stop the Sound file?
Should I use another format than "float"? Which ones are supported?