From 52996e7a8df461c6b4cb9f3a6a7df2061a5e18a9 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 24 Apr 2025 16:41:49 -0600 Subject: [PATCH] fix thinko when setting MIDI trigger first/last event indices Unclear why I use this pattern when the change here uses the more normal way of finding the upper/lower of some values. Either way, the code as it was would skip the first event in a MIDI trigger (most of the time, anyway) --- libs/ardour/triggerbox.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libs/ardour/triggerbox.cc b/libs/ardour/triggerbox.cc index a1d472ca79..7657e85a27 100644 --- a/libs/ardour/triggerbox.cc +++ b/libs/ardour/triggerbox.cc @@ -2482,22 +2482,22 @@ MIDITrigger::setup_event_indices () return; } - first_event_index = 0; - last_event_index = std::numeric_limits::max(); + first_event_index = std::numeric_limits::max(); + last_event_index = 0; for (uint32_t n = 0; n < rt->size(); ++n) { - if ((first_event_index == 0) && ((*rt)[n].timestamp >= _play_start)) { + if ((first_event_index == std::numeric_limits::max()) && ((*rt)[n].timestamp >= _play_start)) { /* first one at or after the loop start */ first_event_index = n; } - if ((last_event_index == std::numeric_limits::max()) && ((*rt)[n].timestamp > _play_end)) { + if ((last_event_index == 0) && ((*rt)[n].timestamp > _play_end)) { /* first one at or after the loop end */ last_event_index = n; /* exclusive end */ } } - if (last_event_index == std::numeric_limits::max()) { + if (last_event_index == 0) { last_event_index = rt->size(); }