private void WavePlayerOnPlaybackStopped(object sender, StoppedEventArgs stoppedEventArgs) { if (reader != null) { SliderPosition = 0; //reader.Position = 0; timer.Stop(); } if (stoppedEventArgs.Exception != null) { MessageBox.Show(stoppedEventArgs.Exception.Message, "Error Playing File"); } wavePlayer.Dispose(); wavePlayer = null; OnPropertyChanged("IsPlaying"); OnPropertyChanged("IsStopped"); }
private void OnPlaybackStopped(object sender, StoppedEventArgs args) { lock (_path) { if (_outputDevice != null) { _outputDevice.Dispose(); _outputDevice = null; if (_audioFile != null) { _audioFile.Dispose(); _audioFile = null; } } } IsPlaying = false; PlaybackStopped?.Invoke(sender, args); }
void waveOut_PlaybackStopped(object sender, StoppedEventArgs e) { if (_log.IsDebugEnabled) { _log.DebugFormat("Starting {0}", MethodBase.GetCurrentMethod().ToString()); } if (!NoPlay) { Changed("IsPlaying"); PlayNextInQueue(); } Changed("IsPlaying"); if (_log.IsDebugEnabled) { _log.DebugFormat("Ending {0}", MethodBase.GetCurrentMethod().ToString()); } }
private void OnRecordingStopped(object sender, StoppedEventArgs e) { if (waveIn != null) { waveIn.Dispose(); waveIn = null; } if (writer != null) { writer.Close(); writer = null; } if (e.Exception != null) { MessageBox.Show(String.Format("出现问题 {0}", e.Exception.Message)); } TitleLabel.Text = "录音工具"; }
/// <summary> /// 录音结束回调函数 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void waveSource_RecordingStopped(object sender, StoppedEventArgs e) { if (waveFile != null) { waveFile.Dispose(); waveFile = null; } if (waveSource != null) { waveSource.Dispose(); waveSource = null; } if (this.ups != null) { this.ups(0); } }
private async void OnRecordingStopped(object sender, StoppedEventArgs e) { Debug.WriteLine(nameof(OnRecordingStopped) + ": Start"); try { await _call.RequestStream.CompleteAsync(); } catch (Exception ex) { Debug.WriteLine(nameof(OnEndOfAudioEvent) + ": " + ex.Message); } await _responseRenderTask; _call.Dispose(); _timer.Stop(); ButtonStartRecord.IsEnabled = true; Debug.WriteLine(nameof(OnRecordingStopped) + ": Start"); }
private void OnRecordingStopped(object sender, StoppedEventArgs e) { if (!this.Dispatcher.CheckAccess()) { this.Dispatcher.BeginInvoke(new EventHandler <StoppedEventArgs>(OnRecordingStopped), sender, e); } else { FinalizeWaveFile(); recordBar.Value = 0; if (e.Exception != null) { MessageBox.Show(String.Format("A problem was encountered during recording {0}", e.Exception.Message)); } SetControlStates(false); } }
/// <summary> /// Handles the PlaybackStopped event of the song control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="StoppedEventArgs"/> instance containing the event data.</param> void song_PlaybackStopped(object sender, StoppedEventArgs e) { if (!_manualStop) { if (_loops > 0) { _loops--; song.Play(0); } else if (_loops == -1) { song.Play(0); } else { NotifyPlaybackStopped(this, e); } } }
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
void OnPlaybackStopped(object sender, StoppedEventArgs e) { //_dTimer.Stop(); GlobalUser.WavePlayer?.Stop(); AudioPanelVM.SetAllDisable(); // 执行倒计时 StartCountdown(); // we want it to be safe to clean up input stream and playback device in the handler for PlaybackStopped //labelNowTime.Text = "0"; if (e.Exception != null) { Log4NetHelper.Error(String.Format("Playback Stopped due to an error {0}", e.Exception.Message)); } }
void wi_RecordingStopped(object sender, StoppedEventArgs e) { txtOutput.AppendText("Recording Stopped\r\n"); btnRecord.Enabled = true; if (wfw != null) { wfw.Dispose(); wfw = null; } if (wi != null) { wi.Dispose(); wi = null; } convertWaveToText("temp.wav"); fft.LoadRawData("temp.txt"); }
void micSource_RecordingStopped(object sender, StoppedEventArgs e) { if (micSource != null) { micSource.Dispose(); micSource = null; } if (micWaveFile != null) { micWaveFile.Dispose(); micWaveFile = null; } lock (_writeLock) { convertToMp3(); IsRecording = false; } }
private static void PlaybackDevice_PlaybackStopped(object sender, StoppedEventArgs e) { if (RepeatCurrentTrack) { StartPlaying(FilePlaying); } else if (RepeatAll && FilePlaying == audioFiles.Last()) { StartPlaying(audioFiles.First()); } else if (FilePlaying == audioFiles.Last()) { playbackFinishedEvent(); } else { PlayNext(); } }
private void WavePlayerOnPlaybackStopped(object sender, StoppedEventArgs stoppedEventArgs) { if (stoppedEventArgs.Exception != null) { MessageBox.Show(stoppedEventArgs.Exception.Message, "Playback Stopped Unexpectedly"); } else { if (!pausebool) { reader.CurrentTime = TimeSpan.FromSeconds(0); speedControl.Reposition(); if (playLoopBool && play) { wavePlayer.Play(); } } } }
void OnRecordingStopped(object sender, StoppedEventArgs e) { writer.Dispose(); writer = null; RecordingsViewModel.Recordings.Add(currentFileName); RecordingsViewModel.SelectedRecording = currentFileName; if (e.Exception == null) { Message = "Recording Stopped"; } else { Message = "Recording Error: " + e.Exception.Message; } capture.Dispose(); capture = null; RecordCommand.IsEnabled = true; StopCommand.IsEnabled = false; }
void sourceOutStream_RecordingStopped(object sender, StoppedEventArgs e) { if (sourceOutStream != null) { sourceOutStream.Dispose(); sourceOutStream = null; } if (waveWriter != null) { waveWriter.Close(); waveWriter.Dispose(); waveWriter = null; } if (equalizerWrite != null) { equalizerWrite = null; } }
/// <summary> /// 停止录音 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void OnRecordingStopped(object sender, StoppedEventArgs e) { if (InvokeRequired) { BeginInvoke(new EventHandler <StoppedEventArgs>(OnRecordingStopped), sender, e); } else { FinalizeWaveFile(); progressBar1.Value = 0; if (e.Exception != null) { MessageBox.Show(String.Format("A problem was encountered during recording {0}", e.Exception.Message)); } int newItemIndex = listBoxRecordings.Items.Add(outputFilename); listBoxRecordings.SelectedIndex = newItemIndex; SetControlStates(false); } }
private void Capture_RecordingStopped(object sender, StoppedEventArgs e) { if (Capturing != null) { Capturing.DataAvailable -= Capture_DataAvailable; Capturing.RecordingStopped -= Capture_RecordingStopped; Capturing.Dispose(); Capturing = null; } if (Writer != null) { Writer.Dispose(); Writer = null; } Recognize(); }
private void WaveSource_RecordingStopped(object sender, StoppedEventArgs e) { if (waveSource != null) { waveSource.Dispose(); waveSource = null; } if (waveFile != null) { waveFile.Dispose(); waveFile = null; } if (isCancelRecord) { isCancelRecord = false; File.Delete(_audioFileName); } }
protected override void OnStop(object sender, StoppedEventArgs e) { if (this._speech is null) { return; } var wavStream = RecognitionAudio.FromStream(e.WaveStream); var results = this._speech.Recognize(this._config, wavStream).Results; var alternatives = results.SelectMany(r => r.Alternatives); Debug.WriteLine("\n========== Results =========="); foreach (var alternative in alternatives) { Debug.WriteLine(alternative.Transcript + $"[{alternative.Confidence}]"); } Debug.WriteLine("=============================\n"); this.Responsed?.Invoke(alternatives.ToList()); }
public void onPlaybackStopped(object sender, StoppedEventArgs e) { if (this.waveOutDevice != null) { this.waveOutDevice.Stop(); this.waveOutDevice = null; } if (this.audioFileReader != null) { this.audioFileReader.Close(); this.audioFileReader = null; } if (this.playbackStoppedHandler != null) { this.playbackStoppedHandler(this); } }
void waveSource_RecordingStopped(object sender, StoppedEventArgs e) { if (capture != null) { capture.Dispose(); capture = null; } if (waveFile != null) { waveFile.Dispose(); waveFile = null; } StereoToMono(); Normalize(); StripSilence(); btnRecord.Enabled = true; }
private void OnPlaybackStopped(object sender, StoppedEventArgs args) { audioTimer.Stop(); _viewPlayer.SetTimePosition(0); if (outputDevice != null) { outputDevice.Dispose(); } outputDevice = null; if (audioFile != null) { audioFile.Dispose(); } audioFile = null; if (args != null && args.Exception == null) { MessageBox.Show("error"); } }
private void AudioInRecordingStopped(object s, StoppedEventArgs a) { _writer?.Dispose(); _writer = null; OnAudioEventAvailable(new AudioEventArgs { State = AudioRecordState.RecordStopped, Information = "Stopped Record." }); var recordAudioPath = Path.Combine(_noiseDetectionOptions.DestinationDirectory, $"autoRecord_{_currentTimeStamp}.rec"); var audioPath = Path.Combine(_noiseDetectionOptions.DestinationDirectory, $"autoRecord_{_currentTimeStamp}.wav"); File.Move(recordAudioPath, audioPath); if (!_isStopAndDisposeRequested) { _audioIn.StartRecording(); } else if (!IsListening) { DisposeAudioDevice(); } }
void OnPlaybackStopped(object sender, StoppedEventArgs e) { //groupBoxDriverModel.Enabled = true; if (e.Exception != null) { MessageBox.Show(e.Exception.Message, "Playback Device Error"); } if (outputDevice != null) { outputDevice.Dispose(); outputDevice = null; } if (audioFile != null) { audioFile.Position = 0; audioFile.Dispose(); audioFile = null; } }
/// <summary> /// Event handled when recording is stopped. We will clean up open objects here that are required to be /// closed and/or disposed of. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void OnRecordingStopped(object sender, StoppedEventArgs e) { // Writer Close() needs to come first otherwise NAudio will lock up. bytesPerMillisecond = Convert.ToInt32(bytestotal / sw.ElapsedMilliseconds); 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
/// <summary> /// Functionality to tidy up when recording has stopped. /// </summary> /// <param name="sender">Automatically generated by Visual Studio.</param> /// <param name="e">Automatically generated by Visual Studio.</param> void OnRecordingStopped(object sender, StoppedEventArgs e) { if (InvokeRequired) // If it is necessary to invoke this on a different thread { BeginInvoke(new EventHandler <StoppedEventArgs>(OnRecordingStopped), sender, e); // Send this event to the relevant thread } else { Resample(); recordingProgressBarLabel.Text = outputFileName; int newItemIndex = RecordingListBox.Items.Add(outputFileName); // Add the new audio file to the list box RecordingListBox.SelectedIndex = newItemIndex; // And select it SetControlStates(false); // Toggle the record and stop buttons if (e.Exception != null) { DeleteFile(); // Remove the now erroneous file. MPAiMessageBoxFactory.Show(string.Format(formatErrorText, e.Exception.Message)); } } }
private void OnOutputPlaybackStopped(object sender, StoppedEventArgs args) { foreach (MemeSound memeSound in memeList) { memeSound.isPlaying = false; } if (outputDevice != null) { outputDevice.Dispose(); outputDevice = null; audioFileForOutput.Dispose(); audioFileForOutput = null; } // If We're Simulating a KeyPress, Release It if (cbSimulatePTT.IsChecked.Value) { keyboardSimulator.Release((KeyboardSimulator.ScanCodeShort)pttKey); } UpdateStatusBarText("Ready..."); }
void OnRecordingStopped(object sender, StoppedEventArgs e) { if (this.InvokeRequired) { this.BeginInvoke(new EventHandler <StoppedEventArgs>(OnRecordingStopped), sender, e); } else { Cleanup(); buttonStartRecording.Enabled = true; progressBar1.Value = 0; if (e.Exception != null) { MessageBox.Show(String.Format("A problem was encountered during recording {0}", e.Exception.Message)); } int newItemIndex = listBoxRecordings.Items.Add(outputFilename); listBoxRecordings.SelectedIndex = newItemIndex; } }
private void WavOutput_PlaybackStopped(object sender, StoppedEventArgs e) { if (!isOgg) { wavFile.Position = 0; } else { vorbisFile.Position = 0; } if (loop.Checked && !forceStop) { wavOutput.Play(); forceStop = false; } else { playPause.Text = "Play"; } }