Пример #1
0
 public SampleAggregator(int fftLength)
 {
     if (!IsPowerOfTwo(fftLength))
     {
         throw new ArgumentException("FFT Length must be a power of two");
     }
     _m         = (int)Math.Log(fftLength, 2.0);
     _fftLength = fftLength;
     _fftBuffer = new Complex[fftLength];
     _fftArgs   = new FftEventArgs(_fftBuffer);
 }
Пример #2
0
        private void FftCalculated(object sender, FftEventArgs e)
        {
            var freq  = e.Result.Take(e.Result.Length / 2).Skip(1).Select(c => Math.Sqrt(c.X * c.X + c.Y * c.Y)).ToList();
            var max   = freq.Max();
            var freq2 = freq.Select(x => x / max).ToList();
            var beat  = false;

            //for (int i = 0; i < 10; i++)
            {
                if (freq2[0] > 0.8)
                {
                    beat = true;
                }
            }
            if (beat)
            {
                counter++;
            }

            //TbCounter.Text = String.Format("{0} beats", counter);
        }