每秒音频采样数?
我想知道样本块与其等效时间之间的关系。到目前为止我的粗略想法是:
每秒播放的样本数=总文件大小/持续时间。
比如说,我有一个 1.02MB 的文件,持续时间为 12 秒(平均),每秒播放大约 89,300 个样本。这是对的吗?
还有其他方法可以计算这个吗?例如,我如何知道一个 byte[1024] 数组相当于多少时间?
I am wondering on the relationship between a block of samples and its time equivalent. Given my rough idea so far:
Number of samples played per second = total filesize / duration.
So say, I have a 1.02MB file and a duration of 12 sec (avg), I will have about 89,300 samples played per second. Is this right?
Is there other ways on how to compute this? For example, how can I know how much a byte[1024] array is equivalent to in time?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
一般来说,对于 PCM 样本,您可以将总长度(以字节为单位)除以持续时间(以秒为单位)以获得每秒字节数(对于 WAV 文件,考虑到标题)。这些如何转换为样本取决于
使用的是 16 位 = 2 字节
这是 2
如果您知道 2) 和 3),您可以确定 1)
在您的示例中为 89300 字节/秒,假设立体声和每个样本 16 位将为 89300 / 4 ~= 22Khz 采样率
Generally speaking for PCM samples you can divide the total length (in bytes) by the duration (in seconds) to get the number of bytes per second (for WAV files there will be some inaccuracy to account for the header). How these translate into samples depends on
used is 16 bits = 2 bytes
this is 2
If you know 2) and 3) you can determine 1)
In your example 89300 bytes/second, assuming stereo and 16 bits per sample would be 89300 / 4 ~= 22Khz sample rate
除了@BrokenGlass 的非常好的答案之外,我还要补充一点,对于具有固定采样率、通道数和每个样本位数的未压缩音频,算法相当简单。例如,对于“CD 质量”音频,我们的采样率为 44.1 kHz,每个样本 16 位,2 个通道(立体声),因此数据速率为:
In addition to @BrokenGlass's very good answer, I'll just add that for uncompressed audio with a fixed sample rate, number of channels and bits per sample, the arithmetic is fairly straightforward. E.g. for "CD quality" audio we have a 44.1 kHz sample rate, 16 bits per sample, 2 channels (stereo), therefore the data rate is: