-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot_wave.py
More file actions
27 lines (23 loc) · 725 Bytes
/
Copy pathplot_wave.py
File metadata and controls
27 lines (23 loc) · 725 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from audio_buffer import AudioBuffer
import matplotlib.pyplot as plt
import numpy as np
from matplotlib import animation
from time import sleep
import matplotlib
matplotlib.use('TkAgg')
if __name__ == "__main__":
audio_buffer = AudioBuffer(seconds=5)
audio_buffer.start()
sleep(5)
fig = plt.figure()
ax = fig.add_subplot(111)
amp = 10000 # you might need to adjust this parameter
line, = ax.plot(amp * np.random.random(len(audio_buffer)) - amp/2)
def animate(i):
data = audio_buffer()
line.set_ydata(data)
return (line,)
anim = animation.FuncAnimation(fig, animate, interval=1, blit=True)
plt.show()
""" while True:
print(audio_buffer()) """