private void SendEvent(MidiEvent midiEvent) { _playbackDataTracker.UpdateCurrentData(midiEvent); OutputDevice?.SendEvent(midiEvent); OnEventPlayed(midiEvent); }
private void FinishCurrentNotes() { foreach (var noteId in _noteOnEvents.Keys) { OutputDevice.SendEvent(new NoteOffEvent(noteId.NoteNumber, SevenBitNumber.MinValue) { Channel = noteId.Channel }); } }
public void Start() { EnsureIsNotDisposed(); if (_clock.IsRunning) { return; } _outputDevice.PrepareForEventsSending(); foreach (var noteOnEvent in _noteOnEvents.Values) { _outputDevice.SendEvent(noteOnEvent); } _noteOnEvents.Clear(); _clock.Start(); IsRunning = true; }
private void OnClockTick(object sender, TickEventArgs e) { var time = e.Time; do { var timedEvent = _eventsEnumerator.Current; if (timedEvent == null) { continue; } if (timedEvent.Time > time) { return; } var midiEvent = timedEvent.Event; if (!IsRunning) { return; } OutputDevice.SendEvent(midiEvent); var noteOnEvent = midiEvent as NoteOnEvent; if (noteOnEvent != null) { _noteOnEvents[noteOnEvent.GetNoteId()] = noteOnEvent; } var noteOffEvent = midiEvent as NoteOffEvent; if (noteOffEvent != null) { _noteOnEvents.Remove(noteOffEvent.GetNoteId()); } }while (_eventsEnumerator.MoveNext()); if (!Loop) { _clock.Stop(); OnFinished(); return; } _clock.StopInternalTimer(); _clock.Reset(); _eventsEnumerator.Reset(); _eventsEnumerator.MoveNext(); _clock.StartInternalTimer(); }
private void SendEvent(MidiEvent midiEvent) { OutputDevice?.SendEvent(midiEvent); OnEventPlayed(midiEvent); }
private void SendEvent(MidiEvent midiEvent) { OutputDevice.SendEvent(midiEvent); }