public void StopRecord() { if (isRecording) { isRecording = false; captureStream.Stop(); audio.Stop(); System.Threading.Thread.Sleep(100); video.Close(); mergeAudioAndVideo(); } }
private void DisposeAudioDevice() { if (audioCaptureDevice == null) { return; } if (audioCaptureDevice.IsRunning) { audioCaptureDevice.Stop(); } audioCaptureDevice.NewFrame -= AudioCaptureDeviceNewFrame; }
/// <summary> /// Create capture buffer, output wave file and stream recorded samples to disk every 50 milliseconds /// </summary> public void StreamAudio() { AudioListener.Position = new Vector3D(0, 0, 0); AudioListener.Velocity = new Vector3D(0, 0, 0); AudioListener.Orientation = new Orientation(new Vector3D(1, 1, 0), new Vector3D(0, 1, 0)); Byte[] recordedData = null; AudioFormatEnum HQcaptureFormat = AudioFormatEnum.Stereo16; int HQcaptureFrequency = 44100; int HQcaptureBufferSize = 1028000; //Console.WriteLine("Creating File {0}", Environment.CurrentDirectory + "\\test.wav"); if (_FileName == "") { _FileName = "undefined.wav"; } WaveFileWriter wave = new WaveFileWriter(); wave.CreateFile(_FileName, HQcaptureFormat); using (AudioCaptureDevice g = new AudioCaptureDevice(null, HQcaptureFormat, HQcaptureFrequency, HQcaptureBufferSize)) { //Console.WriteLine("Started Recording (press Enter To Stop)"); g.Start(); while (OpenALRecoding) { Thread.Sleep(50); int samplecount = g.AvaliabeSampleCount; recordedData = g.CaptureSamples(); wave.WriteCaptured(recordedData); } g.Stop(); //Console.WriteLine("Stopped Recording"); } wave.CloseFile(); //Console.WriteLine("File Saved"); }