public SampleAggregator(ISampleProvider source, int fftLength = 1024)
 {
     channels = source.WaveFormat.Channels;
     if (!IsPowerOfTwo(fftLength))
     {
         throw new ArgumentException("FFT Length must be a power of two");
     }
     m = (int)Math.Log(fftLength, 2.0);
     this.fftLength = fftLength;
     fftBuffer      = new Complex[fftLength];
     fftArgs        = new FftEventArgs(fftBuffer);
     this.source    = source;
 }
Exemple #2
0
        private void FftCalculated(object sender, FftEventArgs e)
        {
            var fftResults = e.Result;

            if (fftResults.Length / 2 != bins)
            {
                bins = fftResults.Length / 2;
            }

            for (int n = 0; n < fftResults.Length / 2; n += binsPerPoint)
            {
                for (int b = 0; b < binsPerPoint; b++)
                {
                    _db += GetDbLog(fftResults[n + b]);
                }
                _fre = CalculateFrequency(n / binsPerPoint);
            }
        }