I am using NAudio library for C#. I have a bye array of floating points from a .wav file. I would like put this through a FFT so I can find if a song has certain frequencies. For example a frequency which of a flute etc. Is there an FFT in NAudio and if so what does it take and output?
Asked
Active
Viewed 4,481 times
1 Answers
1
Here's a SO question which explains how to calculate FFT in NAudio.
Personally, I haven't been the biggest fan of NAudio for FFT implementations, I would rather use the following open-source solutions:
AForge.net. View the ComplexImage.cs for usage & FourierTransform.cs for implementation.
Math.NET's Iridium library (licensed under the LGPL so you are free to use it in commercial products).
Chris Lomont's C# Fast Fourier Transform.
MSDN also has a great discussion and a sample FFT implementation.

Community
- 1
- 1

Devarsh Desai
- 5,984
- 3
- 19
- 21
-
fantastic, I will take a look, I'm new to DSP and was wondering what the FFT would take, can a signal as a float array be used?, also what it the output (for plotting on a visual graph)? Is there methods which do it inline ? – Pete B Oct 07 '14 at 22:19
-
hey Rob, good to hear! float arrays can definitely be used! (In fact many examples you'll encounter online will use float arrays). Also as for your return values, depending on the libraries you use it can vary (from special classes, etc), but plotting them won't be bad at all. Please let me know if you have any questions! – Devarsh Desai Oct 07 '14 at 22:24
-
Here are some sample FFT plots in C#: http://www.codeproject.com/Questions/661422/Plotting-Fast-Fourier-Transform-in-Csharp and http://libzplay.sourceforge.net/FFT_GRAPH.html and http://social.msdn.microsoft.com/Forums/vstudio/en-US/cbb28804-bb27-4f60-9f0f-7d6e79ea0f52/plotting-of-fft-graph-in-c?forum=csharpgeneral and http://stackoverflow.com/questions/18141070/how-do-i-plot-the-spectrum-of-a-wav-file-using-fft Please let me know if you have any questions! :0) – Devarsh Desai Oct 07 '14 at 22:27
-
Thank you to you both, I have written this code, it prints out the complex numbers as (3,0) for example. What are the meaning of this format. I have seen alot of the FFT rtake and return complex numbers in this format , why? i'm guessing that one number is the frequency and one the aptitude, if that is the case then the latter number is always zero from my code . any ideas, thanks in advance guys. – Pete B Oct 08 '14 at 01:22
-
Hey Rob, sorry for the late response, I had to think about your question for a while. The FFT function returns a result equal to the complex, discrete Fourier transform of your float array. The result returned by FFT is a complex array that has the same dimensions as the input array. The FFT algorithm will then return a complex spectra that will give the amplitude and phase at a series of equally spaced frequency points. Please let me know if you have any questions! – Devarsh Desai Oct 08 '14 at 16:38
-
Great explanation. Any information I put through the FFT,I then build a graph from it and the data is always mirrored. I have used a simple sign wave and I get 2 spikes, when i use a cut from some audio it is exactly mirrored. Any ideas why this is happening? – Pete B Oct 11 '14 at 13:08