Exemple #1
0
 private void Start()
 {
     Stop();
     try
     {
         _waveFormat = new WaveFormat(Properties.Settings.Default.SettingSamplesPerSecond, Properties.Settings.Default.SettingBitsPerSample, Properties.Settings.Default.SettingChannels);
         _recorder   = new WaveInRecorder(Properties.Settings.Default.SettingAudioInputDevice, _waveFormat, Properties.Settings.Default.SettingBytesPerFrame * Properties.Settings.Default.SettingChannels, 3, new BufferDoneEventHandler(DataArrived));
         if (_isPlayer == true)
         {
             _player = new WaveOutPlayer(Properties.Settings.Default.SettingAudioOutputDevice, _waveFormat, Properties.Settings.Default.SettingBytesPerFrame * Properties.Settings.Default.SettingChannels, 3, new BufferFillEventHandler(Filler));
         }
         consoletext += DateTime.Now.ToString() + " : Audio input device polling started\r\n";
         consoletext += DateTime.Now + " : Device = " + Properties.Settings.Default.SettingAudioInputDevice.ToString() + "\r\n";
         consoletext += DateTime.Now + " : Channels = " + Properties.Settings.Default.SettingChannels.ToString() + "\r\n";
         consoletext += DateTime.Now + " : Bits per sample = " + Properties.Settings.Default.SettingBitsPerSample.ToString() + "\r\n";
         consoletext += DateTime.Now + " : Samples per second = " + Properties.Settings.Default.SettingSamplesPerSecond.ToString() + "\r\n";
         consoletext += DateTime.Now + " : Frame size = " + Properties.Settings.Default.SettingBytesPerFrame.ToString() + "\r\n";
     }
     catch (Exception ex)
     {
         consoletext += DateTime.Now + " : " + ex.InnerException.ToString() + "\r\n";
     }
 }
 private void Stop()
 {
     if (_recorder != null)
         try
         {
             _recorder.Dispose();
         }
         finally
         {
             _recorder = null;
         }
     if (_isPlayer == true)
     {
         if (_player != null)
             try
             {
                 _player.Dispose();
             }
             finally
             {
                 _player = null;
             }
         _streamOut.Flush(); // clear all pending data
     }
     textBoxConsole.AppendText(DateTime.Now.ToString() + " : Audio input device polling stopped\r\n");
 }
        private void Start()
        {
            Stop();
            try
            {
                _waveFormat = new WaveFormat(Properties.Settings.Default.SettingSamplesPerSecond, Properties.Settings.Default.SettingBitsPerSample, Properties.Settings.Default.SettingChannels);
                _recorder = new WaveInRecorder(Properties.Settings.Default.SettingAudioInputDevice, _waveFormat, Properties.Settings.Default.SettingBytesPerFrame * Properties.Settings.Default.SettingChannels, 3, new BufferDoneEventHandler(DataArrived));
                if (_isPlayer == true)
                    _player = new WaveOutPlayer(Properties.Settings.Default.SettingAudioOutputDevice, _waveFormat, Properties.Settings.Default.SettingBytesPerFrame * Properties.Settings.Default.SettingChannels, 3, new BufferFillEventHandler(Filler));
                textBoxConsole.AppendText(DateTime.Now.ToString() + " : Audio input device polling started\r\n");
                textBoxConsole.AppendText(DateTime.Now + " : Device = " + Properties.Settings.Default.SettingAudioInputDevice.ToString() + "\r\n");
                textBoxConsole.AppendText(DateTime.Now + " : Channels = " + Properties.Settings.Default.SettingChannels.ToString() + "\r\n");
                textBoxConsole.AppendText(DateTime.Now + " : Bits per sample = " + Properties.Settings.Default.SettingBitsPerSample.ToString() + "\r\n");
                textBoxConsole.AppendText(DateTime.Now + " : Samples per second = " + Properties.Settings.Default.SettingSamplesPerSecond.ToString() + "\r\n");
                textBoxConsole.AppendText(DateTime.Now + " : Frame size = " + Properties.Settings.Default.SettingBytesPerFrame.ToString() + "\r\n");
                _audioFrame.sampleMessageTextLabel = sampleMessageTextLabel;
                _audioFrame.interactLabel = interactLabel;
                _audioFrame.neuralOutputLabel = neuralOutputlabel;

                AudioFrame.sampleNameTextBox = sampleNameTextBox;

            }
            catch (Exception ex)
            {
                textBoxConsole.AppendText(DateTime.Now + " : " + ex.InnerException.ToString() + "\r\n");
            }
        }