/// <summary>
        /// This is invoked once per second.
        /// It looks for new recording devices, such as when a mic is plugged in. If it finds one,
        /// it switches the Recorder to use it.
        /// It also checks whether the current recording device is still available. If not,
        /// it switches to whatever is the current default recording device (unless a new one was found,
        /// which takes precedence).
        /// The list of RecordingDevice.Devices, at least on Win7 with USB mics, seems to update as things
        /// are connected and disconnected.
        /// I'm not sure this approach will detect the plugging and unplugging of non-USB mics.
        /// </summary>
        /// <remarks>We compare product names rather than actual devices, because it appears that
        /// RecordingDevices.Devices creates a new list of objects each time; the ones from one call
        /// are never equal to the ones from a previous call.</remarks>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void OnCheckNewMicTimer_Tick(object sender, EventArgs e)
        {
            if (_recorder == null)
            {
                return;
            }
            // Don't try to change horses in the middle of the stream if recording is in progress.
            if (_recorder.RecordingState != RecordingState.Monitoring &&
                _recorder.RecordingState != RecordingState.Stopped)
            {
                return;
            }
            bool foundCurrentDevice = false;
            var  devices            = RecordingDevice.Devices.ToList();

            foreach (var device in devices)
            {
                if (!_knownRecordingDevices.Contains(device.ProductName))
                {
                    _recorder.SelectedDevice = device;
                    if (_recorder.RecordingState == RecordingState.Monitoring)
                    {
                        _knownRecordingDevices.Add(device.ProductName);
                        UpdateDisplay();
                        return;
                    }
                }
                if (_recorder.SelectedDevice != null && device.ProductName ==
                    _recorder.SelectedDevice.ProductName)
                {
                    foundCurrentDevice = true;
                }
            }
            if (foundCurrentDevice)
            {
                if (_recorder.RecordingState != RecordingState.Monitoring)
                {
                    _recorder.BeginMonitoring();
                    if (_recorder.RecordingState == RecordingState.Monitoring)
                    {
                        UpdateDisplay();
                    }
                }
            }
            else
            {
                // presumably unplugged...try to switch to another.
                var defaultDevice = devices.FirstOrDefault();
                if (defaultDevice != _recorder.SelectedDevice)
                {
                    _recorder.SelectedDevice = defaultDevice;
                    UpdateDisplay();
                }
            }
            // Update the list so one that was never active can be made active by unplugging and replugging
            SetKnownRecordingDevices(devices);
        }
        private void BeginMonitoring(int recordingDevice)
        {
            //recorder.BeginMonitoring(recordingDevice);
            //RaisePropertyChanged("MicrophoneLevel");

            //recorder.BeginMonitoring(1);
            //recorder2.BeginMonitoring(3);
            recorder.BeginMonitoring(recordingDevice);
            //recorder2.BeginMonitoring(recordingDevice);

            RaisePropertyChanged("MicrophoneLevel");
        }
예제 #3
0
 private static void BeginMonitoring(int recordingDevice)
 {
     recorder.BeginMonitoring(recordingDevice);
 }
예제 #4
0
 public void Start()
 {
     Init(_config);
     _audioRecorder.BeginMonitoring(_config.InputDevice);
 }
 private void BeginMonitoring2(int recordingDevice2)
 {
     recorder2.BeginMonitoring(recordingDevice2);
     RaisePropertyChanged("MicrophoneLevel2");
 }