private void button_play_Click(object sender, EventArgs e) { if (_wr != null && _wr.GetData() != null) { if (myChart.ChooseAreaMin < myChart.ChooseAreaMax) { _player = new PCMPlayer(_wr.GetData(), myChart.ChooseAreaMin, myChart.ChooseAreaMax, _wr.GetNum_Channels(), _wr.GetSamplesPerSec(), (short)_wr.GetBitsPerSample()); } else { _player = new PCMPlayer(_wr.GetData(), 0, _wr.GetData().Length, _wr.GetNum_Channels(), _wr.GetSamplesPerSec(), (short)_wr.GetBitsPerSample()); } _player.Play(); } }
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(); } }