0

So i have a array of floats where FFT has already been performed on. Now i have a array full of values, but how do i get the main frequency out of that? I have tried this that i found on another page(How do I obtain the frequencies of each value in an FFT?) but it doesn't work with my code.

Where FloatArray is where all the values of the FFT process are stored, and freq is a list where the freq of each value is stored

         List<float> freq=new List<float>();

        for(int i=0;i<FloatArray.Length/2;i++)
        {
            float ja = (i * values.sampleRate) / FloatArray.Length;
            freq.Add(ja);
        }
Community
  • 1
  • 1
  • 3
    *"it doesn't work with my code"* - what is exactly not working? – Sinatr Dec 14 '15 at 15:46
  • The output of your FFT should be *complex value pairs* - how are these stored ? Or did you already calculate the complex *magnitude* ? – Paul R Dec 14 '15 at 16:54
  • I get values from 0 to 16383 followed by -16383 to -10718. How do i get my main frequency out of this? – Thomas Van Raemdonck Dec 14 '15 at 16:55
  • You're looking for a peak *magnitude* in the FFT output - calculate the *magnitude* for each bin, find the largest bin magnitude, then take the *index* of this peak magnitude and convert it to a frequency. – Paul R Dec 14 '15 at 16:57
  • I found the peak magnitude but its always the first one in the array is this correct? – Thomas Van Raemdonck Dec 14 '15 at 18:20
  • The first value is the DC offset. If the DC offset is larger than any sinusoid present, then that is correct. – hotpaw2 Dec 14 '15 at 18:36

0 Answers0