NOTE: This is not a duplicate, I have specific requirements other than related questions.
To start with, I want to plot the spectrum of an audio file (.wav) just lik
The signature is
public static void FFT( float[] data, int length, FourierDirection direction )
Here's an example of a working code:
float[] data = new float[8];
data[0] = 1; data[2] = 1; data[4] = 1; data[6] = 1;
Fourier.FFT(data, data.Length/2, FourierDirection.Forward);
I'm giving it 4 samples, all the same. So I expect to get something only at frequency 0. And indeed, after running it, I get
data[0] == 1, data[2] == 1, data[4] == 1, data[6] == 1
And others are 0.
If I want to use the Complex array overload
Complex[] data2 = new Complex[4];
data2[0] = new Complex(1,0);
data2[1] = new Complex(1, 0);
data2[2] = new Complex(1, 0);
data2[3] = new Complex(1, 0);
Fourier.FFT(data2,data2.Length,FourierDirection.Forward);
Please note that here the second parameter equals the length of the array, since each array member is a complex number. I get the same result as before.
I think I missed the complex overload before. I seems less error prone and more natural to use, unless your data already comes in pairs.