I do not understand why the volume defined frequency is not as expected.
I send sounds to my microphone with a few specified frequencies in turn. I then do FFT of my microphone buffer. On exit of FFT, I have an array of complex numbers. To know the volume of sound on the defined frequency, I look at my array, the number of element in this array I get this way:
MyFrequency = n*SamplingRate/SizeOfArray.
Next, I get the magnitude of complex number
(sqrt(Re^2+Im^2)
If I'm right, this shows me the volume of sound on this frequency. But this value changes strongly, depending on the frequency. If I'm wrong, please explain to me what I need to do in order to correct my mistake. If I'm right, please explain me why this values change so much.
Are you applying a window function prior to the FFT ? If not then you will see the effects of spectral leakage, and the magnitude at any given FFT bin will only be correct if the original frequency is an exact sub-multiple of the sample rate.