The Forum is up for sale: XeNTaX Forum looking for new owner

calculating sample count

Get help on any and all audio formats, or chip in and help others!
Post Reply
AlphaTwentyThree
double-veteran
double-veteran
Posts: 982
Joined: Mon Aug 24, 2009 10:55 pm
Has thanked: 76 times
Been thanked: 658 times

calculating sample count

Post by AlphaTwentyThree »

I'm working on a script to add a working RSTM header but I'm having problems to calculate the sample count. The variables I have are:
  • frequency
  • file size
  • channels
  • data rate (kbps)
How does the sample count calculate from these? I thought it's just (file size * freq) / data rate but apparently I'm wrong. :-\
For example: 44.100Hz stereo, 100kbps, 2665472 bytes. How many samples does this file have?
Sorry for this n00by question...
But thanks for your answers!
If you like what you see, why not click the little Thank You button? ;) It will definitely motivate me! :)
And here's Mr.Mouse's Facebook link: http://www.facebook.com/permalink.php?s ... 8469022795 - thanks ;)
Axsis
advanced
Posts: 48
Joined: Fri Oct 21, 2011 12:55 pm
Has thanked: 2 times
Been thanked: 26 times

Re: calculating sample count

Post by Axsis »

as the data rate isn't precise value, you can only get approximate number of samples. if you can get data rate value with single bit precision, then you can calculate exact sample count.

convert data rate from kilobits-per-second to bytes-per-second:
100 kbps = 100000 bits per sec. = 12500 bytes per sec.
calculate file length in seconds:
2665472 bytes / 12500 bytes per sec. = 213,23776 seconds
calculate approx. sample count:
213,23776 seconds * 44100 samples per sec. = 9403785,216 samples for one channel, 18807570 for both.
AlphaTwentyThree
double-veteran
double-veteran
Posts: 982
Joined: Mon Aug 24, 2009 10:55 pm
Has thanked: 76 times
Been thanked: 658 times

Re: calculating sample count

Post by AlphaTwentyThree »

The contents of this post was deleted because of possible forum rules violation.
If you like what you see, why not click the little Thank You button? ;) It will definitely motivate me! :)
And here's Mr.Mouse's Facebook link: http://www.facebook.com/permalink.php?s ... 8469022795 - thanks ;)
Post Reply