tags:

views:

200

answers:

1

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?

+1  A: 

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.

Mark Heath
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
Mark Heath
C# and MediaInfoLib.
Simon