I implemented FFT using RFFT32 library. However, I have trouble interpreting the result. My current program is as follows (fftSize was defined as 128)
If I read the documentation correctly, ipcbsrc should be populated with input data, and ipcb is the result of the FFT magnitude. The ipcb in my program was populated by ADC which samples input signal from function generator (square wave @ 5kHz, 50% duty cycle) at 40kHz sampling rate.
The interesting element from ipcb are elements 29, 30, 31, 32, which have values of -130, 246, 52, and -179. The value of 246 is like the peak here, corresponds to frequency (30 + 1) / 256 * 40000 = 4843.75 Hz (very close to 5kHz, why?). But why do I get negative value?
Extra credit: why does element 0 have the highest value of 1546? (EDIT: I got the answer already. It's the DC component magnitude. Yes, no?)
Thanks