示例#1
0
        private void autocorrelationButton_Click(object sender, EventArgs e)
        {
            if (_audio != null)
            {
                actionStateLabel.Text = "PROCESSING";
                List <int> frequencies = _audio.Autocorrelation();
                string     freqText    = "";

                foreach (int freq in frequencies)
                {
                    freqText += freq.ToString() + " Hz (T = " + (1.0f / freq) + " s), ";
                }

                actionStateLabel.Text = "";
                CharWindow autoCorelation = new CharWindow();
                autoCorelation.setPropert();

                autoCorelation.Histogram.Series.Add("AutoCorelation");
                autoCorelation.Text = "AutoCorelation";
                autoCorelation.Histogram.Series["AutoCorelation"].ChartType  = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.FastLine;
                autoCorelation.Histogram.Series["AutoCorelation"].MarkerSize = 2;
                autoCorelation.Histogram.ChartAreas[0].AxisX.Title           = "Index";
                autoCorelation.Histogram.ChartAreas[0].AxisY.Title           = "AutoCorelation value";

                for (int i = 0; i < _audio.autoCorrelations[0].Count(); i++)
                {
                    autoCorelation.Histogram.Series["AutoCorelation"].Points.AddXY(i, _audio.autoCorrelations[0][i] / (32768.0f * 32768.0f * 100));
                }

                autoCorelation.Show();

                SoundUtil.SaveSound(_audio.fileName, _audio.sampleRate, _audio.chunkSize, frequencies);
                MessageBox.Show(freqText, "Autocorrelation frequencies");
            }
        }
示例#2
0
        private void cepstrumButton_Click(object sender, EventArgs e)
        {
            if (_audio != null)
            {
                actionStateLabel.Text = "PROCESSING";
                List <int> frequencies = _audio.Cepstrum();
                string     freqText    = "";

                foreach (int freq in frequencies)
                {
                    freqText += freq.ToString() + " Hz (T = " + (1.0f / freq) + " s), ";
                }

                actionStateLabel.Text = "";

                CharWindow Cepstrum = new CharWindow();
                Cepstrum.setPropert();

                Cepstrum.Histogram.Series.Add("Cepstrum");
                Cepstrum.Text = "Cepstrum";
                Cepstrum.Histogram.Series["Cepstrum"].ChartType  = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.FastLine;
                Cepstrum.Histogram.Series["Cepstrum"].MarkerSize = 2;
                Cepstrum.Histogram.ChartAreas[0].AxisX.Title     = "Index";
                Cepstrum.Histogram.ChartAreas[0].AxisY.Title     = "Cepstrum value";

                for (int i = 0; i < _audio.cepstrum.Count() / 2; i++)
                {
                    Cepstrum.Histogram.Series["Cepstrum"].Points.AddXY(i, _audio.cepstrum[i].Modulus());
                }

                Cepstrum.Show();

                CharWindow Spectrum = new CharWindow();
                Spectrum.setPropert();

                Spectrum.Histogram.Series.Add("Spectrum");
                Spectrum.Text = "Spectrum";
                Spectrum.Histogram.Series["Spectrum"].ChartType  = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.FastLine;
                Spectrum.Histogram.Series["Spectrum"].MarkerSize = 2;
                Spectrum.Histogram.ChartAreas[0].AxisX.Title     = "Index";
                Spectrum.Histogram.ChartAreas[0].AxisY.Title     = "Spectrum value";


                float[] time = new float[_audio.fftDataForSpectrumChart.Length];

                for (int i = 0; i < _audio.fftDataForSpectrumChart.Count() / 2; i++)
                {
                    time[i] = i / _audio.sampleRate;

                    Spectrum.Histogram.Series["Spectrum"].Points.AddXY(i, _audio.fftDataForSpectrumChart[i].Modulus());
                }

                Spectrum.Show();

                SoundUtil.SaveSound(_audio.fileName, _audio.sampleRate, _audio.chunkSize, frequencies);
                MessageBox.Show(freqText, "Cepstrum frequencies");
            }
        }