- // Now find the earliest event overall and point to it
- _type = NIL;
- Time earliest_t = std::numeric_limits<Time>::max();
-
- // Next earliest note on
- if (_note_iter != _seq->notes().end()) {
- _type = NOTE_ON;
- earliest_t = (*_note_iter)->time();
- }
-
- // Use the next note off iff it's earlier or the same time as the note on
-#ifdef PERCUSSIVE_IGNORE_NOTE_OFFS
- // issue 0005121 When in Percussive mode, all note offs go missing, which jams all MIDI instruments that they stop playing
- // remove this code since it drowns MIDI instruments by stealing all voices and crashes LinuxSampler
- if (!_seq->percussive() && (!_active_notes.empty())) {
-#else
- if ((!_active_notes.empty())) {
-#endif
- if (_type == NIL || _active_notes.top()->end_time() <= earliest_t) {
- _type = NOTE_OFF;
- earliest_t = _active_notes.top()->end_time();
- }
- }
-
- // Use the next earliest controller iff it's earlier than the note event
- if (_control_iter != _control_iters.end() && _control_iter->x != DBL_MAX) {
- if (_type == NIL || _control_iter->x < earliest_t) {
- _type = CONTROL;
- earliest_t = _control_iter->x;
- }
- }
-
- // Use the next earliest SysEx iff it's earlier than the controller
- if (_sysex_iter != _seq->sysexes().end()) {
- if (_type == NIL || (*_sysex_iter)->time() < earliest_t) {
- _type = SYSEX;
- earliest_t = (*_sysex_iter)->time();
- }
- }
-
- // Use the next earliest patch change iff it's earlier than the SysEx
- if (_patch_change_iter != _seq->patch_changes().end()) {
- if (_type == NIL || (*_patch_change_iter)->time() < earliest_t) {
- _type = PATCH_CHANGE;
- earliest_t = (*_patch_change_iter)->time();
- }
- }