bias_oversampling_plot.py (553B)
1 import matplotlib.pyplot as plt 2 import numpy as np 3 4 freqs = np.zeros(1000) 5 6 fs = 44 * 2 7 8 plt.plot([0,20], [0.5,0.5], 'b') 9 plt.plot([20,20], [0,0.5], 'b') 10 11 plt.plot([fs,fs], [0,1]) 12 13 amp = 1.0 14 harmonic = 1 15 f_base = 50 16 f = 0 17 while f < 1000: 18 f = f_base * harmonic 19 20 if f < fs: 21 plt.plot([f,f], [0,amp], 'r') 22 else: 23 plt.plot([fs-(f-fs),fs-(f-fs)], [0,amp], 'r') 24 25 amp *= 0.9 26 harmonic += 0.2 27 28 plt.xlim((0,fs*1.1)) 29 30 plt.xlabel("Frequency [kHz]") 31 plt.ylabel("Amplitude") 32 33 plt.title("Audio Signal + Bias (digitized)") 34 35 plt.show()