Ejemplo n.º 1
0
        public void PlotInvFFT(List <float> dataList, int sampleRate)
        {
            var windowsize = dataList.Count();
            var d          = Sampling.FFTFilter(dataList, windowsize, sampleRate, 5, 500);

            var point = d.Select((v, index) =>
                                 new DataPoint((double)index, v)
                                 ).ToList();

            _lineSeries.Points.Clear();
            _lineSeries.Points.AddRange(point);
        }
Ejemplo n.º 2
0
        public void UpdateFFTPlot(List <float> dataList, int sampleRate)
        {
            var windowsize = dataList.Count();

            var c = Sampling.HammingFFT(dataList, windowsize);
            //var c = Sampling.TestPlot(dataList, windowsize, sampleRate, 5, 500);

            var s     = windowsize * (1.0 / sampleRate);
            var point = c.Take(c.Count() / 1).Select((v, index) =>
                                                     new DataPoint((double)index / s,
                                                                   Math.Sqrt(v.Real * v.Real + v.Imaginary * v.Imaginary))
                                                     ).ToList();

            _lineSeries.Points.Clear();
            _lineSeries.Points.AddRange(point);

            _pv.InvalidatePlot(true);
        }
Ejemplo n.º 3
0
        private void TestPlot()
        {
            List <float> _3Hz  = new List <float>();
            List <float> _10Hz = new List <float>();

            RecordButton.Enabled = false;
            var angle = 360.0;
            //sound rate is 8000 but take data is 1024
            var testRate = 1024;
            var c        = angle / testRate;
            var hz3      = c * 3;
            var hz10     = c * 10;
            var hz400    = c * 400;

            for (int i = 0; i < testRate; i++)
            {
                var hz3v = (float)Math.Sin(hz3
                                           * i * (Math.PI / 180));
                var hz10v = (float)Math.Sin(hz10 *
                                            i * (Math.PI / 180));
                var hz400v = (float)Math.Sin(hz400 *
                                             i * (Math.PI / 180));
                _3Hz.Add(hz3v);
                _10Hz.Add(hz10v);

                //sum wave
                _recorded1.Add(hz3v + hz10v);
                //_recorded1.Add(hz400v);
            }

            _p1.UpdatePlot(_recorded1);             //3HZ + 10HZ

            //before FFT, Hamming.
            _p2.UpdateFFTPlot(_recorded1, testRate);

            //lowPassFilter = 0   HighPassFilter =  5
            var f = Sampling.FFTFilter(_recorded1,
                                       _recorded1.Count(), testRate, 0, 5);

            _p3.UpdatePlot(f);
        }