Exemple #1
0
        private void StartOuput(MMDevice input, MMDevice output)
        {
            Stop();

            if (output == null)
            {
                MessageBox.Show("No output ?");
            }

            // MessageBox.Show(output.AudioClient.MixFormat.SampleRate + "/" + output.AudioClient.MixFormat.Channels);

            var wf = new WaveFormat(44100, 16, 2);

            try
            {
                playbackMixer = new PlaybackMixer(wf);
                playbackMixer.Start(output);

                trackMicrophone = playbackMixer.AddPlaybackTrack();
                trackWaves      = playbackMixer.AddPlaybackTrack();


                if (input != null)
                {
                    microphone = MicrophoneWaveInProvider.CreateMicrophone(input, input.AudioClient.MixFormat);
                    trackMicrophone.Play(microphone);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Exemple #2
0
        public void Stop()
        {
            if (playbackMixer != null)
            {
                playbackMixer.Stop();
                playbackMixer = null;

                microphone?.Stop();
            }
        }
Exemple #3
0
 private void Form1_Load(object sender, EventArgs e)
 {
     inputDeviceBindingSource.DataSource = PlaybackMixer.GetInputDevices();
     mMDeviceBindingSource.DataSource    = PlaybackMixer.GetOutputDevices();
 }