def wave_plotting(sonic, block=False):
if isinstance(sonic.wave_bin_data, list):
bin_buffer = bytearray()
for data in sonic.wave_bin_data:
bin_buffer.extend(data)
sonic.wave_bin_data = bytes(bin_buffer)
elif not isinstance(sonic.wave_bin_data, bytes):
raise Exception("Type of bin_data need bytes!")
#?????????????????????????????????????
wave_data = numpy.fromstring(sonic.wave_bin_data, dtype=number_type.get(sonic.sample_width))
#???????wave_data??????short???????????????????????
# ??????????????????LRLRLRLR....LR?L??????????R????????????wave_data?sharp
wave_data.shape = (sonic.sample_length, sonic.channels)
wave_data = wave_data.T
time = numpy.arange(0, sonic.sample_length) * (1.0 / sonic.sample_frequency)
# ????
colors = ['b', 'g', 'r', 'c', 'm', 'y', 'k']
pylab.figure()
for index in range(0, sonic.channels):
pylab.subplot(sonic.channels, 1, index + 1)
pylab.plot(time, wave_data[index], colors[index % len(colors)])
pylab.ylabel("quantization")
pylab.xlabel("time (seconds)")
pylab.ion()
if block:
pylab.ioff()
pylab.show()
评论列表
文章目录