audio_visualize_5.py 489 B

1234567891011
  1. def update(frames):
  2. if self.stream.is_active():
  3. slice = self.left.get_sample_slice(frames, frames + self.window)
  4. self.stream.write(slice.raw_data)
  5. y = np.array(slice.get_array_of_samples()) / 30000
  6. points = np.array([np.cos(time), y]).T.reshape((-1, 1, 2)) # 控制曲线精细程度和振幅
  7. segments = np.concatenate([points[:-1], points[1:]], axis=1)
  8. lc.set_segments(segments)
  9. lc.set_array(y) # 控制颜色
  10. return lc,