Converting Real and Imaginary FFT output to Frequency and Amplitude

前端 未结 2 1422
轻奢々
轻奢々 2021-02-11 07:18

I\'m designing a real time Audio Analyser to be embedded on a FPGA chip. The finished system will read in a live audio stream and output frequency and amplitude pairs for the X

相关标签:
2条回答
  • 2021-02-11 07:54

    The FFT result will give you an array of complex values. The twice the magnitude (square root of sum of the complex components squared) of each array element is an amplitude. Or do a log magnitude if you want a dB scale. The array index will give you the center of the frequency bin with that amplitude. You need to know the sample rate and length to get the frequency of each array element or bin.

    f[i] = i * sampleRate / fftLength
    

    for the first half of the array (the other half is just duplicate information in the form of complex conjugates for real audio input).

    The frequency of each FFT result bin may be different from any actual spectral frequencies present in the audio signal, due to windowing or so-called spectral leakage. Look up frequency estimation methods for the details.

    0 讨论(0)
  • 2021-02-11 08:07

    Well, the bad news is, there's no way around needing to understand complex numbers. The good news is, just because they're called complex numbers doesn't mean they're, y'know, complicated. So first, check out the wikipedia page, and for an audio application I'd say, read down to about section 3.2, maybe skipping the section on square roots: http://en.wikipedia.org/wiki/Complex_number

    What that's telling you is that if you have a complex number, a + bi, you can picture it as living in the x,y plane at location (a,b). To get the magnitude and phase, all you have to do is find two quantities:

    • The distance from the origin of the plane, which is the magnitude, and
    • The angle from the x-axis, which is the phase.

    The magnitude is simple enough: sqrt(a^2 + b^2).

    The phase is equally simple: atan2(b,a).

    0 讨论(0)
提交回复
热议问题