1
$\begingroup$

I have a signal that consists of a sine wave, on which I apply a rectangular window and then an FFT. I'm only interested in the magnitude of the sine wave, and I want it to stay the same even if the signal shifts a few samples to the right relative to the window (of course assuming the sine wave has the same amplitude from top to bottom). Is this possible and how can this be done best? The application is a kind of pitch detector where I have to detect a small group of different pitches.

$\endgroup$
  • 1
    $\begingroup$ Pitch detection algorithms (cepstrum, YAAPT, RAPT, harmonic product, weighted autocorrelation, etc.,) usually don't require exact magnitudes independent of phase. $\endgroup$ – hotpaw2 Jan 15 '14 at 9:06
1
$\begingroup$

You can't make an FFT ignore phase (for strictly real input), except for signals which have frequencies that are exactly periodic in the FFT window length.

Otherwise, you will have to interpolate to get any between bin magnitude peaks. And an accurate magnitude interpolation of any non-bin-centered frequency will depend on phase (easiest if you reference phase to the center of the data window), especially near the DC or Fs/2 bins, but to a much smaller extent, thru the rest of the FFT result as well.

$\endgroup$
1
$\begingroup$

I'm only interested in the magnitude of the sine wave, and I want it to stay the same even if the signal shifts a few samples to the right relative to the window

The absolute magnitude of the DFT result will be independent of the phase shift. Each DFT bin will give you a complex number of the form $A \ e^{j \ \theta}$. Circularly shifting your tone will only affect $\theta$. If you take the absolute magnitude, you will end up with $|A|$, all the while ignoring the phase.

$\endgroup$

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.