Hello, I am new to NAudio and am playing with the NAudioWpfDemo FFT code and I am trying to understand the FFT results. I am using the demo's SampleAggregator.cs and AudioPlayback.cs with an _fftlength of 16.
public AudioPlayback()
{
_fftLength = 16;
aggregator = new SampleAggregator(_fftLength);
aggregator.NotificationCount = 882;
aggregator.PerformFFT = true;
}
Here's my form's callback method which is being called:
void audioGraph_FftCalculated(object sender, FftEventArgs e)
{
int qtyBins = audioPlayback.FFTLength / 2; // This equals 8
for (int j = 0; j < qtyBins; j++)
{
// audioPlayback.SampleRate = 44100
double freq = j * (audioPlayback.SampleRate / audioPlayback.FFTLength);
double dx = e.Result[j].X; double dy = e.Result[j].Y;
Debug.WriteLine(j + " " + freq/1000 + "kHz = " + dx + " " + dy);
}
}
And here's some of the callback's output:
bin freq result.X result.Y
0 0kHz = 0.0895436406135559 0
1 2.756kHz = 0.0815449208021164 0.072540670633316
2 5.512kHz = 0.0273693520575762 0.0248471423983574
3 8.268kHz = 0.000522108399309218 0.00102939654607326
4 11.024kHz = 0.00428497046232224 0.00206405459903181
5 13.78kHz = 0.0028145220130682 0.00431088916957378
6 16.536kHz = 0.00255107693374157 0.00238887779414654
7 19.292kHz = 0.000449806451797485 1.36718153953552E05
So, as I understand these results, I have 8 bins, and each bin relates to a (average?) frequency. But what are the X and Y components? I am assuming the X component is the average amplitude (energy?) of the frequency, but I have no idea what the Y represents?
What I would like to do is display a bar graph, one for each frequency bin, showing the amplitude of each. But those numbers don't seem to be inline with my expectations.
Can some explain how I can take these values and display a reasonable graph? Or, are these values even the expected results from a musical song?
Oh, and what does the aggregator.NotificationCount = 882 mean? What is a NotificationCount?
Any insight would be greatly appreciated!
Thank you,
Dan
