public SampleAggregator(int fftLength = 1024) { if (!IsPowerOfTwo(fftLength)) { throw new ArgumentException("FFT Length must be a power of two"); } this.m = (int)Math.Log(fftLength, 2.0); this.fftLength = fftLength; this.fftBuffer = new Complex[fftLength]; this.fftArgs = new FftEventArgs(fftBuffer); this.fftBufferQueue = new Queue <Complex>(fftLength); this.bffFull = false; }
void FftCalculated(object sender, FftEventArgs e) { double sumFreq1 = 0; double sumFreq2 = 0; double sumFreq3 = 0; double temp = 0; FftChart.Series[fft].Points.Clear(); for (var i = 0; i < e.Result.Length / 2; i++) { temp = Math.Sqrt(e.Result[i].X * e.Result[i].X + e.Result[i].Y * e.Result[i].Y); if (i < 3) { sumFreq1 = sumFreq1 + temp; } else if (i < 10) { sumFreq2 = sumFreq2 + temp; } else { sumFreq3 = sumFreq3 + temp; } FftChart.Series[fft].Points.AddY(temp); } if (counter2 > 100) { SumFreq1Chart.Series[sumFreq1series].Points.Remove(SumFreq1Chart.Series[sumFreq1series].Points.First()); SumFreq2Chart.Series[sumFreq2series].Points.Remove(SumFreq2Chart.Series[sumFreq2series].Points.First()); SumFreq3Chart.Series[sumFreq3series].Points.Remove(SumFreq3Chart.Series[sumFreq3series].Points.First()); } else { counter2++; } SumFreq1Chart.Series[sumFreq1series].Points.AddY(sumFreq1); SumFreq2Chart.Series[sumFreq2series].Points.AddY(sumFreq2); SumFreq3Chart.Series[sumFreq3series].Points.AddY(sumFreq3); }