示例#1
0
        /// <summary>
        /// Stops playing of the MIDI data. Note that this method doesn't reset playback position. If you
        /// call <see cref="Start"/>, playing will be resumed from the point where <see cref="Stop"/> was called.
        /// </summary>
        /// <exception cref="ObjectDisposedException">The current <see cref="Playback"/> is disposed.</exception>
        /// <exception cref="MidiDeviceException">An error occurred on device.</exception>
        public void Stop()
        {
            EnsureIsNotDisposed();

            if (!IsRunning)
            {
                return;
            }

            _clock.Stop();

            if (InterruptNotesOnStop)
            {
                var currentTime = _clock.CurrentTime;

                var notes = new List <Note>();

                foreach (var noteMetadata in _activeNotesMetadata.ToArray())
                {
                    Note note;
                    if (TryPlayNoteEvent(noteMetadata, false, currentTime, out note))
                    {
                        notes.Add(note);
                    }
                }

                OnNotesPlaybackFinished(notes.ToArray());

                _activeNotesMetadata.Clear();
            }

            OnStopped();
        }
示例#2
0
        /// <summary>
        /// Stops playing of the MIDI data. Note that this method doesn't reset playback position. If you
        /// call <see cref="Start"/>, playing will be resumed from the point where <see cref="Stop"/> was called.
        /// </summary>
        /// <exception cref="ObjectDisposedException">The current <see cref="Playback"/> is disposed.</exception>
        /// <exception cref="MidiDeviceException">An error occurred on device.</exception>
        public void Stop()
        {
            EnsureIsNotDisposed();

            if (!IsRunning)
            {
                return;
            }

            _clock.Stop();

            if (InterruptNotesOnStop)
            {
                foreach (var note in _activeNotes)
                {
                    SendEvent(new NoteOffEvent(note.Key.NoteNumber, note.Value.OffVelocity)
                    {
                        Channel = note.Key.Channel
                    });
                }

                _activeNotes.Clear();
            }

            OnStopped();
        }
示例#3
0
        /// <summary>
        /// Stops playing of the MIDI data. Note that this method doesn't reset playback position. If you
        /// call <see cref="Start"/>, playing will be resumed from the point where <see cref="Stop"/> was called.
        /// </summary>
        /// <exception cref="ObjectDisposedException">The current <see cref="Playback"/> is disposed.</exception>
        /// <exception cref="MidiDeviceException">An error occurred on device.</exception>
        public void Stop()
        {
            EnsureIsNotDisposed();

            if (!IsRunning)
            {
                return;
            }

            _clock.Stop();
            StopNotes();

            OnStopped();
        }
示例#4
0
        public void Stop()
        {
            EnsureIsNotDisposed();

            if (!_clock.IsRunning)
            {
                return;
            }

            _clock.Stop();
            StopNotes();
            IsRunning = false;
        }
        /// <summary>
        /// Stops current times watching.
        /// </summary>
        /// <exception cref="ObjectDisposedException">The current <see cref="PlaybackCurrentTimeWatcher"/>
        /// is disposed.</exception>
        public void Stop()
        {
            EnsureIsNotDisposed();

            _clock.Stop();
        }