【发布时间】:2013-05-20 18:26:39
【问题描述】:
所以基本上我正在尝试读取波形文件的信息,以便我可以获取字节信息并创建一个时间数组->振幅点。
import wave
class WaveFile:
# `filename` is the name of the wav file to open
def __init__(self, fileName):
self.wf = wave.open(fileName, 'r')
self.soundBytes = self.wf.readframes(-1)
self.timeAmplitudeArray = self.__calcTimeAmplitudeArray()
def __calcTimeAmplitudeArray(self):
self.internalTimeAmpList = [] # zero out the internal representation
byteList = self.soundBytes
if((byteList[i+1] & 0x080) == 0):
amp = (byteList[i] & 0x0FF) + byteList[i+1] << 8
#more code continues.....
错误:
if((int(byteList[i+1]) & 0x080) == 0):
TypeError: unsupported operand type(s) for &: 'str' and 'int'
我曾尝试使用int() 转换为整数类型,但无济于事。我来自 Java 背景,这将使用 byte 类型完成,但这似乎不是 Python 的语言特性。任何方向将不胜感激。
【问题讨论】:
标签: python python-2.7 wav