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?
views:
200answers:
1
+1
Q:
Given a WAV file, its file size and sample rate, is it possible to calculate the sample count?
+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
2010-04-15 16:37:26
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
2010-04-16 08:33:13
Mark Heath
2010-04-16 09:37:16
C# and MediaInfoLib.
Simon
2010-06-17 08:16:59