Commit ca1e90d4 authored by Samuel Warfield's avatar Samuel Warfield

Code cleanup, and plot disable

parent 3c284757
......@@ -72,15 +72,19 @@ fft_plot = fig.add_subplot(111)
sounddevice.play(wav_data, rate)
timestep = 1/24
timestep = .01
t = time.time()
origin = time.time()
nextBeat = 0
while t - origin < len(wav_data) / rate:
if load_from_file == True:
if time.time() - origin >= beat_times[nextBeat]:
nextBeat += 1
print(f"Beat {t - origin}")
try:
if time.time() - origin >= beat_times[nextBeat]:
nextBeat += 1
print(f"Beat {t - origin}")
except:
print("Last beat encountered")
while (time.time() - t < timestep):
pass
......@@ -91,21 +95,25 @@ while t - origin < len(wav_data) / rate:
# print(second)
transform = np.abs(np.fft.fftshift(np.fft.fft(second[:])))
transform = np.abs(np.fft.fft(second[:]))
plot_transform = np.fft.fftshift(transform)
peaks, _ = signal.find_peaks(transform, prominence=20)
print(peaks)
peaks, _ = signal.find_peaks(plot_transform, prominence=20)
fft_plot.clear()
if load_from_file == True:
fft_plot.plot(transform) # np.abs(np.fft.fftshift(np.fft.fft(second[:])))
else:
fft_plot.plot(transform) # np.abs(np.fft.fftshift(np.fft.fft(second[:])))
plot = True
if plot is True:
fft_plot.clear()
if load_from_file == True:
fft_plot.plot(plot_transform) # np.abs(np.fft.fftshift(np.fft.fft(second[:])))
else:
fft_plot.plot(plot_transform) # np.abs(np.fft.fftshift(np.fft.fft(second[:])))
for x in peaks:
fft_plot.plot(x,transform[x], marker='x')
for x in peaks:
fft_plot.plot(x,plot_transform[x], marker='x')
fft_plot.set_ylim([0,300])
fft_plot.set_ylim([0,300])
fig.canvas.draw()
fig.canvas.flush_events()
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