예제 #1
0
        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");
        }
예제 #2
0
 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);
 }
예제 #3
0
        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());
            }
        }
예제 #4
0
 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 = "录音工具";
 }
예제 #5
0
        /// <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);
            }
        }
예제 #6
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);
     }
 }
예제 #8
0
 /// <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);
         }
     }
 }
예제 #9
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
예제 #10
0
        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));
            }
        }
예제 #11
0
        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");
        }
예제 #12
0
        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;
            }
        }
예제 #13
0
 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();
             }
         }
     }
 }
예제 #15
0
 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;
 }
예제 #16
0
        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;
            }
        }
예제 #17
0
 /// <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);
     }
 }
예제 #18
0
        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();
        }
예제 #19
0
        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);
            }
        }
예제 #20
0
        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());
        }
예제 #21
0
            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);
                }
            }
예제 #22
0
        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;
        }
예제 #23
0
        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");
            }
        }
예제 #24
0
        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();
            }
        }
예제 #25
0
        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
예제 #27
0
 /// <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));
         }
     }
 }
예제 #28
0
 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...");
 }
예제 #29
0
 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;
     }
 }
예제 #30
0
 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";
     }
 }