大家好,我是按照http://blog.csdn.net/xsc_c/article/details/8941338写的的代码
我还有三个问题请教?
wave_data = np.fromstring(str_data, dtype=np.short) # 疑问1、此时,如果wave文件的采样宽度是8比特,该如何转成数组呢?使用长度是16比特的short分割数组,合理吗
# for the data is stereo,and format is LRLRLR...
# shape the array to n*2(-1 means fit the y coordinate) wave_data.shape = -1, 2 # 疑问2、此时,应该对文件的channel数做一个判断吧,单声道的不用再这样把组数一分为二了吧?
plt.plot(time, wave_data[0]) # 疑问3、plot的两个参数的长度不一致。 此时time数组的长度是nframe ;而wave_data[0]的长度是wave_data被拆分前的一半,wave_data长度是str_data 被short 分割前的一半,wave_data[0]的长度也就是1/4 nframe 。
谢谢。
我还有三个问题请教?
wave_data = np.fromstring(str_data, dtype=np.short) # 疑问1、此时,如果wave文件的采样宽度是8比特,该如何转成数组呢?使用长度是16比特的short分割数组,合理吗
# for the data is stereo,and format is LRLRLR...
# shape the array to n*2(-1 means fit the y coordinate) wave_data.shape = -1, 2 # 疑问2、此时,应该对文件的channel数做一个判断吧,单声道的不用再这样把组数一分为二了吧?
plt.plot(time, wave_data[0]) # 疑问3、plot的两个参数的长度不一致。 此时time数组的长度是nframe ;而wave_data[0]的长度是wave_data被拆分前的一半,wave_data长度是str_data 被short 分割前的一半,wave_data[0]的长度也就是1/4 nframe 。
谢谢。