每秒音频采样数?

发布于 2024-10-17 19:36:42 字数 191 浏览 5 评论 0原文

我想知道样本块与其等效时间之间的关系。到目前为止我的粗略想法是:

每秒播放的样本数=总文件大小/持续时间。

比如说,我有一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

晨与橙与城 2024-10-24 19:36:42

一般来说,对于 PCM 样本,您可以将总长度(以字节为单位)除以持续时间(以秒为单位)以获得每秒字节数(对于 WAV 文件,考虑到标题)。这些如何转换为样本取决于

  1. 每个样本使用的采样率
  2. 位,即通常
    使用的是 16 位 = 2 字节
  3. 通道数,即立体声
    这是 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

  1. the sample rate
  2. bits used per sample, i.e. commonly
    used is 16 bits = 2 bytes
  3. number of channels, i.e. for stereo
    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

寒江雪… 2024-10-24 19:36:42

除了@BrokenGlass 的非常好的答案之外,我还要补充一点,对于具有固定采样率、通道数和每个样本位数的未压缩音频,算法相当简单。例如,对于“CD 质量”音频,我们的采样率为 44.1 kHz,每个样本 16 位,2 个通道(立体声),因此数据速率为:

  44100 * 16 * 2
= 1,411,200 bits / sec
= 176,400 bytes / sec
= 10 MB / minute (approx)

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:

  44100 * 16 * 2
= 1,411,200 bits / sec
= 176,400 bytes / sec
= 10 MB / minute (approx)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文