Exemple #1
0
 extern static System.Int32 FFT_translateToSpectrum(out System.Double p_delte_hz, out System.Double p_amplitude, out FFT_Complex p_dst, FFT_Complex[] p_src, System.Int32 num_of_points, System.Double hz);
Exemple #2
0
        private void btnFileRead_Click(object sender, EventArgs e)
        {
            string[] s_arr = null;


            lvInput.Items.Clear();
            lvOutput.Items.Clear();
            m_fft_in   = null;
            m_fft_out  = null;
            m_fft_out2 = null;
            m_real     = null;

            chartInput.Series["實數"].Points.Clear();
            chartInput.Series["虛數"].Points.Clear();


            if (ofdInput.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }

            s_arr       = System.IO.File.ReadAllLines(ofdInput.FileName);
            m_fft_in    = new FFT_Complex[s_arr.Length - 1];
            m_fft_out   = new FFT_Complex[s_arr.Length - 1];
            m_fft_out2  = new FFT_Complex[s_arr.Length - 1];
            m_real      = new double[s_arr.Length - 1];
            m_amplitude = new double[(s_arr.Length - 1) / 2];

            m_hz = double.Parse(s_arr[0]);
            switch (cmbFileRead.SelectedIndex)
            {
            case 0:
                PointPairList[] list = new PointPairList[2];
                GraphPane       pane = zgcTest.GraphPane;

                list[0] = new PointPairList();
                list[1] = new PointPairList();
                for (int i = 0; i < (s_arr.Length - 1); i++)
                {
                    string[] arr = s_arr[i + 1].Split(',');

                    m_fft_in[i].real = double.Parse(arr[0]);
                    m_fft_in[i].imag = double.Parse(arr[1]);

                    ListViewItem item = lvInput.Items.Add((i + 1).ToString());
                    item.SubItems.Add(m_fft_in[i].real.ToString());
                    item.SubItems.Add(m_fft_in[i].imag.ToString());

                    chartInput.Series["實數"].Points.AddY(m_fft_in[i].real);
                    chartInput.Series["虛數"].Points.AddY(m_fft_in[i].imag);
                    list[0].Add(i + 1, m_fft_in[i].real);
                    list[1].Add(i + 1, m_fft_in[i].imag);
                }
                pane.AddCurve("", list[0], Color.IndianRed, SymbolType.None);
                pane.AddCurve("", list[1], Color.CadetBlue, SymbolType.None);
                zgcTest.AxisChange();
                zgcTest.Refresh();
                break;

            case 1:
                for (int i = 0; i < (s_arr.Length - 1); i++)
                {
                    m_fft_in[i].real = double.Parse(s_arr[i + 1]);
                    m_fft_in[i].imag = 0.0f;

                    ListViewItem item = lvInput.Items.Add((i + 1).ToString());
                    item.SubItems.Add(m_fft_in[i].real.ToString());
                    item.SubItems.Add(m_fft_in[i].imag.ToString());

                    chartInput.Series["實數"].Points.AddY(m_fft_in[i].real);
                    chartInput.Series["虛數"].Points.AddY(m_fft_in[i].imag);
                }
                break;

            case 2:
                for (int i = 0; i < (s_arr.Length - 1); i++)
                {
                    m_fft_in[i].real = 0.0f;
                    m_fft_in[i].imag = double.Parse(s_arr[i + 1]);;

                    ListViewItem item = lvInput.Items.Add((i + 1).ToString());
                    item.SubItems.Add(m_fft_in[i].real.ToString());
                    item.SubItems.Add(m_fft_in[i].imag.ToString());

                    chartInput.Series["實數"].Points.AddY(m_fft_in[i].real);
                    chartInput.Series["虛數"].Points.AddY(m_fft_in[i].imag);
                }
                break;
            }
        }
Exemple #3
0
 extern static System.Int32 FFT_translate(out FFT_Complex p_dst, FFT_Complex[] p_src, System.Int32 num_of_points);