private void playBackStoppedMusic(object stream, StoppedEventArgs e) { if (outputMusic.PlaybackState == PlaybackState.Stopped) { outputMusic.Dispose(); } }
private void Form1_FormClosing(object sender, FormClosingEventArgs e) { if (_dsOne != null) { afrOne.Dispose(); loopOne.Dispose(); _dsOne.Dispose(); } if (_dsTwo != null) { afrTwo.Dispose(); loopTwo.Dispose(); _dsTwo.Dispose(); } if (driverOut != null) { driverOut.Dispose(); } //if (_WaveOutEventOne != null) //{ // _WaveOutEventOne.Dispose(); // _WaveOutEventOne = null; //} //if (_WaveOutEventTwo != null) //{ // _WaveOutEventTwo.Dispose(); // _WaveOutEventTwo = null; //} }
private void sbtSave_Click(object sender, EventArgs e) { if (sourceStream1 != null) { sourceStream1.StopRecording(); sourceStream1.Dispose(); sourceStream1 = null; sbtSave.Enabled = false; sbtOpen.Focus(); txtTenFile.Text = ""; } if (this.waveWriter != null) { this.waveWriter.Dispose(); this.waveWriter = null; } steam.Dispose(); steam2.Dispose(); output.Dispose(); output2.Dispose(); if (cdDelete.Checked) { File.Delete(currentrecord); File.Delete(currentrecord.Replace(".wav", "mic.wav")); } setdefaul(); }
public void Dispose() { if (directOut != null) { directOut.Stop(); directOut.Dispose(); } if (provider != null) { provider.ClearBuffer(); } }
private void initializeOutput() { if (_output != null) { _output.Dispose(); _output = null; } _output = new DirectSoundOut(200); _output.PlaybackStopped += _output_PlaybackStopped; _output.Init(new WaveChannel32(_audioFileReader) { PadWithZeroes = 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 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"; }
public void OpenDirectSoundDevice() { DirectSoundOut dsoundOut = new DirectSoundOut(); dsoundOut.Initialize(new CSCore.Streams.SineGenerator().ToWaveSource(16)); dsoundOut.Dispose(); }
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(); } }
private void DisposeWavePlay() { if (output != null) { if (output.PlaybackState == PlaybackState.Playing) { output.Stop(); } output.Dispose(); output = null; } if (wave != null) { wave.Dispose(); wave = null; } if (wavechannel != null) { wavechannel.Dispose(); wavechannel = null; } if (waveSignal != null) { waveSignal.Dispose(); waveSignal = null; } }
public void trackBar1_Scroll(object sender, EventArgs e) { if (waveOut != null) { waveOut.Stop(); waveOut.Dispose(); waveOut = null; } if (wi != null) { wi.StopRecording(); wi.Dispose(); wi = null; } //d = trackBar1.Value; //sourceStream = new NAudio.Wave.WaveIn(); //sourceStream.DeviceNumber = 0; //sourceStream.WaveFormat = new NAudio.Wave.WaveFormat(RATE, 1); ; //NAudio.Wave.WaveInProvider waveIn = new NAudio.Wave.WaveInProvider(sourceStream); waveOut = new NAudio.Wave.DirectSoundOut(); waveOut.Init(bwp); //sourceStream.StartRecording(); waveOut.Play(); //in_thread = new Thread(new ThreadStart(upgrate)); //in_thread.Start(); }
public void Close() { _finished = true; _context.Stop(); _circularBuffer.Clear(); _context.Dispose(); }
private void DisposeWave() { if (waveOut != null) { if (waveOut.PlaybackState == PlaybackState.Playing) { waveOut.Stop(); } waveOut.Dispose(); waveOut = null; } if (waveReader != null) { waveReader.Flush(); waveReader.Dispose(); waveReader = null; } if (waveWriter != null) { waveWriter.Flush(); waveWriter.Dispose(); waveWriter = null; } if (axWindowsMediaPlayer1.IsDisposed != true) { axWindowsMediaPlayer1.URL = null; axWindowsMediaPlayer1.currentPlaylist.clear(); //axWindowsMediaPlayer1.Dispose(); //axWindowsMediaPlayer1.Visible = true; AxWMPLib.AxWindowsMediaPlayer myMediaPlayer = new AxWMPLib.AxWindowsMediaPlayer(); this.Controls.Add(myMediaPlayer); } }
public void Dispose() { if (WaveFileReader != null) { WaveFileReader.Dispose(); } WaveFileReader = null; if (WaveChannel != null) { WaveChannel.Dispose(); } WaveChannel = null; if (MemoryStream != null) { MemoryStream.Dispose(); } MemoryStream = null; if (DirectSoundOut != null) { DirectSoundOut.Dispose(); } DirectSoundOut = null; }
public bool SetAudioEndpoint(string dev, bool usedefault = false) { System.Collections.ObjectModel.ReadOnlyCollection <DirectSoundDevice> list = DirectSoundDeviceEnumerator.EnumerateDevices(); DirectSoundDevice dsd = null; if (dev != null) // active selection { dsd = list.FirstOrDefault(x => x.Description.Equals(dev)); // find if (dsd == null && !usedefault) // if not found, and don't use the default (used by constructor) { return(false); } } DirectSoundOut dso = new DirectSoundOut(200, System.Threading.ThreadPriority.Highest); // seems good quality at 200 ms latency if (dso == null) // if no DSO, fail.. { return(false); } if (dsd != null) { dso.Device = dsd.Guid; } else { DirectSoundDevice def = DirectSoundDevice.DefaultDevice; dso.Device = def.Guid; // use default GUID } NullWaveSource nullw = new NullWaveSource(10); try { dso.Initialize(nullw); // check it takes it.. may not if no sound devices there.. dso.Stop(); nullw.Dispose(); } catch { nullw.Dispose(); dso.Dispose(); return(false); } if (aout != null) // clean up last { aout.Stopped -= Output_Stopped; aout.Stop(); aout.Dispose(); } aout = dso; aout.Stopped += Output_Stopped; return(true); }
private void DisposeWave() { if (outputSound != null) { if (outputSound.PlaybackState == NAudio.Wave.PlaybackState.Playing) { outputSound.Stop(); } outputSound.Dispose(); outputSound = null; } if (waveReader != null) { waveReader.Dispose(); waveReader = null; } if (waveSource != null) { waveSource.Dispose(); waveSource = null; } if (waveFile != null) { waveFile.Dispose(); waveFile = null; } }
/// <summary> /// フォームのクロージング処理 /// Wave関連オブジェクトのDispose処理を担当 /// </summary> private void Form1_FormClosing(object sender, FormClosingEventArgs e) { output?.Dispose(); output = null; stream?.Dispose(); stream = null; }
public void Close() { Stop(); direct_out.Stop(); direct_out.Dispose(); synth.UnloadBank(); mseq.UnloadMidi(); }
private void playBackStopped(object stream, StoppedEventArgs e) { if (outputSFX.PlaybackState == PlaybackState.Stopped) { outputSFX.Dispose(); Debug.debugMessage("disposing soundFX...", 1, false); } }
public void DisposWave() { if (output != null) { if (output.PlaybackState == PlaybackState.Playing) { output.Stop(); } output.Dispose(); output = null; } if (steam != null) { steam.Dispose(); steam = null; } }
private void playBackStoppedMoveRotate(object stream, StoppedEventArgs e) { if (outputMoveAndRotate.PlaybackState == PlaybackState.Stopped) { outputMoveAndRotate.Dispose(); Debug.debugMessage("disposing moverotatesfx...", 1, false); } }
void wavePlayer_PlaybackStopped(object sender, StoppedEventArgs e) { // dispose of wave output if (_waveOut != null) { _waveOut.Dispose(); _waveOut = null; } }
public void EndLoopback() { if (waveOut != null) { waveOut.Stop(); waveOut.Dispose(); waveOut = null; } }
/** <summary>Dispose of resoures from all members.</summary> */ public void Dispose() { Player.Stop(); Recorder.Dispose(); Layers.ForEach((x) => x.Dispose()); Player.Dispose(); Mixer = null; //Writer.Dispose(); }
void ReleasePlayer() { player.Stop(); player.Dispose(); min.Dispose(); TimerStreaming.Stop(); connected = false; sri = 0; }
static void Main(string[] args) { IWavePlayer waveOutDevice; WaveStream mainOutputStream; string fileName = @"C:\Users\Yuval\Sources\PracticeSharpProject\Audio\Ringtone 01.wma"; Console.WriteLine("Initiailizing NAudio"); try { waveOutDevice = new DirectSoundOut(50); } catch (Exception driverCreateException) { Console.WriteLine(String.Format("{0}", driverCreateException.Message)); return; } mainOutputStream = CreateInputStream(fileName); try { waveOutDevice.Init(mainOutputStream); } catch (Exception initException) { Console.WriteLine(String.Format("{0}", initException.Message), "Error Initializing Output"); return; } Console.WriteLine("NAudio Total Time: " + (mainOutputStream as WaveChannel32).TotalTime); Console.WriteLine("Playing WMA.."); waveOutDevice.Volume = 1.0f; waveOutDevice.Play(); Console.ReadKey(); Console.WriteLine("Seeking to new time: 00:00:20.."); (mainOutputStream as WaveChannel32).CurrentTime = new TimeSpan(0, 0, 20); Console.ReadKey(); Console.WriteLine("Hit key to stop.."); waveOutDevice.Stop(); Console.WriteLine("Finished.."); mainOutputStream.Dispose(); waveOutDevice.Dispose(); Console.WriteLine("Press key to exit..."); Console.ReadKey(); }
public void Play(string filename) { if (InvokeRequired) { Invoke(new PlayDelegate(Play), filename); } else { if (_mStream != null) { _mStream.Stop(); } if (WaveOut != null) { WaveOut.Stop(); WaveOut.Dispose(); WaveOut = null; } _mStream = new FFMPEGStream(filename); _mStream.NewFrame += MStreamNewFrame; _mStream.DataAvailable += _mStream_DataAvailable; _mStream.LevelChanged += _mStream_LevelChanged; _mStream.PlayingFinished += _mStream_PlayingFinished; _mStream.RecordingFormat = null; _firstFrame = true; _filename = filename; _mStream.Start(); _mStream.Play(); string[] parts = filename.Split('\\'); string fn = parts[parts.Length - 1]; FilesFile ff = ((MainForm)Owner).GetCameraWindow(ObjectID).FileList.FirstOrDefault(p => p.Filename.EndsWith(fn)); videoPlayback1.Init(ff); videoPlayback1.CurrentState = VideoPlayback.PlaybackState.Playing; } }
/// <summary> /// Disposes of all current active file resources /// </summary> public void CloseFile() { soundOut?.Pause(); soundOut.PlaybackStopped -= PlaybackStopped; soundOut?.Dispose(); audioReader?.Dispose(); IsFilePlaying = false; IsFileClosed = true; }
static void Main(string[] args) { IWavePlayer waveOutDevice; WaveStream mainOutputStream; string fileName = @"..\..\Audio\test.ogg"; Console.WriteLine("Initiailizing NAudio"); try { waveOutDevice = new DirectSoundOut(50); } catch (Exception driverCreateException) { Console.WriteLine(String.Format("{0}", driverCreateException.Message)); return; } mainOutputStream = CreateInputStream(fileName); try { waveOutDevice.Init(mainOutputStream); } catch (Exception initException) { Console.WriteLine(String.Format("{0}", initException.Message), "Error Initializing Output"); return; } Console.WriteLine("NAudio Total Time: " + (mainOutputStream as WaveChannel32).TotalTime); Console.WriteLine("Playing Ogg Vorbis.."); waveOutDevice.Volume = 1.0f; waveOutDevice.Play(); Console.ReadKey(); Console.WriteLine("Seeking to new time: 00:01:00.."); (mainOutputStream as WaveChannel32).CurrentTime = new TimeSpan(0, 1, 0); Console.ReadKey(); waveOutDevice.Stop(); Console.WriteLine("Finished.."); mainOutputStream.Dispose(); waveOutDevice.Dispose(); Console.WriteLine("Press key to exit..."); Console.ReadKey(); }
private void OnDefaultPlaybackStopped(object sender, StoppedEventArgs args) { if (defaultDevice != null) { defaultDevice.Dispose(); defaultDevice = null; audioFileForDefault.Dispose(); audioFileForDefault = null; } UpdateStatusBarText("Ready..."); }