I have an application that fills a buffer from my computer's microphone and does an FFT. My objective is to figure out what frequencies are in the sample.

I've tested the application by whistling as well as by playing this video from my cellphone into my computer's mic (I've tried two different mics to be sure). What I expect (taking the absolute frequency) is a smooth Gaussian-like curve with a mean at the frequency of the incoming tone, but what I'm getting is this:

Jagged Frequency Spectrum

What is the cause for the jaggedness of the signal's frequency spectrum? And what technique can be used to reliably identify the main frequencies present in the signal while filtering out the unwanted bumps?

  • 1
    $\begingroup$ This is the windowing effect, causing spectral leakage. The longer your window (=buffer), the higher the spectral resolution. You can trade off resolution and spectral leakage by using different window functions. Right now you're effectively using a rectangular window because you just fill a buffer of finite length. $\endgroup$ – Matt L. Dec 14 '14 at 18:27

What you are seeing is a peak from sinusoid convolved with a spectrum of rectangular window sinc function. That is due to property:

$$x(t)\star w(t) = X(f)\cdot W(f) $$

Where your signal $x(t)$ is a sinusoid with a spectrum being a Kronecker (Dirac) Delta function, $w(t)$ is a rectangular window function. In DFT by default we are using rectangular window (taking a time snippet of a signal). Please check out this paper for more info: A Comprehensive Window Tutorial

  • $\begingroup$ Just a small (but important) detail: it should be Dirac delta rather than Kronecker delta. $\endgroup$ – Matt L. Dec 14 '14 at 20:39
  • $\begingroup$ @MattL.: I had similar conversation years ago with some professor. Basically outcome was that in digital domain there is always Kronecker delta and for Analog domain Dirac's. Any thoughts about that? $\endgroup$ – jojek Dec 14 '14 at 20:52
  • $\begingroup$ @jojek, when you're writing $x(t)$ or $w(t)$, what first comes to mind is that you're in the continuous-time domain (sometimes "analog domain", for the anal-retentive like me, "analog" and "continuous-time" are not quite the same thing). also, i might suggest the circled asterisk $\circledast$ ("\circledast" in $\LaTeX$) for convolution. $\star$ is okay, i guess, but i thought it may have had other uses in mathematics. one thing, for sure, is we need to get away from $*$ because we use it for simple multiplication in any programming language i am familiar with (and i don't know very many). $\endgroup$ – robert bristow-johnson Dec 14 '14 at 21:25
  • 1
    $\begingroup$ actually, @MattL., i think when you're in the discrete-whatever domain, the Kronecker delta appears about as commonly as does the Dirac delta in the continuous-whatever domain. just an opinion though. and we all know you're strictly correct about the Dirac delta not being a function (if $f(x)=g(x)$ almost everywhere, their integrals over the same range have to be equal and, if $\delta(t)$ were a "function", it and $g(t)=0$, would be equal almost everywhere, yet their integrals are different). i like to think of $\delta(t)$ having finite width of 1 Planck Time and make all that crap go away. $\endgroup$ – robert bristow-johnson Dec 14 '14 at 21:36
  • 2
    $\begingroup$ in a Starbucks in Cambridge Mass (by the Trader Joes). gonna go caroling now with some friends. love to chat about Diracs and (sp)Rectal leakage and the like, but i gotta go. L8r, r b-j $\endgroup$ – robert bristow-johnson Dec 14 '14 at 21:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.