使用Audacity,我生成并导出了两个非常相似的线性调频脉冲,各1秒。一个具有440.00Hz的频率,另一个具有440.01Hz的频率。
使用Julia,我编写了一个简短的脚本来生成FFT图:
using WAV
using FFTW
using PyPlot
data, bps = wavread("440.01hz.wav")
plot(fft(data))
440.01绘图着眼于我的期望,在该频率处有一个大的尖峰:但是,在精确的整数440文件上重复相同的过程会产生以下结果:锯齿状的线条非常尖峰,没有尖峰。并进行缩小,看起来像这样(x轴转到44100,因为那是文件的每秒节拍数):我以更多的频率重复了该过程,并且似乎总是产生良好的效果(合理吗? )的结果是当频率为非整数时,否则会造成混淆。我在这里遇到什么问题?
编辑:
这些是文件:
440.00Hz http://www.mediafire.com/file/n6erdh3tkzslpro/440.00hz.wav/file
440.01Hz http://www.mediafire.com/file/2au05df2aelmn9o/440.01hz.wav/file
And here's a plot of both waves (almost indistinguishable) plotted with both fft's zoomed in:
And zoomed out:
The code used to generate these is the same as the one above, but with 4 plots (440 WAV, 440 FFT, 440.01 WAV, 440.01 FFT).
Edit2:
I figured out at least part of the problem. If I first pass the fourier transform of the 440.00hz wav to the absolute value function before plotting it plot(fft(data) .|> abs)
, I get a correct result:
So I know the solution to the problem now, but not why the solution works. The question still remains: what is it about integer frequencies that produces a graph with no spikes? Or, equally valid, why do fractional frequencies produce graphs with them?
The (real) FFT decomposes your signal into a sum of sinusoidal components.
For each frequency you get a complex number. (ignoring the negative frequencies for now) The real part gives the cosine component, and the imaginary part gives the sine component.
You are making a .wav file with a sine wave in it, so you only get sine components, but you're plotting the real components so they're all 0.
Except... The FFT considers your signal to be periodic. When you use an arbitrary frequency, you don't end up with an integer number of cycles in the file, so there is a discontinuity when it wraps around from the end to the start.
Since your signal is not a perfect sinusoid in that case, you get some energy in the cosine components.
--
What you're doing with this FFT is probably very far from what you want to do. If you ask a question about how to do what you're really trying to do, we might be able to help.
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句