Esempio n. 1
0
 private void Stop()
 {
     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
     }
 }
Esempio n. 2
0
 private void Start(int device)
 {
     Stop();
     try
     {
         _waveFormat = new WaveFormat(_audioFrameSize, _audioBitsPerSample, _audioChannels);
         _recorder   = new WaveInRecorder(device, _waveFormat, _audioFrameSize * 2, 3, new BufferDoneEventHandler(DataArrived));
         if (_isPlayer == true)
         {
             _player = new WaveOutPlayer(-1, _waveFormat, _audioFrameSize * 2, 3, new BufferFillEventHandler(Filler));
         }
     }
     catch (Exception ex)
     {
         throw new Exception(DateTime.Now + " : Audio exception\r\n" + ex.ToString() + "\r\n");
     }
 }