/// <summary> /// Loads recorder. /// </summary> /// <param name="settings">Audio settings.</param> /// <param name="equalizer">Equalizer.</param> private void _RecorderLoad(AudioSettings settings) { try { if (_isRecorderLoaded) { _RecorderUnLoad(); } // Prepare destination stream. if (_streamMemory != null) { _streamMemory.Dispose(); } _streamMemory = new MemoryStream(); // Create wave format and load recorder. _waveFormat = _CreateWaveFormat((uint)settings.SamplesPerSecond, settings.isEightBitSample, settings.Channels); _recorder = new WaveInRecorder(settings.AudioInputDevice, new BufferDoneEventHandler(_RecordData), _waveFormat); _isRecorderLoaded = true; } catch (Exception) { throw new Exception(Properties.Resources.DeviceNotFoundError); } }
/// <summary> /// Unload recorder. /// </summary> private void _RecorderUnLoad() { try { if (_recorder != null) { if (State == ApplicationState.Recording) _recorder.Stop(); _recorder.Dispose(); _recorder = null; } if (_streamMemory != null) { _streamMemory.Dispose(); _streamMemory = null; } } finally { _isRecorderLoaded = false; } }
/// <summary> /// Loads recorder. /// </summary> /// <param name="settings">Audio settings.</param> /// <param name="equalizer">Equalizer.</param> private void _RecorderLoad(AudioSettings settings) { try { if (_isRecorderLoaded) _RecorderUnLoad(); // Prepare destination stream. if (_streamMemory != null) _streamMemory.Dispose(); _streamMemory = new MemoryStream(); // Create wave format and load recorder. _waveFormat = _CreateWaveFormat((uint)settings.SamplesPerSecond, settings.isEightBitSample, settings.Channels); _recorder = new WaveInRecorder(settings.AudioInputDevice, new BufferDoneEventHandler(_RecordData), _waveFormat); _isRecorderLoaded = true; } catch (Exception) { throw new Exception(Properties.Resources.DeviceNotFoundError); } }