Exemplo n.º 1
0
 /// <summary>断开与音频输入设备的连接</summary>
 public void Stop()
 {
     if (this.IsRunning)
     {
         if (waveIn == null)
         {
             return;
         }
         try
         {
             waveIn.StopRecording();
             waveIn.Dispose();
         }
         catch (Exception ex)
         {
             Console.WriteLine(" -> audio.stop.error");
             Console.WriteLine(ex.ToString());
         }
         finally
         {
             waveIn = null;
         }
     }
     this.IsRunning = false;
 }
Exemplo n.º 2
0
 void OnRecordingStopped(object sender, EventArgs e)
 {
     IsCapturing = false;
     CloseRecording();
     captureDevice.Dispose();
     captureDevice = null;
 }
Exemplo n.º 3
0
 /// <summary>
 /// Attempts to disconnect from data input source.
 /// </summary>
 /// <remarks>
 /// Derived classes should attempt disconnect from data input source here.  Any exceptions thrown
 /// by this implementation will be reported to host via <see cref="AdapterBase.ProcessException"/> event.
 /// </remarks>
 protected override void AttemptDisconnection()
 {
     if ((object)m_waveIn != null)
     {
         m_waveIn.Dispose();
         m_waveIn = null;
     }
 }
Exemplo n.º 4
0
        private void InitReader()
        {
            waveProvider = new BufferedWaveProvider(input.WaveFormat);

            provider                = waveProvider.ToSampleProvider();
            input.DataAvailable    += AddData;
            input.RecordingStopped += (s, a) => { input?.Dispose(); };
        }
Exemplo n.º 5
0
        public void Reset()
        {
            player?.Dispose();
            player = null;
            recorder?.Dispose();
            recorder = null;

            Recorder_Load(this, new EventArgs());
        }
Exemplo n.º 6
0
 public void Dispose()
 {
     if (_waveIn != null)
     {
         _waveIn.StopRecording();
         _waveIn.DataAvailable -= OnDataAvailable;
         _waveIn.Dispose();
     }
     _writer?.Close();
 }
Exemplo n.º 7
0
 public void Dispose()
 {
     if (wave_in != null)
     {
         wave_in.StopRecording();
         wave_in.Dispose();
         wave_in = null;
     }
     if (writer != null)
     {
         writer.Close();
         writer = null;
     }
 }
Exemplo n.º 8
0
 public void Dispose()
 {
     if (_waveIn != null)
     {
         _waveIn.StopRecording();
         _waveIn.Dispose();
         _waveIn = null;
     }
     if (_writer != null)
     {
         _writer.Close();
         _writer = null;
     }
 }
Exemplo n.º 9
0
 public void close()
 {
     if (!_online)
     {
         return;
     }
     // Close Device
     if (openDev.audioDeviceType == AudioDeviceType.Windows)
     {
         try
         {
             waveIn.StopRecording();
             waveIn.Dispose();
         }
         catch (Exception E)
         {
         }
         waveIn  = null;
         openDev = null;
     }
     else     // WASAPI Device
     {
         try
         {
             WASAPIwaveIn.StopRecording();
             WASAPIwaveIn.Dispose();
         }
         catch (Exception E)
         {
         }
         WASAPIwaveIn = null;
         openDev      = null;
     }
     _online = false;
 }
Exemplo n.º 10
0
        //private void DisposeAudioWriters() {
        //    mutAudioFileProcess.WaitOne();

        //    audioFileWriters = null;
        //    mutAudioFileProcess.ReleaseMutex();
        //}



        public void Dispose()
        {
            isDisposing = true;
            camera.StopCameras();
            camera.Dispose();
            mutAudioFileProcess.Dispose();
            mutVideoRecord.Dispose();
            try
            {
                threadVideoDisplay.Join();
                threadVideoDisplay = null;

                threadVideoFrameExtract.Join();
                threadVideoFrameExtract = null;

                threadAudioDisplay.Join();
                threadAudioDisplay = null;
                AudioDataAvailable = null;
                VideoDataAvailable = null;
                // audio complete
                audioCaptureDevice.DataAvailable -= OnAudioDataAvailable;
                audioCaptureDevice.StopRecording();
                audioCaptureDevice.Dispose();
            }
            catch (Exception e)
            {
                Debug.WriteLine($"An exception occured when the {field.ToString()}-view Kinect is being closed!");
                Debug.WriteLine(e.ToString());
            }
        }
