Beispiel #1
0
        private void button3_Click(object sender, EventArgs e)
        {
            const int M = 8;

            int       p = (int)Math.Floor(Math.Log(1.0 * _transformedSource.Count / M, 2));
            int       availableCount = M * (int)Math.Pow(2, p);
            var       range          = _transformedSource.GetRange(0, availableCount);
            var       signalCut      = range.Select(pt => new Complex(pt.Y, 0)).ToArray();
            Stopwatch sw             = new Stopwatch();

            sw.Start();
            var transform = FourierTransformer.FFTn(signalCut, M, false);

            sw.Stop();
            TimeSpan timeSpan = sw.Elapsed;

            label1.Text = string.Format("Time: {0}m {1}s {2}ms", timeSpan.Minutes, timeSpan.Seconds, timeSpan.Milliseconds);

            var fft = FourierTransformer.CalculateSpecs(transform);

            sourceChart.DataSource = range;
            sourceChart.DataBind();

            ampSpec.DataSource                = fft.amplitudeSpec.GetRange(0, fft.amplitudeSpec.Count / 2);
            ampSpec.Series[0].XValueMember    = "X";
            ampSpec.Series[0].YValueMembers   = "Y";
            ampSpec.ChartAreas[0].AxisX.Title = "Гц";
            ampSpec.DataBind();


            phaseSpec.DataSource                = fft.phaseSpec.GetRange(0, fft.phaseSpec.Count / 2);
            phaseSpec.Series[0].XValueMember    = "X";
            phaseSpec.Series[0].YValueMembers   = "Y";
            phaseSpec.ChartAreas[0].AxisX.Title = "Гц";
            phaseSpec.DataBind();
        }