I’m trying to transform a file containing a soundwave. I just want to make sure that my transform looks right because it doesn’t look right to me. I unfortunately don’t know how to provide the files I’m using but I will link the problem and plots I’ve made.
Code for Part B:
FT1=rfft(sax)
FT2=rfft(clar)
tsax=np.linspace(0,len(FT1)/44100,len(FT1))
tclar=np.linspace(0,len(FT2)/44100,len(FT2))
plt.plot(tsax,real(FT1))
plt.xlabel('time (s)')
plt.title('Saxophone Soundwave Discrete Fourier Transform')
plt.figure()
plt.plot(tclar,real(FT2))
plt.xlabel('time (s)')
plt.title('Clarinet Soundwave Discrete Fourier Transform')
plt.show()
Code for Part A & C:
plt.figure(figsize=(12, 12))
plt.subplots_adjust(hspace=.25)
plt.subplots_adjust(wspace=1)
FT1=rfft(sax)
FT2=rfft(clar)
N=len(FT1)
tsax=np.linspace(0,len(FT1)/44100,len(FT1))
tclar=np.linspace(0,len(FT2)/44100,len(FT2))
tau=tsax[1]
freq=array([k/(2*N*tau) for k in range(N)])
tsax=np.linspace(0,len(sax)/44100,len(sax))
tclar=np.linspace(0,len(clar)/44100,len(clar))
plt.subplot(221)
plt.plot(tsax, sax)
plt.xlabel(‘time (s)’)
plt.title(‘Saxophone Soundwave’)
plt.subplot(223)
plt.plot(tclar, clar)
plt.xlabel(‘time (s)’)
plt.title(‘Clarinet Soundwave’)
plt.subplot(222)
plt.plot(freq/1000, abs(real(FT1)))
plt.xlabel(‘Frequency (kHz)’)
plt.title(‘Saxophone Soundwave Discrete Fourier Transform Coefficients vs Frequency’)
plt.subplot(224)
plt.plot(freq/1000, abs(real(FT2)))
plt.xlabel(‘Frequency (kHz)’)
plt.title(‘Clarinet Soundwave Discrete Fourier Transform Coefficients vs Frequency’)
plt.show()
I was expecting the FFT plot to be more spread out rather than it being so concentrated in such a small region for the Fourier Transformation. I made sure I used the right functions and that it did what it was suppose to do which seems like it did. I made sure my time step tau was right and I think it is. The sample rate is 44100Hz so tau should be 1/44100 or the first nonzero point in the time array. The code looks right yet the plot feels wrong.
Hopefully someone is able to confirm or deny my plots.