/// <summary> /// Creates a new audio panel and starts an audio recording. /// </summary> /// <param name="sender">Unused.</param> /// <param name="e">Unused.</param> private void StartRecord(object sender, EventArgs e) { this.record.Visible = false; this.stopRecord.Visible = true; WaveParser parser = new WaveParser(); AudioPanel newPanel = this.NewAudioPanel(); if (this.window.IsScrollable) { int val = this.window.VScrollBar.Maximum - this.window.VScrollBar.Value; this.window.VScrollBar.Value = this.window.VScrollBar.Maximum; this.window.MainContainer.Top = this.window.MainContainer.Location.Y - val; } newPanel.Header = parser.CreateHeader(this.window.SampleRate, this.window.BitRate); newPanel.MenuStrip.InfoLabel.Text = newPanel.Header.SampleRate + " Sample rate" + " | " + newPanel.Header.BitsPerSample + " Bit rate"; recorder.RecordAudio(newPanel); }
/// <summary> /// Opens a wav file and loads the data int he time domain. /// </summary> /// <param name="sender">Unused.</param> /// <param name="e">Unused.</param> public void OpenFile(object sender, EventArgs e) { OpenFileDialog dialog = new OpenFileDialog(); dialog.Title = "Open"; dialog.CheckFileExists = true; dialog.CheckPathExists = true; dialog.Filter = "WAV File (*.wav) | *.wav"; dialog.DefaultExt = "wav"; if (dialog.ShowDialog() == DialogResult.OK) { // Parses the wave header WaveParser parser = new WaveParser(dialog.FileName); this.window.Header = parser.OpenWave(); this.window.RawData = parser.Data; // Set the info label to display the sample rate and bit rate this.InfoLabel.Text = this.window.Header.SampleRate + " Sample rate" + " | " + this.window.Header.BitsPerSample + " Bit rate"; // Split the wave channels this.window.SplitWavChannels(); // Loads the data into the time domain charts this.window.LTimeChannel.LoadData(this.window.LChannel); if (this.window.Header.Channels == 2) { if (!this.window.RTimeChannel.Chart.Visible) { this.window.AddRChannel(); } this.window.RTimeChannel.LoadData(this.window.RChannel); } else if (this.window.RTimeChannel.Chart.Visible) { this.window.RemoveRChannel(); } } }
/// <summary> /// Saves the current audio stream that is opened. /// </summary> /// <param name="sender">Unused.</param> /// <param name="e">Unused.</param> private void SaveFile(object sender, EventArgs e) { SaveFileDialog dialog = new SaveFileDialog(); dialog.Title = "Save ..."; dialog.CheckPathExists = true; dialog.Filter = "WAV File (*.wav) | *.wav"; dialog.DefaultExt = "wav"; if (dialog.ShowDialog() == DialogResult.OK) { // Converts the data into bytes List <byte> byteData = this.window.DataToBytes(); if (byteData == null) { return; } // Writes the data to a file WaveParser parser = new WaveParser(dialog.FileName); parser.SaveWave(byteData, this.window.Header); } }