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?
What mark said. No, normally you need to interpret the header. But if the format, number of channels, and number of bits per sample are known and the same for all files you could theoretically calculate it from the file size.
WAV is a simple format, unfortunately there have been many strange variations of the format from big and small hardware and software developers over the years. Usually you can count on the format being kosher if the files are coming from a modern mainstream wave editor. So, if the samples are standardized by exporting them from WaveLab or similar, you could save writing the (small) code for the header-interpreter.
The easiest-to-read .wav format description is here. StripWav is a small program to standardize samples; there's also a command-line tool which is more capable: sox. Sox supports batch jobs, so it would be better than using a wave editor - assuming the set of .wav files is a given and not 'dynamic'.
So: If you can standardize them once and for all with a sox batch job, it should be possible. I've used this format description and Sox to great effect several times, good luck :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With