I have a half second audio data sampled at $44.1\textrm{ kHz}$. If I FFT it I get frequency components in $2\textrm{ Hz}$ increments. Now suppose I want the component of an arbitrary frequency, like $32.45\textrm{ Hz}$, how can I get it?

Looking at the DFT formula from Wikipedia:

$$ X_k = \sum_{n=0}^{N-1} x_n e^{-i 2 \pi k n / N} $$

I wondered, what if I calculate the relevant $k$ and plug it into the equation? Like:

$$ {32.45 \times 22050 \over 44100} = 16.225\quad \textrm{then}\quad X_{16.225} = \sum_{n=0}^{N-1} x_n e^{-i 2\pi \times 16.225 n / N} $$

would that get me what I want?


2 Answers 2


The commonly used Goertzel filter (or algorithm) used to detect a single frequency component is essentially a computational optimization of computing 1 bin of a DFT this way.

Note that a both a Goertzel filter and 1 bin of an un-windowed (or rectangular windowed) DFT don't just respond to a single frequency, but have a non-zero bandwidth filter response in the shape of a Sinc function, with most of the main lobe response on the order of Fs/N wide. So the 32 Hz bin of your half-second-long FFT will contain most of a 32.45 Hz component, as well as vice versa with the Goertzel result.

Note that if the k is fractional, or not integer, which corresponds to a Goertzel filter length that is not an exact integer multiple of the period of the frequency in question, there will be some dependency of the magnitude result on the phase of the frequency component with respect to some point in the sampling window (say, the start).

And, unlike with a full FFT, 1 bin of a DFT won't tell you whether the measured component is significant compared to adjacent frequencies (is a peak), or to the rest of the signal (is above the noise floor).

But otherwise, yes.


Yes, you can compute a single-bin DFT at ANY frequency, as mentioned in this post, and a related post. After all, F = k*f_s/N, where f_s is the sampling frequency and N is the number of points. Since f_s and N are known, just compute the value of k you need to get the frequency you want. It's basically putting down a single bin DFT centered at frequency F. And the 'bin width' is the same as what you'd get with any other DFT bin based on N points.

Since the advent of FFT, people have become accustomed to thinking of the parameter 'k' (the frequency index) as being an integer. However, if you think of a DFT calculation as being like a correlation, then you can think of it as answering the question: does my time record look like a sine or cosine wave of a specific frequency? So, no matter what the value of 'k' is, and no matter if you have an integer number of cycles in your input or not - for example, 3.7825 cycles in your input will correlate quite well with 3.7825 cycles of the sine and cosine wave of your DFT bin. You just have to figure out what value of 'k' to use.

As for phase - well, whether for a full DFT, single-bin DFT or FFT - you've DEFINED the time = 0 point (you have a data point x(0), don't you?), and phase will be relative to that point.

  • $\begingroup$ x(0) for time=0 is a very poor point to which to reference phase, as, giving that a DFT is a circular correlation, for any non-periodic-in-aperture signals, x(0) will be at a discontinuity in phase. The phase of a discontinuity often doesn't make any sense. Doing an fftshift to center the phase as odd/even in aperture may be non-standard, but measures phase at a continuous portion of the waveform, which can make much more sense for many waveforms (any non-bin-centered sinusoids, for instance). $\endgroup$
    – hotpaw2
    Commented Nov 8, 2013 at 18:44
  • $\begingroup$ But the OP isn't computing an off-bin sinusoid via an FFT. He's taking N points (0 to N-1) of a single frequency input and computing a single output of a DFT bin whose value of 'k' matches his input frequency. So he gets a single complex number as a result, and computes amplitude and phase. There's nothing to shift or rotate. $\endgroup$ Commented Nov 9, 2013 at 4:32
  • $\begingroup$ The correlation basis vector, even if non-periodic in N, can still be centered in the N point window (phase 0 at the center) so that the phase reference point has a 2-sided neighborhood of continuity. $\endgroup$
    – hotpaw2
    Commented Nov 9, 2013 at 7:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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