+ (MIDI_CMD_NOTE_OFF, time, 3, buffer, false);
+ /* note that we do not care about failure from
+ push_back() ... should we warn someone ?
+ */
+ dst.push_back (noteoff);
+ _active_notes[note + 128 * channel]--;
+ DEBUG_TRACE (PBD::DEBUG::MidiTrackers, string_compose ("%1: MB-resolved note %2/%3 at %4\n",
+ this, (int) note, (int) channel, time));
+ }
+ }
+ }
+ _on = 0;
+}
+
+void
+MidiStateTracker::resolve_notes (Evoral::EventSink<framepos_t> &dst, framepos_t time)
+{
+ uint8_t buf[3];
+
+ DEBUG_TRACE (PBD::DEBUG::MidiTrackers, string_compose ("%1 EVS-resolve notes @ %2 on = %3\n", this, time, _on));
+
+ if (!_on) {
+ return;
+ }
+
+ for (int channel = 0; channel < 16; ++channel) {
+ for (int note = 0; note < 128; ++note) {
+ while (_active_notes[note + 128 * channel]) {
+ buf[0] = MIDI_CMD_NOTE_OFF|channel;
+ buf[1] = note;
+ buf[2] = 0;
+ /* note that we do not care about failure from
+ write() ... should we warn someone ?
+ */
+ dst.write (time, midi_parameter_type (buf[0]), 3, buf);
+ _active_notes[note + 128 * channel]--;
+ DEBUG_TRACE (PBD::DEBUG::MidiTrackers, string_compose ("%1: EVS-resolved note %2/%3 at %4\n",
+ this, (int) note, (int) channel, time));
+ }
+ }
+ }
+ _on = 0;
+}
+
+void
+MidiStateTracker::resolve_notes (MidiSource& src, const MidiSource::Lock& lock, Evoral::Beats time)
+{
+ DEBUG_TRACE (PBD::DEBUG::MidiTrackers, string_compose ("%1 MS-resolve notes @ %2 on = %3\n", this, time, _on));
+
+ if (!_on) {
+ return;
+ }
+
+ /* NOTE: the src must be locked */
+
+ for (int channel = 0; channel < 16; ++channel) {
+ for (int note = 0; note < 128; ++note) {
+ while (_active_notes[note + 128 * channel]) {
+ Evoral::MIDIEvent<Evoral::Beats> ev ((MIDI_CMD_NOTE_OFF|channel), time, 3, 0, true);
+ ev.set_type (MIDI_CMD_NOTE_OFF);
+ ev.set_channel (channel);
+ ev.set_note (note);
+ ev.set_velocity (0);
+ src.append_event_beats (lock, ev);
+ DEBUG_TRACE (PBD::DEBUG::MidiTrackers, string_compose ("%1: MS-resolved note %2/%3 at %4\n",
+ this, (int) note, (int) channel, time));
+ _active_notes[note + 128 * channel]--;
+ /* don't stack events up at the same time */
+ time += Evoral::Beats::tick();