3

I'm a beginner with FFT concepts and so what I understand is that if I put in 1024 signals, I'll get 513 bins back ranging from 0hz to 22050Hz (in the case of a 44100Hz sampling rate). Using KISS FFT in Cinder the getBinSize function returns the expected 513 values for an input of 1024 signals. What I don't understand is why duplicate peaks show up. Running a test audio sample that goes through frequencies (in order) of 20Hz to 22000Hz I see two peaks the entire time. It looks something like:

_____|________|_____

As the audio plays, the peaks seem to move towards each other so the second peak really does seem to be a mirrored duplicate of the first. Every example I've been through seems to just go ahead and plot all 513 values and they don't seem to have this mirroring issue. I'm not sure what I'm missing.

Aziz Shaikh
  • 16,245
  • 11
  • 62
  • 79
geranyl
  • 55
  • 1
  • 5
  • Try a signal of alternate ones and negative ones with zeros between each. (i.e. 1,0,-1,0, 1,0,-1,0, ...) For a real FFT of length 1024, this should give you a single peak at out[255] ( the 256th frequency bin) – Mark Borgerding Jan 17 '12 at 16:34
  • Thanks Mark. I did that and it did give me a single peak at the 256th frequency bin, but I'm not sure what that means. Could you help me understand why in an audio track with input blocks of 1024 signals seems mirrored but this constructed signal didn't? – geranyl Jan 17 '12 at 21:16

2 Answers2

9

Ok, after reading up on this I found the solution. The reason for the mirroring is because I use an FFT on real numbers (real FFT). The normal FFT as everyone knows works on complex numbers. Hence the imaginary part is "set" to 0 in the real FFT, resulting in a mirroring around the middle (or technically speaking the mirroring is around 0 and N/2).

Here is a detailed discussion: http://www.edaboard.com/thread144315.html (the page is no longer avaliable, but there is a copy on archive.org)

And read p 238 - 242 on this book (Chapter 12). It's fantastic, so buy it. I think there is a free pdf version on the author’s website: http://www.dspguide.com/

Daniel F
  • 13,684
  • 11
  • 87
  • 116
goocreations
  • 2,938
  • 8
  • 37
  • 59
1

You are possibly plotting the magnitude of all 1024 FFT result bins of a 1024 length FFT, but the upper half is just a mirror image of the lower half (since real-only input to a complex fft doesn't provide enough degrees of freedom to make the upper half unique).

The peaks will move towards each other when mirror images of each other about the center.

Another possibility is that your FFT was somehow only of length 512.

hotpaw2
  • 70,107
  • 14
  • 90
  • 153
  • I've checked both the input length and the output. I input 1024 and get 513 back. Plotting the 513 values shows me a mirrored image, which is why I don't understand what's happening. – geranyl Jan 17 '12 at 13:43