Exemple #1
0
 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();
 }
Exemple #2
0
        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();
            }
        }
Exemple #3
0
 public void Dispose()
 {
     wvin?.StopRecording();
     wvin?.Dispose();
 }
Exemple #4
0
 public void Dispose()
 {
     shuttingDown = true;
     wvin?.StopRecording();
     wvin?.Dispose();
 }