コード例 #1
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="audioSettings"></param>
 public void UpdateEqualizer(AudioSettings audioSettings)
 {
     if (audioSettings.isEightBitSample)
         _equalizer = new Equalizer8Bit(audioSettings, DrawingSpace1.ActualWidth, DrawingSpace1.ActualHeight, _UpdateGraphics);
     else
         _equalizer = new Equalizer16Bit(audioSettings, DrawingSpace1.ActualWidth, DrawingSpace1.ActualHeight, _UpdateGraphics);
 }
コード例 #2
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="settings">Current settings.</param>
 /// <param name="width">Width.</param>
 /// <param name="height">Height.</param>
 /// <param name="updateGraphicsMethod">Method for updating graphics.</param>
 public Equalizer16Bit(AudioSettings settings,
     double width,
     double height,
     Action<IList<Rect>, IList<Rect>, IList<Point>, IList<Point>> updateGraphicsMethod)
     : base(settings, width, height, updateGraphicsMethod)
 {
 }
コード例 #3
0
        /// <summary>
        /// Starts or stops recognizing process.
        /// </summary>
        private void StopStartSwitch_Click(object sender, RoutedEventArgs e)
        {
            bool isChecked = StopStartSwitch.IsChecked.GetValueOrDefault();

            if (isChecked)
            {
                if (!_IsEnvironmentGood())
                    return;

                if (_recognizer != null && _recognizer.State == ApplicationState.Recording)
                    return;

                // Create appropriate settings.
                AudioSettings audioSettings = new AudioSettings();

                audioSettings.AudioInputDevice = _selectedDevice; // -1 default
                audioSettings.isEightBitSample = false; // 8 or 16 bits
                audioSettings.Channels = 1; // mono
                audioSettings.SamplesPerSecond = 16000;// 48000;

                // Load equalizer.
                GraphicEqualizer.UpdateEqualizer(audioSettings);

                // Count timing
                _StartTimeCounters();

                // Start recognizing.
                _recognizer.Start(audioSettings, GraphicEqualizer.ProcessSound,
                    _selectedShortCultureName, TemporaryFolderPath.Text);

                // Disable some elements.
                SettingsTab.IsEnabled = false;
            }
            else
            {
                if (_recognizer == null || _recognizer.State == ApplicationState.Idle)
                    return;

                _StopTimeCounters();

                _recognizer.Stop();

                // Enable disabled elements.
                SettingsTab.IsEnabled = true;
            }
        }
コード例 #4
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);
            }
        }
コード例 #5
0
        /// <summary>
        /// Starts recording of sound with using specified audio settings.
        /// </summary>
        /// <param name="settings">Audio settings.</param>
        /// <param name="equalizer">Equalizer.</param>
        /// <returns>Changed state of application.</returns>
        public ApplicationState Start(AudioSettings settings,
            Action<List<byte>, IntPtr> soundProcessing,
            string shortLanguageName,
            string temporaryFolder)
        {
            _shortLanguageName = shortLanguageName;
            _tempWavFilePath = _GetTemporaryFilePath(temporaryFolder, "wav");
            _tempFlacFilePath = _GetTemporaryFilePath(temporaryFolder, "flac");
            _soundProcessing = soundProcessing;

            if (State == ApplicationState.Idle)
            {
                _RecorderLoad(settings);

                _timer.Start();

                _RecordWave();
            }
            else
            {
                Debug.Assert(false);
            }

            return State;
        }