开发者

readframes return 2 byte in python

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 i开发者_如何学Pythont 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?


A wave file has:

  • sample rate of Wave_read.getframerate() per second (e.g 44100 if from an audio CD).
  • sample width of 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 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