timing_test.py (571B)
1 import numpy as np 2 import matplotlib.pyplot as plt 3 import soundfile as sf 4 5 def toMono (arr): 6 list = [] 7 for samp in arr: 8 list.append (samp[0]) 9 return list 10 11 pulse_in, fs = sf.read ("pulse_train.wav") 12 13 pulse_out, fs = sf.read ("PulseTrain_Out.wav") 14 pulse_out = toMono (pulse_out) 15 16 N = len (pulse_in) 17 t = np.arange (N) 18 n = 60000 19 start = 30000 20 21 plt.plot (t[start:start+n], pulse_in[start:start+n], t[start:start+n], pulse_out[start:start+n]) 22 plt.xlabel ("Time [samples]") 23 plt.ylabel ("Amplitude") 24 plt.title ("Real-time Timing Offset (Flutter)") 25 plt.show()