I’m reading raw data from a mic and feeding into FFT. Two of the FFT libraries I’m trying (AForge and Exocortex.DSP) takes Complex numbers as input and gives Complex numbers as output.
I’m trying to understand what complex numbers are.
More specifically – how do I convert the raw audio data obtained from a microphone into complex numbers for processing in FFT?
And how do I plot the output to a nice spectrogram (that is; reading the frequencies and amplitudes from the output)?
Added bonus: What FFT libs are there for .Net other than the two mentioned?
When performing an FFT on real data then you just need to set the imaginary part of the input to zero. (Note that the output of the FFT will still be complex though.)
Plotting a spectrogram is more complex – there are previous posts on SO about this but essentially you need to compute the power spectrum for successive overlapping time windows (typical overlap = 50%) and then plot the log (dB) magnitude of these power spectra using colour or grey scale intensity for magnitude (with time on the X axis and frequency on the Y axis usually). To compute the power spectrum:
N/2values of FFT output (re*re + im*im)10 * log10 (magnitude squared))