private void cbDevices_SelectedIndexChanged(object sender, EventArgs e) { wvin?.Dispose(); wvin = new NAudio.Wave.WaveInEvent(); wvin.DeviceNumber = cbDevices.SelectedIndex; wvin.WaveFormat = new NAudio.Wave.WaveFormat(rate: SAMPLE_RATE, bits: 16, channels: 1); wvin.DataAvailable += OnDataAvailable; wvin.BufferMilliseconds = 20; wvin.StartRecording(); }
private BooleanMixerControl GetMuteControl() { var waveInEvent = new NAudio.Wave.WaveInEvent(); try { //get mixer of default audio device var mixer = waveInEvent.GetMixerLine(); var muter = mixer.Controls.FirstOrDefault(x => x.ControlType == NAudio.Mixer.MixerControlType.Mute) as BooleanMixerControl; if (muter == null) { throw new Exception(BadMicrophoneMessage); } return(muter); } finally { waveInEvent.Dispose(); } }
public void Dispose() { wvin?.StopRecording(); wvin?.Dispose(); }
public void Dispose() { shuttingDown = true; wvin?.StopRecording(); wvin?.Dispose(); }