Hi All,

I've got some questions about the behaviour of the AudioPlayMemory object, and how it expects the array containing the samples to be laid out.

I've read the old documentation here: https://www.pjrc.com/teensy/td_libs_...layMemory.html as well as the AudioPlayMemory page in the teensy audio tool.
and some comments here:
and looked at the source code for "wav2sketch".

And I think I've mostly wrapped my head around it, but I can't reconcile some things with the numbers I see in the example sketches.

Here's my understanding of the layout of AudioPlayMemory, please let me know if I've gotten anything wrong:
1) The data is stored as an array of "const unsigned int", each element of which is 32-bits (4 bytes) in size.
2) The data of each sample is _signed_ in a 2's complement form.
3) Different sample rates (44100, 22050, 11025 Hz) can be selected,
4) Samples can be in either an 8-bit compressed format, or uncompressed 16-bit PCM. (16-bit samples are stored in little-endian format, with low-byte containting the least-significant bits)
5) The high 8-bits of the first word of the array specify the format of the compression, and the low 24-bits specifies the length of the samples. According to the documentation the length is specified in bytes, but I suspect it is actually specified in samples.

Here's my diagram:
Click image for larger version. 

Name:	audioplaymemory_memory_usage_v01.jpg 
Views:	13 
Size:	100.1 KB 
ID:	22007

The problem is when I look at example sketches and see how other people have used the AudioPlayMemory objects, I get different numbers for array size than what I'd predict based on the length specification in the header.
Specifically the numbers are wrong for all the 16-bit formats if I assume the units of length are bytes:

Click image for larger version. 

Name:	audioplaymemory_usage_v01.png 
Views:	20 
Size:	46.4 KB 
ID:	22008

If I assume the units of length are samples, then it looks much better, but some of the files still don't match the pattern:

Click image for larger version. 

Name:	audioplaymemory_usage_v02.jpg 
Views:	19 
Size:	121.4 KB 
ID:	22009

Is what I'm seeing just a bug in wav2sketch (or the files "guitar_a2_note" and "guitar_b3_note" in the example sketches), or have I made a mistake somewhere?