Commit e82d12db authored by Samuel Warfield's avatar Samuel Warfield

Added Timestep

parent 8407297f
......@@ -4,7 +4,7 @@ import numpy as np
import scipy.io.wavfile as wavfile
import sounddevice
import time
import math
import numpy as np
......@@ -30,16 +30,24 @@ def plot(data):
rate, wav_data = wavfile.read("violin.wav", mmap=True)
wav_data = samples
#wav_data = samples
sounddevice.play(wav_data, rate)
timestep = 1/24
t = time.time()
for i in range(0, 54):
second = wav_data[i * rate:(i + 1) * rate]
while (time.time() - t < 1):
origin = time.time()
while t - origin < len(wav_data) / rate:
while (time.time() - t < timestep):
pass
t = time.time()
second = wav_data[math.floor((t - origin) * rate) : math.floor((t - origin + timestep) * rate)]
print(second)
fft_plot.clear()
fft_plot.plot(np.abs(np.fft.fftshift(np.fft.fft(second[:]))))
fft_plot.plot(np.abs(np.fft.fftshift(np.fft.fft(second[:,0]))))
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