Exemplo n.º 1
0
        private Point[] Init2()
        {
            WAVReader wAVReader = new WAVReader();

            wAVReader.ReadWAVFile(fileName);
            wAVReader = ZipWav(wAVReader);
            //Complex[] complices = new Complex[frame];
            canvasOs.Width  = this.Width;
            canvasOs.Height = this.Height;
            int i_0 = 0;//前面为0的部分

            while (wAVReader.stereos[i_0].Left == 0 && wAVReader.stereos[i_0].Right == 0)
            {
                i_0++;
            }

            Point[] points = new Point[wAVReader.stereos.Count - i_0];
            for (int i = 0; i < points.Length; i++)
            {
                double x = (i * 1.0 / samplingRate) * unitOfOneSecond;

                double y = TranY(wAVReader.stereos[i + i_0].Left / heightZipCount);
                points[i] = new Point(x, y);
            }
            return(points);
        }
Exemplo n.º 2
0
        private WaveMap GetWaveMaps(string fileName, float shiftNumber = 0, float deviation = 0, float threshold = 0)
        {
            WAVReader wAVReader = new WAVReader();

            wAVReader.ReadWAVFile(fileName);
            WAVReader         newWAVReader = ZipWav(wAVReader);
            EndpointDetection endpoint     = new EndpointDetection();

            newWAVReader = endpoint.EndpointDetectionDeal(newWAVReader);
            //Stereo test169 = wAVReader.stereos[169];
            //Stereo test170 = wAVReader.stereos[170];
            //Stereo test171 = wAVReader.stereos[171];
            //List<WaveMap> waveMaps = new List<WaveMap>();
            Spectrogram spectrogram = new Spectrogram();

            return(spectrogram.GetSpectrogram(newWAVReader.stereos, shiftNumber, deviation, threshold));
        }
Exemplo n.º 3
0
        private void 打开ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            System.GC.Collect();
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.Filter = "波形文件|*.wav";
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                _wr = new WAVReader();
                _wr.ReadWAVFile(dlg.FileName);
                关闭文件ToolStripMenuItem.Enabled = true;
                myChart.Datas           = _wr.GetData();
                myChart.sample_frequent = _wr.GetSamplesPerSec();
                trackBar_move.Maximum   = _wr.GetData().Length;
                this.Text = "WaveViewer — " + dlg.SafeFileName;
                AllMenuInitial(true);
                myChart.Refresh();
            }
        }
Exemplo n.º 4
0
        private Point[] Init()
        {
            WAVReader wAVReader = new WAVReader();

            wAVReader.ReadWAVFile(fileName);
            Complex[] complices = new Complex[frame];


            canvasOs.Width  = this.Width;
            canvasOs.Height = this.Height;


            int i_0 = 0;//前面为0的部分

            while (wAVReader.stereos[i_0].Left == 0 && wAVReader.stereos[i_0].Right == 0)
            {
                i_0++;
            }
            for (int i = 0; i < complices.Length; i++)
            {
                complices[i] = new Complex(wAVReader.stereos[i + i_0 + startNumber].Right * Hamming(i, frame), 0);
            }

            FourierTransform.DFT(complices, FourierTransform.Direction.Backward);
            double max = 0;

            Point[] points = new Point[frame];
            for (int i = 0; i < points.Length; i++)
            {
                double x = (i * 1.0 / 44100) * unitOfOneSecond;
                if (complices[i].Magnitude > max)
                {
                    max = complices[i].Magnitude;
                }
                double y = TranY(complices[i].Magnitude / heightZipCount);
                points[i] = new Point(x, y);
            }
            return(points);
        }
Exemplo n.º 5
0
        private Point[] Init3()
        {
            WAVReader wAVReader = new WAVReader();

            wAVReader.ReadWAVFile(fileName);
            canvasOs.Width  = this.Width;
            canvasOs.Height = this.Height;

            EndpointDetection endpointDetection = new EndpointDetection();

            wAVReader = ZipWav(wAVReader);
            wAVReader = endpointDetection.EndpointDetectionDeal(wAVReader);

            Point[] points = new Point[wAVReader.stereos.Count];
            for (int i = 0; i < points.Length; i++)
            {
                double x = (i * 1.0 / 44100) * unitOfOneSecond;

                double y = TranY(wAVReader.stereos[i].Left / heightZipCount);
                points[i] = new Point(x, y);
            }
            return(points);
        }