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); }
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); // seems good quality at 200 ms latency if (dsd != null) { dso.Device = dsd.Guid; } if (aout != null) // clean up last { aout.Stopped -= Output_Stopped; aout.Stop(); aout.Dispose(); } aout = dso; aout.Stopped += Output_Stopped; return(true); }
private void OnSoundOutStopped(object sender, PlaybackStoppedEventArgs playbackStoppedEventArgs) { if (IsLooped) { _soundOut.Dispose(); Play(); } else { OnSoundStateChanged(new SoundStateChangedEventArgs(SoundState.Stopped)); } }
private void CleanupPlayback() { if (soundOut != null) { soundOut.Dispose(); soundOut = null; } if (soundSource != null) { soundSource.Dispose(); soundSource = null; } }
private void GameBoy_StopRequested() { if ((_soundOut != null) && (_soundOut.PlaybackState == PlaybackState.Playing)) { // The soundout will be reloaded after the first frame // of gameplay passes _soundOut.Stop(); _soundOut.Dispose(); _soundOut = null; // We Reload it ReloadAPU(); } }
public void Dispose() { _sound.Stop(); _sound.Dispose(); _source.Dispose(); Equalizer.Dispose(); }
private void Dispose(bool isDisposing) { if (_isDisposed) { return; } if (isDisposing) { StopHandler(); if (_updateTimer != null) { _updateTimer.Stop(); _updateTimer = null; } if (_soundTouchSource != null) { _soundTouchSource.Dispose(); _soundTouchSource = null; } if (_soundOut != null) { _soundOut.Dispose(); _soundOut = null; } } _isDisposed = true; }
private void StopCSCore() { if (_soundOut != null) { _soundOut.Stop(); _soundOut.Dispose(); _soundOut = null; } if (_soundIn != null) { _soundIn.Stop(); _soundIn.Dispose(); _soundIn = null; } if (_source != null) { _source.Dispose(); _source = null; } if (_lineSpectrum != null) { _lineSpectrum = null; } }
private void mainWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e) { dx11.Dispose(); midiOutput.Dispose(); fileReader.Dispose(); waveOut.Dispose(); }
public void Destroy() { CheckForCreated(); Stop(); _soundOut.Dispose(); IsInitialized = false; }
/// <summary> /// /// </summary> private void CleanupPlayback() { if (_soundOut != null) { _soundOut.Dispose(); _soundOut = null; } }
public void Dispose() { StopPlayback(); _soundOut?.Dispose(); _soundSource?.Dispose(); _simpleNotificationSource?.Dispose(); _currentMemoryStream?.Dispose(); }
public void Dispose() { soundOut.Dispose(); flanger.Dispose(); rev.Dispose(); m_AudioStream.Dispose(); GC.Collect(); }
public static void CleanupPlayback() { //client.Dispose(); soundOut.Dispose(); soundOut = null; waveSource.Dispose(); waveSource = null; }
void StopPlayByCSCore() { if (_soundOut != null) { _soundOut.Stop(); _soundOut.Dispose(); _soundOut = null; } }
public void StopScore() { IsPlaying = false; if (SoundOut != null) { SoundOut.Stop(); SoundOut.Dispose(); } }
private void btn_Close_Click(object sender, EventArgs e) { player_on = false; if (soundOut != null) { soundOut.Stop(); soundOut.Dispose(); } Environment.Exit(0); }
private void Stop() { if (_soundOut != null) { _soundOut.Stop(); _soundOut.Dispose(); _equalizer.Dispose(); _soundOut = null; } }
public async void UpdateSoundOut() { long position = Position; bool isplaying = IsPlaying; if (_soundOut != null) { StopPlayback(); _soundOut.Dispose(); } RefreshSoundOut(); if (CurrentTrack != null) { await OpenTrack(CurrentTrack); Position = position; if (isplaying) { TogglePlayPause(); } } }
private void MainWindow_OnClosing(object sender, CancelEventArgs e) { if (_soundOut != null) { _soundOut.Dispose(); } if (_notificationSource != null) { _notificationSource.Dispose(); } }
protected virtual void Dispose(bool disposing) { if (disposing) { _fader.Dispose(); SoundOutManager.Dispose(); if (_soundOut != null) { if (_fader.IsFading) { _fader.CancelFading(); _fader.WaitForCancel(); } _soundOut.Dispose(); _crossfade.CancelFading(); } SoundSource?.Dispose(); } }
public bool SetAudioEndpoint(string dev, bool usedefault = false) { #if true 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(100, System.Threading.ThreadPriority.Highest); // seems good quality at 200 ms latency if (dsd != null) { dso.Device = dsd.Guid; } #else MMDevice def = MMDeviceEnumerator.DefaultAudioEndpoint(DataFlow.Render, Role.Console); ISoundOut dso = new WasapiOut() { Latency = 100, Device = def }; //BAD breakup #endif if (aout != null) // clean up last { aout.Stopped -= Output_Stopped; aout.Stop(); aout.Dispose(); } aout = dso; aout.Stopped += Output_Stopped; return(true); }
private void SoundOut_Stopped(object sender, PlaybackStoppedEventArgs e) { CurrentStateChanged(); if (e.HasError) { ErrorOccurred?.Invoke(this, new ErrorOccurredEventArgs(e.Exception.Message)); _fadingService.Cancel(); StopAndReset(); _soundOut.Dispose(); _soundOut = null; } }
private void UnloadAudioFile() { if (waveSource != null) { waveSource.Dispose(); } if (soundOut != null) { soundOut.Dispose(); } }
protected virtual void Dispose(bool disposing) { if (disposing) { // free managed resources if (_fadingService.IsFading) { _fadingService.Cancel(); } StopPlayback(); _soundOut?.Dispose(); _soundOut = null; _soundSource?.Dispose(); SoundOutProvider.Dispose(); _loopStream?.Dispose(); _equalizer?.Dispose(); _simpleNotificationSource?.Dispose(); _soundSourceLoadingToken?.Dispose(); } // free native resources if there are any. }
private void CleanupPlayback() { if (_soundOut != null) { _soundOut.Dispose(); _soundOut = null; } if (_waveSource != null) { _waveSource.Dispose(); _waveSource = null; } }
public void Close() { if (!_isControllerMode) { switch (state) { case States.Closed: return; case States.Closing: return; case States.Stopped: break; default: state = States.Stopping; return; } } else { _soundOut.Dispose(); } Trace.TraceInformation("Alarm System closing"); state = States.Closing; _overlayWorking = false; _timerAlarmDelay.Stop(); _timerOverlayShow.Stop(); _timerOverlayUpdate.Stop(); _timerZeroVolumeDelay.Stop(); if (_alertOverlay != null) { _alertOverlay.Disable(); _alertOverlay.Dispose(); } state = States.Closed; OnClosed(this); }
private void Limpiar() { if (_output != null) { _output.Dispose(); _output = null; } if (_sound != null) { _sound.Dispose(); _sound = null; } }
public void CleanupPlayback() { if (soundOut != null) { soundOut.Dispose(); soundOut = null; } if (waveSource != null) { waveSource.Dispose(); waveSource = null; } }
/// <summary> /// Освобождает ресурсы /// </summary> private void CleanupPlayback() { if (mSoundOut != null) { mSoundOut.Dispose(); mSoundOut = null; } if (mWaveSource != null) { mWaveSource.Dispose(); mWaveSource = null; } }
public async void FadeOut(double seconds, ISoundOut soundOut) { IsCrossfading = true; var steps = seconds / 0.2; var soundstep = soundOut.Volume / (float)steps; for (int i = 0; i < steps; i++) { if (_cancel) { _cancel = false; break; } await Task.Delay(200); try { var value = soundOut.Volume - soundstep; if (0 > value) break; soundOut.Volume -= soundstep; } catch (ObjectDisposedException) { IsCrossfading = false; break; } } IsCrossfading = false; if (soundOut.PlaybackState != PlaybackState.Stopped) soundOut.Stop(); soundOut.WaveSource.Dispose(); soundOut.Dispose(); }