audio_visualize_9.py 479 B

1234567891011121314
  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. z = np.array(slice.get_array_of_samples())
  6. zft = np.abs(np.fft.fft(z / max(z))) / (self.window * 4)
  7. lf.set_xdata(x)
  8. lf.set_ydata(y)
  9. lf.set_3d_properties(zft)
  10. lf2.set_xdata(x)
  11. lf2.set_ydata(y)
  12. lf2.set_3d_properties(z / 1000000)
  13. return lf, lf2,