Exemplo n.º 1
0
 public void StartRecording()
 {
     StopRecording();
     try
     {
         _waveFormat = new WaveFormat(_audioFrameSize, _audioBitsPerSample, _audioChannels);
         _recorder = new WaveInRecorder(0, _waveFormat, _audioFrameSize * 2, 3, new BufferDoneEventHandler(DataArrived));
         if (_isPlayer == true)
             _player = new WaveOutPlayer(-1, _waveFormat, _audioFrameSize * 2, 3, new BufferFillEventHandler(Filler));
         //textBox1.AppendText(DateTime.Now.ToString() + " : Audio device initialized\r\n");
         //textBox1.AppendText(DateTime.Now.ToString() + " : Audio device polling started\r\n");
         //textBox1.AppendText(DateTime.Now + " : Samples per second = " + _audioSamplesPerSecond.ToString() + "\r\n");
         //textBox1.AppendText(DateTime.Now + " : Frame size = " + _audioFrameSize.ToString() + "\r\n");
         //textBox1.AppendText(DateTime.Now + " : Bits per sample = " + _audioBitsPerSample.ToString() + "\r\n");
         //textBox1.AppendText(DateTime.Now + " : Channels = " + _audioChannels.ToString() + "\r\n");
     }
     catch (Exception ex)
     {
         //textBox1.AppendText(DateTime.Now + " : Audio exception\r\n" + ex.ToString() + "\r\n");
     }
 }
Exemplo n.º 2
0
 private void StopRecording()
 {
     if (_recorder != null)
         try
         {
             _recorder.Dispose();
         }
         finally
         {
             _recorder = null;
         }
     if (_isPlayer == true)
     {
         if (_player != null)
             try
             {
                 _player.Dispose();
             }
             finally
             {
                 _player = null;
             }
         _stream.Flush(); // clear all pending data
     }
 }