Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fast Fourier Transform in C# [duplicate]

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.

like image 846
Phil Avatar asked Oct 06 '10 14:10

Phil


People also ask

How do you code Fast Fourier Transform?

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.

What is Fast Fourier Transform?

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) .

What is the difference between Fourier transform and Fast Fourier Transform?

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.


1 Answers

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);
   }
like image 143
SwDevMan81 Avatar answered Sep 22 '22 04:09

SwDevMan81