Possible Duplicate:
Fast fourier transform in c#
I am looking for an example of performing a real time FFT (Fast Fourier Transform) of line in or mic audio data in C#. My goal is to determine in real time if a particular note is present in the audio data. Any examples appreciated.
Y = fft( X ) computes the discrete Fourier transform (DFT) of X using a fast Fourier transform (FFT) algorithm. If X is a vector, then fft(X) returns the Fourier transform of the vector. If X is a matrix, then fft(X) treats the columns of X as vectors and returns the Fourier transform of each column.
As the name implies, the Fast Fourier Transform (FFT) is an algorithm that determines Discrete Fourier Transform of an input significantly faster than computing it directly. In computer science lingo, the FFT reduces the number of computations needed for a problem of size N from O(N^2) to O(NlogN) .
Fourier Transform is a function. Fast Fourier Transform is an algorithm. It is similar to the relationship between division and long division. Division is a function, long division is a way to compute the function.
AForge.NET is an open-source library with Fast Fourier Transform support.
ExocortexDSP is also another option.
ExocortexDSP example would look something like this:
Exocortex.DSP.ComplexF[] complexData = new Exocortex.DSP.ComplexF[512];
for (int i = 0; i < 512; ++i)
{
// Fill the complex data
complexData[i].Re = 1; // Add your real part here
complexData[i].Im = 2; // Add your imaginary part here
}
// FFT the time domain data to get frequency domain data
Exocortex.DSP.Fourier.FFT(complexData, Exocortex.DSP.FourierDirection.Forward);
float[] mag_dat_buffer = new float[complexData.Length];
// Loop through FFT'ed data and do something with it
for (int i = 0; i < complexData.Length; ++i)
{
// Calculate magnitude or do something with the new complex data
mag_data_buffer[i] = ImaginaryNumberMagnitude(complexData[i].Im, complexData[i].Re);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With