コード例 #1
0
        /// <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);
            }
        }
コード例 #2
0
        /// <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;
            }
        }
コード例 #3
0
        /// <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);
            }
        }