Example #1
0
        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));
     }
 }
Example #4
0
 private void CleanupPlayback()
 {
     if (soundOut != null)
     {
         soundOut.Dispose();
         soundOut = null;
     }
     if (soundSource != null)
     {
         soundSource.Dispose();
         soundSource = null;
     }
 }
Example #5
0
        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();
            }
        }
Example #6
0
 public void Dispose()
 {
     _sound.Stop();
     _sound.Dispose();
     _source.Dispose();
     Equalizer.Dispose();
 }
Example #7
0
        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;
        }
Example #8
0
        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;
            }
        }
Example #9
0
 private void mainWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     dx11.Dispose();
     midiOutput.Dispose();
     fileReader.Dispose();
     waveOut.Dispose();
 }
Example #10
0
 public void Destroy()
 {
     CheckForCreated();
     Stop();
     _soundOut.Dispose();
     IsInitialized = false;
 }
Example #11
0
 /// <summary>
 ///
 /// </summary>
 private void CleanupPlayback()
 {
     if (_soundOut != null)
     {
         _soundOut.Dispose();
         _soundOut = null;
     }
 }
Example #12
0
 public void Dispose()
 {
     StopPlayback();
     _soundOut?.Dispose();
     _soundSource?.Dispose();
     _simpleNotificationSource?.Dispose();
     _currentMemoryStream?.Dispose();
 }
Example #13
0
 public void Dispose()
 {
     soundOut.Dispose();
     flanger.Dispose();
     rev.Dispose();
     m_AudioStream.Dispose();
     GC.Collect();
 }
Example #14
0
 public static void CleanupPlayback()
 {
     //client.Dispose();
     soundOut.Dispose();
     soundOut = null;
     waveSource.Dispose();
     waveSource = null;
 }
Example #15
0
 void StopPlayByCSCore()
 {
     if (_soundOut != null)
     {
         _soundOut.Stop();
         _soundOut.Dispose();
         _soundOut = null;
     }
 }
Example #16
0
 public void StopScore()
 {
     IsPlaying = false;
     if (SoundOut != null)
     {
         SoundOut.Stop();
         SoundOut.Dispose();
     }
 }
Example #17
0
 private void btn_Close_Click(object sender, EventArgs e)
 {
     player_on = false;
     if (soundOut != null)
     {
         soundOut.Stop();
         soundOut.Dispose();
     }
     Environment.Exit(0);
 }
Example #18
0
 private void Stop()
 {
     if (_soundOut != null)
     {
         _soundOut.Stop();
         _soundOut.Dispose();
         _equalizer.Dispose();
         _soundOut = null;
     }
 }
Example #19
0
        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();
                }
            }
        }
Example #20
0
 private void MainWindow_OnClosing(object sender, CancelEventArgs e)
 {
     if (_soundOut != null)
     {
         _soundOut.Dispose();
     }
     if (_notificationSource != null)
     {
         _notificationSource.Dispose();
     }
 }
Example #21
0
        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();
            }
        }
Example #22
0
        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);
        }
Example #23
0
 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;
     }
 }
Example #24
0
        private void UnloadAudioFile()
        {
            if (waveSource != null)
            {
                waveSource.Dispose();
            }

            if (soundOut != null)
            {
                soundOut.Dispose();
            }
        }
Example #25
0
 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.
 }
Example #26
0
 private void CleanupPlayback()
 {
     if (_soundOut != null)
     {
         _soundOut.Dispose();
         _soundOut = null;
     }
     if (_waveSource != null)
     {
         _waveSource.Dispose();
         _waveSource = null;
     }
 }
Example #27
0
        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);
        }
Example #28
0
 private void Limpiar()
 {
     if (_output != null)
     {
         _output.Dispose();
         _output = null;
     }
     if (_sound != null)
     {
         _sound.Dispose();
         _sound = null;
     }
 }
Example #29
0
 public void CleanupPlayback()
 {
     if (soundOut != null)
     {
         soundOut.Dispose();
         soundOut = null;
     }
     if (waveSource != null)
     {
         waveSource.Dispose();
         waveSource = null;
     }
 }
Example #30
0
 /// <summary>
 /// Освобождает ресурсы
 /// </summary>
 private void CleanupPlayback()
 {
     if (mSoundOut != null)
     {
         mSoundOut.Dispose();
         mSoundOut = null;
     }
     if (mWaveSource != null)
     {
         mWaveSource.Dispose();
         mWaveSource = null;
     }
 }
Example #31
0
        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();
        }