Using Audacity, I generated and exported two very similar chirps of 1 second each. One has a frequency of 440.00Hz, and the other has a frequency of 440.01Hz.
Using Julia, I made a short script to generate a plot of the FFT:
using WAV
using FFTW
using PyPlot
data, bps = wavread("440.01hz.wav")
plot(fft(data))
The 440.01 plot looked about how I would expect, with a big spike at that frequency:
However, the same procedure repeated on the exact integer 440 file yielded this result:
A very jagged line with no spike. And zoomed out it looks like this (x-axis goes to 44100 since that was the beats-per-second of the file):
I've repeated the procedure with several more frequencies, and it seems to always produce a good (sensible?) result when the frequency is a non-integer, and a confusing result otherwise. What problem am I running into here?
Edit:
Here are the files:
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?