Tell me more ×  Our app needs to know the sample count of the
audio files it loads. The library we're using can reliably
determine the sample rate, but not the sample count. Is it
possible for us to calculate the sample count from just the file
size and sample rate?  share|improve this question add comment
2 Answers  Assuming the WAV file is PCM, you can calculate it
using the size of the data chunk. The number of bytes per sample
is simply the number of bits per sample divided by eight. The
number of bits per sample will be present in the WAVEFORMAT
structure. This can be used to accurately get the sample count.
share|improve this answer can I work out the size of the data
chunk from the file size, or do I need to know more - e.g.
header size? –  Simon Apr 16 '10 at 8:33 WAV files always have a
format chunk and a data chunk. They may have other chunks. The
only way to be sure of the data chunk size is to find it and
read its size parameter. What language & library are you using?
–  Mark Heath Apr 16 '10 at