Exemplo n.º 11
0
 private void ExecuteStop()
 {
     //SpectralAnaliser0.Stop();
     //SpectralAnaliser1.Stop();
     wave_in.StopRecording();
     wave_in.Dispose();
 }
Exemplo n.º 12
0
 public void Stop()
 {
     _waveIn.StopRecording();
     _waveIn.Dispose();
     _waveIn = null;
     //_buffer = null;
 }
Exemplo n.º 13
0
        private void InitAudio(InputState state)
        {
            filePanel.Enabled = false;

            switch (state)
            {
            case InputState.SpeakerOut:
                input = new WasapiLoopbackCapture();

                InitReader();
                break;

            case InputState.MicrophoneIn:
                input            = new WaveIn();
                input.WaveFormat = new WaveFormat(44100, 32, 2);

                InitReader();
                break;

            case InputState.FileIn:
                input = new WasapiLoopbackCapture();

                waveProvider = new BufferedWaveProvider(input.WaveFormat);

                provider                = waveProvider.ToSampleProvider();
                input.DataAvailable    += AddDataFromFile;
                input.RecordingStopped += (s, a) => { input?.Dispose(); };
                break;

            default:
                break;
            }
        }
Exemplo n.º 14
0
        private void StartRecording()
        {
            var selectedDevice = this._mmDevices.Single(d => d.ID == (string)DeviceSelectCombobox.SelectedValue);

            capture = new WasapiLoopbackCapture(selectedDevice);

            capture.RecordingStopped += (s, a) =>
            {
                writer.Dispose();
                writer = null;
                capture.Dispose();
                capture = null;
            };

            capture.DataAvailable += (s, waveInEventArgs) =>
            {
                if (writer == null)
                {
                    writer = new WaveFileWriter("test.wav", capture.WaveFormat);
                }

                writer.Write(waveInEventArgs.Buffer, 0, waveInEventArgs.BytesRecorded);
            };

            capture.StartRecording();
        }
Exemplo n.º 15
0
        /// <summary>
        /// 停止录音
        /// </summary>
        public void StopRec()
        {
            waveSource.StopRecording();

            // Close Wave(Not needed under synchronous situation)
            if (waveFile != null)
            {
                waveFile.Dispose();
                waveFile = null;
            }
            if (waveSource != null)
            {
                waveSource.Dispose();
                waveSource = null;
            }
        }
Exemplo n.º 16
0
        //Once we stop recording, clean up and store recording end date/time
        //INPUT: sender and StoppedEventArgs
        //OUTPUT:
        public void OnRecordingStopped(object sender, StoppedEventArgs e)
        {
            functionResult result = new functionResult();

            try
            {
                //Clean up everytyhing used within the recording
                if (waveIn != null)
                {
                    waveIn.Dispose();
                    waveIn = null;
                }

                if (writer != null)
                {
                    writer.Close();
                    writer = null;
                }

                //Store the date/time the recording ended to be used for calculating the sample length
                recordingEnded = DateTime.Now;
            }
            catch (Exception ex)
            {
                result.Result  = false;
                result.Message = "ERROR - OnDataAvailable - " + ex.ToString();
            }
        }
Exemplo n.º 17
0
 public void Dispose()
 {
     if (waveIn != null)
     {
         waveIn.Dispose();
     }
 }
Exemplo n.º 18
0
 // Освобождение памяти от объекта Wave
 private void WaveIn_RecordingStopped(object sender, StoppedEventArgs e)
 {
     waveIn.Dispose();
     waveIn = null;
     time.Stop();
     time.Reset();
 }
