Commit 5722db5f authored by Samuel Warfield's avatar Samuel Warfield

Locked the axises

parent 34feac57
......@@ -70,14 +70,9 @@ plt.ion()
fig = plt.figure()
fft_plot = fig.add_subplot(111)
def plot(data):
plt.plot(data, color='steelblue')
sounddevice.play(wav_data, rate)
timestep = 1/24
timestep = 1/30
t = time.time()
origin = time.time()
nextBeat = 0
......@@ -85,7 +80,7 @@ while t - origin < len(wav_data) / rate:
if load_from_file == True:
if time.time() - origin >= beat_times[nextBeat]:
nextBeat += 1
print("Beat")
print(f"Beat {t - origin}")
while (time.time() - t < timestep):
pass
......@@ -96,10 +91,21 @@ while t - origin < len(wav_data) / rate:
# print(second)
transform = np.abs(np.fft.fftshift(np.fft.fft(second[:])))
peaks = signal.find_peaks_cwt(np.fft.fftshift(transform), [30,50])
fft_plot.clear()
if load_from_file == True:
fft_plot.plot(np.abs(np.fft.fftshift(np.fft.fft(second[:]))))
fft_plot.plot(transform) # np.abs(np.fft.fftshift(np.fft.fft(second[:])))
else:
fft_plot.plot(np.abs(np.fft.fftshift(np.fft.fft(second[:]))))
fft_plot.plot(transform) # np.abs(np.fft.fftshift(np.fft.fft(second[:])))
for x in peaks:
fft_plot.plot(x, transform[x], marker='x')
fft_plot.set_ylim([0,300])
fig.canvas.draw()
fig.canvas.flush_events()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment