readframes 在 python 中返回 2 个字节
当在 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Wave 文件
Wave_read.getframerate()< /code>
每秒(例如,如果来自音频 CD,则为 44100)。
Wave_read.getsampwidth()
字节(即 1 表示 8 位样本,2 表示 16 位样本)Wave_read.getnchannels()
通道(通常 1 个用于单声道,2 个用于立体声)每次执行
Wave_read.getframes(N)
,您将得到N * Sample_width * n_channels
字节。因此,如果您从 44100Hz、16 位立体声文件中读取 2048 帧,则会得到 8192 字节。
A wave file has:
Wave_read.getframerate()
per second (e.g 44100 if from an audio CD).Wave_read.getsampwidth()
bytes (i.e 1 for 8-bit samples, 2 for 16-bit samples)Wave_read.getnchannels()
channels (typically 1 for mono, 2 for stereo)Every time you do a
Wave_read.getframes(N)
, you getN * 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.