readframes 在 python 中返回 2 个字节

发布于 2024-11-10 04:56:03 字数 298 浏览 9 评论 0原文

当在 python 中使用 readframes() 时,在线文档说返回采样频率,看起来返回2个字节。我认为每帧有 4 个字节:

left = 2 bytes
right = 2 bytes

我是否必须检查它是单声道还是立体声,如果是立体声,一次读取 2 帧,如果是单声道,一次读取 1 帧?

When readframes() is used in python, the online documention says sampling frequency is returned it looks it returns 2 bytes. I think there are 4 byte on each frame:

left = 2 bytes
right = 2 bytes

Do I have to check if it is mono or stereo and if it is stereo, read 2 frames at a time and if it is mono, read 1 frame at a time?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

勿忘初心 2024-11-17 04:56:03

Wave 文件

每次执行 Wave_read.getframes(N),您将得到 N * Sample_width * n_channels 字节。

因此,如果您从 44100Hz、16 位立体声文件中读取 2048 帧,则会得到 8192 字节。

A wave file has:

Every time you do a Wave_read.getframes(N), you get N * sample_width * n_channels bytes.

So, if you read 2048 frames from a 44100Hz, 16-bit stereo file, you get 8192 bytes as a result.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文