Exemplo n.º 19
0
        /// <summary>
        /// Cleanup.
        /// </summary>
        private void CleanUp()
        {
            // If recording.
            Stop();

            // Cleanup.
            if (_waveIn != null)
            {
                _waveIn.Dispose();
            }

            if (_writer != null)
            {
                _writer.Dispose();
            }

            // If the stream was created internally.
            if (_internalStream)
            {
                if (_audioStream != null)
                {
                    _audioStream.Dispose();
                }
            }

            // If the stream was created internally.
            if (_internalStream)
            {
                _audioStream = null;
            }

            _writer = null;
            _waveIn = null;
        }
Exemplo n.º 20
0
 private void WaveIn_RecordingStopped(object sender, StoppedEventArgs e)
 {
     if (waveIn != null)
     {
         waveIn.Dispose();
     }
 }
Exemplo n.º 21
0
        private void EndStreaming()
        {
            streaming = false;

            if (gzipCompressor != null)
            {
                gzipCompressor.Close();
                gzipCompressor.Dispose();
            }

            if (waveIn != null)
            {
                waveIn.StopRecording();
                waveIn.Dispose();
                waveIn = null;
            }

            if (keyboardHook != null)
            {
                keyboardHook.Dispose();
                keyboardHook = null;
            }

            Disconnect();
            UpdateTrayMenuAndIcon();
        }
Exemplo n.º 22
0
 // 停止录音的外部接口
 public void StopRecording()
 {
     waveIn.StopRecording();
     waveIn.Dispose();
     waveIn = null;
     writer.Dispose();
     writer = null;
 }
Exemplo n.º 23
0
 public void Dispose()
 {
     if (captureDevice != null)
     {
         captureDevice.Dispose();
         captureDevice = null;
     }
 }
Exemplo n.º 24
0
 public void StopRecording()
 {
     waveIn.StopRecording();
     waveIn.Dispose();
     waveFileWriter.Close();
     OnRecordingStopped();
     ConvertWavToMp3Thread();
 }
Exemplo n.º 25
0
 private void Cleanup()
 {
     if (captureDevice != null)
     {
         captureDevice.Dispose();
         captureDevice = null;
     }
     FinalizeWaveFile();
 }
Exemplo n.º 26
0
 private void Cleanup()
 {
     if (waveIn != null)
     {
         waveIn.Dispose();
         waveIn = null;
     }
     FinalizeWaveFile();
 }
Exemplo n.º 27
0
 private void waveSource_RecordingStopped(object sender, StoppedEventArgs e)
 {
     lock (_lock)
     {
         _waveSource.Dispose();
         _waveSource = null;
         _waveFile.Dispose();
         _waveFile = null;
     }
 }
Exemplo n.º 28
0
 public override void stopRecord()
 {
     if (newWaveIn != null)
     {
         newWaveIn.StopRecording();
         newWaveIn?.Dispose();
         newWaveIn = null;
     }
     if (stopWatch != null)
     {
         stopWatch.Stop();
     }
     if (aTimer != null)
     {
         aTimer.Stop();
         aTimer.Dispose();
     }
     startListeningAfterStop = false;
 }
Exemplo n.º 29
0
 void OnRecordingStopped(object sender, StoppedEventArgs e)
 {
     // Writer Close() needs to come first otherwise NAudio will lock up.
     if (_writer != null)
     {
         _writer.Close();
         _writer = null;
     }
     if (_waveIn != null)
     {
         _waveIn.Dispose();
         _waveIn = null;
     }
     _isRecording = false;
     if (e.Exception != null)
     {
         throw e.Exception;
     }
 } // end void OnRecordingStopped
Exemplo n.º 30
0
        protected override void OnClosed(EventArgs e)
        {
            // Inout Output device and cache must be disposed explicitly
            waveOut?.Dispose();
            capture?.Dispose();
            cache?.Dispose();

            updateTimer?.Dispose();
            base.OnClosed(e);
        }