Commit bac58f01 authored by Robozman's avatar Robozman

Added sine wave test

parent 31caf405
......@@ -6,6 +6,16 @@ import sounddevice
import time
import numpy as np
volume = 0.5 # range [0.0, 1.0]
fs = 44100 # sampling rate, Hz, must be integer
duration = 54.0 # in seconds, may be float
f = 1440.0 # sine frequency, Hz, may be float
# generate samples, note conversion to float32 array
samples = (np.sin(2*np.pi*np.arange(fs*duration)*f/fs)).astype(np.float32)
def plot(data):
plt.plot(data, color='steelblue')
plt.ion()
......@@ -14,6 +24,7 @@ def plot(data):
rate, wav_data = wavfile.read("violin.wav", mmap=True)
wav_data = samples
sounddevice.play(wav_data, rate)
t = time.time()
......@@ -22,5 +33,5 @@ for i in range(0, 54):
while (time.time() - t < 1):
pass
t = time.time()
plot(np.abs(np.fft.fftshift(np.fft.fft(second[:,0]))))
plot(np.abs(np.fft.fftshift(np.fft.fft(second[:]))))
plt.close()
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