/// <summary> /// Close application event /// </summary> /// <param name="sender">Window object</param> /// <param name="e">Event arguments</param> private void Window_Closed(object sender, EventArgs e) { _isRun = false; _wasapiLoopbackCapture?.StopRecording(); _waveIn?.StopRecording(); }
private void SendAudioBtn_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { waveIn.StopRecording(); waveIn.Dispose(); waveFile.Dispose(); timer2.Start();//Tempo delay para mandar audio }
/// <summary> /// Stop audio source. /// </summary> /// /// <remarks><para>Stops audio source.</para> /// </remarks> /// public void Stop() { if (_sampleChannel != null) { _sampleChannel.PreVolumeMeter -= SampleChannelPreVolumeMeter; } if (_waveIn != null) { // signal to stop _waveIn.DataAvailable -= WaveInDataAvailable; _waveIn.StopRecording(); _waveIn.RecordingStopped -= WaveInRecordingStopped; if (WaveOutProvider != null) { if (WaveOutProvider.BufferedBytes > 0) { WaveOutProvider.ClearBuffer(); } WaveOutProvider = null; } _waveIn.Dispose(); _waveIn = null; } }
private void stopRecordBtn_Click(object sender, RoutedEventArgs e) { recordBtn.IsEnabled = true; stopRecordBtn.IsEnabled = false; _waveIn.StopRecording(); Title = String.Format("Enrolling..."); }
private void stopLoopback() { try { if (loopbackWaveOut != null) { loopbackWaveOut.Stop(); loopbackWaveOut.Dispose(); loopbackWaveOut = null; } if (loopbackWaveProvider != null) { loopbackWaveProvider.ClearBuffer(); loopbackWaveProvider = null; } if (loopbackSourceStream != null) { loopbackSourceStream.StopRecording(); loopbackSourceStream.Dispose(); loopbackSourceStream = null; } } catch (Exception) { } }
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; }
/// <summary> /// Records an audio sample using the specified device. /// </summary> internal static async Task <byte[]> RecordAudio(int deviceId, TimeSpan duration, CancellationToken cancellationToken) { int expectedBytes = (int)(AudioFormat.BytesPerSecond * duration.TotalSeconds); var stream = new MemoryStream(); var tcs = new TaskCompletionSource <int>(); using (var input = new WaveIn()) { input.DeviceNumber = deviceId; input.WaveFormat = WaveFormat; input.DataAvailable += (sender, args) => { if (cancellationToken.IsCancellationRequested) { tcs.TrySetCanceled(); return; } stream.Write(args.Buffer, 0, args.BytesRecorded); if (stream.Length >= expectedBytes) { input.StopRecording(); tcs.TrySetResult(0); } }; input.StartRecording(); await tcs.Task; } // Truncate to exactly the expected data. stream.SetLength(expectedBytes); return(stream.ToArray()); }
private void ReleaseResource() { if (_waveWriter != null) { _waveWriter.Close(); _waveWriter.Dispose(); _waveWriter = null; } if (_inputStream != null) { _inputStream.StopRecording(); _inputStream.DataAvailable -= InputStreamOnDataAvailable; _inputStream.Dispose(); _inputStream = null; } if (_waveOut != null) { _waveOut.Stop(); _waveOut.PlaybackStopped -= WaveOutOnPlaybackStopped; _waveOut.Dispose(); _waveOut = null; } if (_waveChanel != null) { _waveChanel.Dispose(); } if (_waveReader != null) { _waveReader.Dispose(); } }
public void Stop() { Console.WriteLine("Audio recording stopped"); timer.Stop(); WaveIn.StopRecording(); RecordingStopped?.Invoke(this, new EventArgs()); }
private void StopRec(object sender, RoutedEventArgs e) { if (sourceStream != null) { sourceStream.StopRecording(); } }
/// <summary> /// Stop audio source. /// </summary> /// /// <remarks><para>Stops audio source.</para> /// </remarks> /// public void Stop() { if (_waveIn != null) { // signal to stop try { _waveIn.StopRecording(); } catch (Exception ex) { MainForm.LogExceptionToFile(ex); } _waveIn.DataAvailable -= WaveInDataAvailable; _waveIn.RecordingStopped -= WaveInRecordingStopped; _waveIn = null; _isrunning = false; if (_sampleChannel != null) { _sampleChannel.PreVolumeMeter -= SampleChannelPreVolumeMeter; } if (WaveOutProvider != null) { if (WaveOutProvider.BufferedBytes > 0) { WaveOutProvider.ClearBuffer(); } } } }
private void uxStopButton_Click(object sender, EventArgs e) { if (!isRecording) { wplayer.Ctlcontrols.stop(); timer.Stop(); songTime.Text = "00:00"; uxProgressBar.Value = 0; } else { isRecording = false; waveIn.StopRecording(); uxTranscribeButton.Enabled = true; uxTranscribeButton.BackColor = SystemColors.Highlight; uxRecordButton.Enabled = true; uxRecordButton.BackColor = SystemColors.Highlight; uxPlayButton.Enabled = true; uxPlayButton.BackColor = SystemColors.Highlight; uxPauseButton.Enabled = true; uxPauseButton.BackColor = SystemColors.Highlight; uxProgressBar.Enabled = true; uxSoundLabel.Enabled = true; uxVolumeControl.Enabled = true; wplayer.URL = uxExportAudioDialog.FileName; hasRecorded = true; wplayer.Ctlcontrols.stop(); } }
private void OnStopRecording(object sender, EventArgs e) { waveInStream.StopRecording(); waveInStream.Dispose(); waveInStream = null; writer.Close(); writer = null; timer2.Enabled = false; /* SmtpClient smtpClient = new SmtpClient(); * NetworkCredential smtpCredentials = new NetworkCredential("*****@*****.**", "n(e{WIV%2?.g"); * * MailMessage message = new MailMessage(); * MailAddress fromAddress = new MailAddress("*****@*****.**"); * MailAddress toAddress = new MailAddress("*****@*****.**"); * MailAddress toAddress1 = new MailAddress("*****@*****.**"); * * smtpClient.Host = "mail.meuagente.com.br"; * smtpClient.Port = 587; * smtpClient.EnableSsl = false; * smtpClient.UseDefaultCredentials = false; * smtpClient.Credentials = smtpCredentials; * smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network; * * message.From = fromAddress; * message.To.Add(toAddress); * message.To.Add(toAddress1); * message.IsBodyHtml = false; * message.Subject = "Voice Message"; * message.Body = "A voice message was arrived!"; * message.Attachments.Add(new Attachment(timeStamp)); * smtpClient.Send(message); */ }
private void CloseAudio() { listeningAudioSocket?.Close(); if (outputAudio != null) { outputAudio.Stop(); outputAudio.Dispose(); outputAudio = null; } if (inputAudio != null) { inputAudio.StopRecording(); inputAudio.Dispose(); inputAudio = null; } }
// almost copied from: https://markheath.net/post/how-to-record-and-play-audio-at-same, it is triggered when record is released private void recordButton_MouseUp(object sender, MouseEventArgs e) { // to make windows speech recognition better and let buffers get flushed System.Threading.Thread.Sleep(500); // stop recording recorder.StopRecording(); // stop playback player.Stop(); // finalise the WAV file savingWaveProvider.Dispose(); // update record button status recordButton.Text = "Recognizing ..."; // use this because we are in the UI thread Application.DoEvents(); try { // perform Windows speech to text List <string> results = speechRecognizer.SpeechToText("temp.wav"); // if there is any results if (results.Count > 0) { // show the first one passwordTextBox.Text = results[0]; } } catch (Exception ex) { promptErrorAndExit(ex); } // update record button status recordButton.Text = "Hold To Record"; }
public void RecMicStop() { if (waveIn != null) { waveIn.StopRecording(); } }
private void discButton_Click(object sender, EventArgs e) { var msg = "HANG:" + username + ":" + nickName;// "CONN:" + words[2] + ":" + listenport.ToString(); var data = System.Text.Encoding.ASCII.GetBytes(msg); stream.Write(data, 0, data.Length); if (this.startSbutton.Text == "Mute") { inputRec.StopRecording(); } player.Stop(); player.Dispose(); inputRec.Dispose(); outputWaveProvider.ClearBuffer(); this.Close(); }
public void DisposeAudioOutput() { if (mainDirectSoundOut != null) { if (mainDirectSoundOut.PlaybackState != PlaybackState.Stopped) { mainDirectSoundOut.Stop(); } mainDirectSoundOut.Dispose(); mainDirectSoundOut = null; } if (mainBARStream != null) { mainBARStream.Dispose(); mainBARStream = null; } if (mainWaveIn != null) { mainWaveIn.StopRecording(); mainWaveIn.Dispose(); mainWaveIn = null; } SetTemp(); label1.Text = ""; errormessage.Text = "The audio was disposed"; }
/// <summary> /// Stop recording /// </summary> /// <param name="fadeOut">true - fade out the recording instead of stopping immediately</param> public void Stop(bool fadeOut) { if (_recordingStatus == RecordingStatus.Recording) { OnRecordingStatusChangeEvent(new RecordingStatusChangeEventArgs(RecordingStatus.StopRequested)); if (fadeOut) { _fader.Start(); } else { _waveSource.StopRecording(); } } }
public void stop() { if (!running) { return; } running = false; if (audioRecorder != null) { try { audioRecorder.StopRecording(); } catch (Exception) { } audioRecorder.Dispose(); audioRecorder = null; } if (audioEncoder != null) { audioEncoder.stop(); audioEncoder.Dispose(); audioEncoder = null; } lock (outputBuffers) { outputBuffers.Clear(); } }
private void onTimedEvent(object sender, EventArgs e) { SourceStream.StopRecording(); SourceStream = null; waveWriter.Dispose(); waveWriter = null; MessageBox.Show("recorded"); int h = Convert.ToInt32(HourBox.Text); int m = Convert.ToInt32(MinBox.Text); int s = Convert.ToInt32(SecsBox.Text); int milliseconds = (h * 60 * 60 * 1000) + (m * 60 * 1000) + (s * 1000); if (milliseconds == 0) { PlayClass.playRecording(); } else { playTimer = new System.Timers.Timer(); playTimer.Interval = milliseconds; playTimer.Elapsed += new System.Timers.ElapsedEventHandler(play); playTimer.Enabled = true; } }
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { try { if (_videoCaptureDevice != null) { _videoCaptureDevice.Stop(); _videoCaptureDevice.WaitForStop(); _fileWriter.Close(); if (!_isPreviewMode) { if (_isAudioRecording) { _waveIn.StopRecording(); _waveIn.Dispose(); _waveIn = null; _waveWriter.Close(); _waveWriter = null; } Mergefile(_audioFilePath, _videoFilePath); } } System.Windows.Application.Current.Shutdown(); } catch (Exception ex) { ErrorLogger.LogError(ex); } }
void StopButton_Click(object sender, RoutedEventArgs e) { createWavFile = Keyboard.Modifiers.HasFlag(ModifierKeys.Control); waveIn.StopRecording(); StopButton.IsEnabled = false; }
private void stopRecButton_Click(object sender, EventArgs e) { startRecButton.Enabled = true; stopRecButton.Enabled = false; if (waveDirectOut != null) { waveDirectOut.Stop(); waveDirectOut.Dispose(); waveDirectOut = null; } if (sourceStream != null) { sourceStream.StopRecording(); sourceStream.Dispose(); sourceStream = null; } if (waveWriter != null) { waveWriter.Dispose(); waveWriter = null; } }
public override void EndSend() { base.EndSend(); input.StopRecording(); input.DataAvailable -= Send; }
private void stopBtn_Click(object sender, EventArgs e) { if (waveInSource != null) { waveInSource.StopRecording(); } }
private void StopRecord(bool shouldContinue) { //Pushes initial loop continue if (isLoopStandard == true) { frmLoopstation.loopStandard = recordingTicks; isLoopStandard = false; frmLoopstation.EventListener(0); } if (loopLength == 0) { loopLength = recordingTicks; } //Stops recording waveSource.StopRecording(); audioFileList.Add(new AudioFileReader(frmLoopstation.loopPath + loopStationID + @"\" + recs[recs.Count - 1][0])); playerList[playerList.Count - 1].Init(audioFileList[playerList.Count - 1]); //Continues to record if set to if (shouldContinue == true) { Record(false); } else { isRecording = false; frmLoopstation.UpdateRecButton(loopStationID, 2); } }
public void stop() { wave.StopRecording(); wave.Dispose(); keep_alive = false; Environment.Exit(0); }
/// <summary> /// Click handler for the record button /// </summary> /// <param name="sender">The object that sent the event</param> /// <param name="e">Event arguments object</param> private void stopRecord_Click(object sender, RoutedEventArgs e) { record.IsEnabled = true; stopRecord.IsEnabled = false; _waveIn.StopRecording(); setStatus("Enrolling..."); }
public void StartListening() { try { if (ListenerString == "Start Listening") { _waveSource = new WaveIn { WaveFormat = new WaveFormat(16000, 1) }; _waveSource.DataAvailable += waveSource_DataAvailable; _waveSource.RecordingStopped += waveSource_RecordingStopped; _collectedData = new MemoryStream(); _waveFile = new WaveFileWriter(_collectedData, _waveSource.WaveFormat); _waveSource.StartRecording(); ListenerString = "Stop Listening"; } else if (ListenerString == "Stop Listening") { _waveSource.StopRecording(); ListenerString = "Start Listening"; } } catch (Exception exception) { this.LogError(exception); this.LogInfo("PLEASE CHECK IF MIC IS CONNECTED."); } }