private void rewindSaveBtn_Click(object sender, EventArgs e) { //Get usable buffer and read bytes byte[] buffer = new byte[rewind.GetUsableBytes()]; rewind.ReadBuffer(buffer, 0); //Open a file prompt SaveFileDialog fd = new SaveFileDialog(); fd.Title = "Save Audio Buffer"; fd.Filter = "Audio File (*.wav)|*.wav"; DialogResult ar = fd.ShowDialog(); //Save if (ar == DialogResult.OK) { using (FileStream fs = new FileStream(fd.FileName, FileMode.Create)) using (WavEncoder wav = new WavEncoder(fs, rewind)) { wav.Write(buffer, 0, buffer.Length); wav.Flush(); } rewind.ResetBuffer(); } }
public void ReadBufferIntoWav(WavEncoder wav) { //Get usable buffer and read bytes byte[] buffer = new byte[GetUsableBytes()]; ReadBuffer(buffer, 0); //Write wav.Write(buffer, 0, buffer.Length); }