コード例 #1
0
        private void Morphing()
        {
            int startPos = (int)RectangleUI.X0;

            int err = (SelectedData.Count() % 2);

            SelectedData.RemoveRange((SelectedData.Count() - 1 - err), err);


            Complex[] tempFFT = FFT2Helper.fft(SelectedData.ToArray());

            int start = 0;
            int count = 90;
            int dest  = 10;

            tempFFT.ToList().GetRange(start, count).CopyTo(tempFFT.ToArray(), dest);

            for (int i = start; i < dest - start; i++)
            {
                tempFFT[i] = new Complex(0, 0);
            }

            for (int i = start; i < start + count; i++)
            {
                tempFFT[(tempFFT.Count() - 1) - i] = tempFFT[i];
            }

            IFFT(tempFFT, startPos);

            //  Line.Points.AddRange(res.ToList());
            Model.InvalidatePlot(true);
        }
コード例 #2
0
        private void Morphing2()
        {
            int startPos = (int)RectangleUI.X0;

            DataPoint[] res = new DataPoint[SelectedData.Count() - 2048];

            for (int x = 0; x < SelectedData.Count() - 2048; x += 100)
            {
                if (x + 2048 < SelectedData.Count() - 2048)
                {
                    Complex[] tempFFT = FFT2Helper.fft(SelectedData.GetRange(x, 2048).ToArray());

                    int start = 0;
                    int count = 900;
                    int dest  = 10;

                    tempFFT.ToList().GetRange(start, count).CopyTo(tempFFT.ToArray(), dest);

                    for (int i = start; i < dest - start; i++)
                    {
                        tempFFT[i] = new Complex(0, 0);
                    }

                    for (int i = start; i < start + count; i++)
                    {
                        tempFFT[(tempFFT.Count() - 1) - i] = tempFFT[i];
                    }

                    IFFT(tempFFT, startPos + x);
                }
            }
            //  Line.Points.AddRange(res.ToList());
            Model.InvalidatePlot(true);
        }
コード例 #3
0
        private void SelectDataChanged(List <Complex> selectedData, int start)
        {
            FFTLine.Points.Clear();
            FFTcom = FFT2Helper.fft(selectedData.ToArray()).ToList();
            int x = 0;

            FFTcom.ForEach(comp =>
            {
                FFTLine.Points.Add(new DataPoint(x, comp.Magnitude));
                x++;
            }

                           );
            FFTModel.InvalidatePlot(true);
        }
コード例 #4
0
        private void Process(int start, int end)
        {
            FFTLine.Points.Clear();

            int err = (SelectedData.Count() % 2);

            SelectedData.RemoveRange((SelectedData.Count() - 1 - err), err);

            Val[] temp = new Val[SelectedData.Count];


            int i1 = 0;

            FFT2Helper.fft(SelectedData.ToArray()).ToList().ForEach(p =>
            {
                temp[i1]            = new Val();
                temp[i1].Magnitude += p.Magnitude;
                temp[i1].Rep++;
                i1++;
            });


            for (int i = 0; i < SelectedData.Count / 2; i++)
            {
                temp[i].Magnitude = (temp[i].Magnitude / SelectedData.Count);
                FFTLine.Points.Add(new DataPoint(i, temp[i].Magnitude));
            }
            FFTModel.Axes[0].AbsoluteMaximum = temp.Count() / 2;
            //FFTModel.Axes[0].MaximumRange = temp.Count() / 2;
            //FFTModel.Axes[0].MinimumRange = temp.Count() / 2;
            FFTModel.Axes[1].Maximum   = FFTLine.Points.Select(p => p.Y).Max();
            FFTModel.Axes[0].MajorStep = (FFTModel.Axes[0].MaximumRange / 100) * 10;
            MaxFFTWidth = temp.Count() / 2;
            // FFTWidth = MaxFFTWidth - 1;
            FFTModel.InvalidatePlot(true);
        }
コード例 #5
0
        private void Process2(int start, int end)
        {
            //Сдвиг окна (shift 500 - width 512)
            int shift = 256;
            int width = 1024;

            //Диапазон частот (256 - до 22100Hz, 128 - до 11050Hz)
            int freq_range = 256;

            double[] func = FFTHelper.WindowFunc(SelectedWindowFunc, width);

            Bitmap btm = new Bitmap((end - start) / shift, 256);

            System.Drawing.Color[] freq = new System.Drawing.Color[freq_range];
            int btm_i = 0;

            FFTLine.Points.Clear();

            double[] result = new double[width];
            for (int x = 0; x < SelectedData.Count() - width; x += shift)
            {
                int i  = 0;
                int ii = 0;
                if (x + width < SelectedData.Count() - 1)
                {
                    FFT2Helper.fft(SelectedData.GetRange(x, width).ToArray()).ToList().ForEach(p =>
                    {
                        p            = p.Magnitude * func[ii];
                        int Db       = (int)(GetYPosLog(p) + 5) * 8;
                        int intense1 = Db <= 0 ? 0 : Db;

                        intense1 = intense1 > 255 ? 255 : intense1;
                        // intense1 = Math.Abs(intense1 - 255) ;
                        if (i < freq.Count())
                        {
                            freq[i] = System.Drawing.Color.FromArgb(255, intense1, intense1, 50);
                        }
                        i++;
                        ii++;
                    });


                    for (int yi = freq.Count() - 1; yi > 0; yi--)
                    {
                        btm.SetPixel(btm_i, yi, freq[Math.Abs(yi - (freq.Count() - 1))]);
                    }
                }
                btm_i++;
            }

            Spectrogramm = BitmapToImage(btm);


            //for (int i = 0; i < 2048; i++)
            //{
            //    temp[i].Magnitude = (temp[i].Magnitude / 2048);
            //    // temp[i].Magnitude = temp[i].Rep > cons ? (temp[i].Magnitude / temp[i].Rep) : 0;
            //    FFTLine.Points.Add(new DataPoint(i, temp[i].Magnitude));
            //}

            //FFTModel.InvalidatePlot(true);
        }