I noticed that if the INFO chunk contains an odd-sized subchunk, the WavAudioFormatReader loses track of the next subchunk.
For example, for chunks like the following:
Well technically chunk sizes can not be odd.
So the file is corrupt. Odd chunk sizes should be considered illegal.
You could be lenient and try to read them anyway and pad the byte.
But to be compliant you don’t have to.
hmmm
To my understanding, the RIFF spec allows odd-sized chunks (cksize is odd), and in that case, the insertion of padding 0 is required.
As an actual example, Adobe Audition CS6 exports odd-sized metadata chunks like this one.
Can I find documentation somewhere that odd-sized chunks are illegal?
Yes, the size of the chunk itself is always even. But I am talking about cases where the “length of this chunk” field in the chunk header is an odd number. I believe that is legal.
With the list sub-chunks it becomes even murkier.
But I think you’re right, nothing afaik stated about the parity of the sub-chunks in the standard.
If the sub-chunk size is correct it should just read.
And if the chunk size is odd the reader can assume the pad byte is present and start reading the next chunk after.
Binary data of fixed or variable size. The start of ckData is word-aligned with respect to the start of the RIFF file. If the chunk size is an odd number of bytes, a pad byte with value zero is written after ckData. Word aligning improves access speed (for chunks resident in memory) and maintains compatibility with EA IFF. The ckSize value does not include the pad byte.
With that information I would still think, that an odd number and writing without the padding byte would violate that standard. Otherwise what would be the point of the byte in the first place?
The number of bytes might be odd, which is then adding the pad byte, so the next chunck starts at an even address again.
In that time 16 bit processors were standard, so an odd chunck would have a performance impact back then.