Search code examples
c#audiosignal-processingfftfmod

Find the frequency in Hz using FMOD


I am trying to find the frequency in hertz for every bin in the fft spectrum. Below is my code just adding the fft spectrum values inside a float list.

for (int len = 0; len < nyquistLength; ++len)
    {
        for (int channel = 0; channel < numChannels; ++channel)
        {
            channs += dspFFT.spectrum[channel][len];
            if (channel == numChannels - 1)
            {
                spectrum.Add(Math.Abs(Mathf.Log10(channs)));
                Debug.Log(spectrum[len]);
                channs = 0;
            }
        }
    }

How can I use this information to obtain the Hz of each entry in the spectrum? Thanks.


Solution

  • A N-point FFT of a signal with a sample rate of 44100 produces frequency bins with center frequencies spaced 44100/N apart from 0 Hz to 44100 Hz. From 0 to the Nyquist frequency of 22050 Hz, there are N/2+1 points inclusive. So if you want the center frequencies then compute i*44100/N where i=0,1,...,N/2.