Commit 8407297f authored by Robozman's avatar Robozman

Added scaling sine waves

parent bac58f01
......@@ -10,17 +10,23 @@ 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
duration = 1 # 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)
samples = np.zeros( 10 * fs)
for i in range(0, 10):
curr_freq = 440 + (i * 1000)
samples[(i * fs):((i + 1) * fs)] = np.sin(2*np.pi*np.arange(fs*duration)*curr_freq/fs).astype(np.float32)
plt.ion()
fig = plt.figure()
fft_plot = fig.add_subplot(111)
def plot(data):
plt.plot(data, color='steelblue')
plt.ion()
plt.figure()
plt.show()
rate, wav_data = wavfile.read("violin.wav", mmap=True)
......@@ -33,5 +39,7 @@ 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[:]))))
plt.close()
fft_plot.clear()
fft_plot.plot(np.abs(np.fft.fftshift(np.fft.fft(second[:]))))
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