I think itโs important here to understand what each of these terms means so that you can write code that gives you what you want.
The sampling frequency is the number of samples per second of audio, in your case 11025 (this is sometimes expressed in kHz) it is quite low compared to something like an audio CD, which is 44.1 kHz, so the sampling frequency is 44100 and higher standards. such as 48 kHz, 96 kHz.
Then you have the number of bits used for each sample, usually 8/16/24/32 bits.
Then you can have an arbitrary number of channels for each sample.
Thus, the already presented code example shows how to apply each of these numbers together to get milliseconds for samples that simply multiply the number of channels by sample bits by the sampling frequency, which gives you the data size per second of audio, then divide that number by 1000 to give you milliseconds.
It can get quite complicated if you start applying it to videos that deal with frames that are good numbers, such as 25/30/50/60 frames per second for NTSC, which are 23.98 / 29.97 / 59.94 frames per second, in this case you have to do terrible calculations to make sure they are aligned correctly.
Hope this helps.
source share