Starting from the 40th byte for the next 4 bytes (small end) - the size of Subchunk2. This can also be deduced from the formula:
Subchunk2size = NumSamples * NumChannels * BitsPerSample/8
NumChannels begin with byte 22 and 2 bytes (a small number) in length. BitsPerSample starts at the 34th byte and has a length of 2 bytes (small end). Replacing all of this, you can get NumSamples, which is the number of samples.
For example: if Subchunksize2=2048, NumChannels=2 and BitsPerSample=16 , you get 2048 = NumSamples * 2 * 2 so NumSamples=512
Good reading here.
source share