private void StartWasapi() { var deviceInfos = GetAudioDeviceInfos(); if (deviceInfos.Count == 0) { throw new Exception("No audio devices found."); } DeviceInformation deviceInfo; if (DesiredDeviceNumber.HasValue && DesiredDeviceNumber.Value < deviceInfos.Count) { deviceInfo = deviceInfos[DesiredDeviceNumber.Value]; } else { deviceInfo = deviceInfos[0]; } Label = deviceInfo.Name; WasapiIn = new WasapiCaptureRT(deviceInfo.Id); WasapiIn.DataAvailable += new EventHandler <WaveInEventArgs>(WasapiIn_DataAvailable); WasapiIn.StartRecording(); }
/// <summary> /// Open socket for voice chat /// </summary> /// <param name="address"></param> private void StartVoiceChat(string address) { var splittedAddress = address.Split(':'); var ip = splittedAddress[0]; var port = splittedAddress[1]; BindSocket(); remoteEndPoint = new IPEndPoint(IPAddress.Parse(ip), Int32.Parse(port)); udpConnectionActive = true; recorder.DataAvailable += sourceStream_DataAvailable; recorder.StartRecording(); }
private void StartRecording() { var recorder = new WasapiCaptureRT(); //recorder.WaveFormat = new WaveFormat(44100, 16, 2); //var devices = await DeviceInformation.FindAllAsync(); //foreach (var device in devices) //{ // Debug.WriteLine(device.Name + " " + device.Id); //} //recorder.WaveFormat = new WaveFormat(); //recorder.WaveFormat = new WaveFormat(8000, 16, 1); recorder.WaveFormat = new WaveFormat(48000, 16, 1); recorder.DataAvailable += OnDataAvailable; Debug.WriteLine("Wave format: " + recorder.WaveFormat); Debug.WriteLine(WasapiCaptureRT.GetDefaultCaptureDevice()); recorder.StartRecording(); }