From 511b09b3d620747b7b160ccde8a689ed71733e96 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 14 Feb 2022 12:56:18 -0700 Subject: [PATCH] triggerbox: avoid double-accounting for buffer offset in MIDI triggers Because MIDI triggers compute buffer-relative timestamps using timeline_samples - start_sample, this already takes into account any offset to the start of the trigger. We still need to use dest_offset if a non-zero value was passed into ::midi_run(), but we do NOT want to have it contain the "offset to start of trigger in process cycle" as well. Instead of trying to special case ::maybe_compute_next_transition(), we just pass a dummy pframes_t to that method, leaving dest_offset as it was passed into ::midi_run() --- libs/ardour/triggerbox.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libs/ardour/triggerbox.cc b/libs/ardour/triggerbox.cc index bc4fb278b9..95e9d5e0a6 100644 --- a/libs/ardour/triggerbox.cc +++ b/libs/ardour/triggerbox.cc @@ -2412,7 +2412,8 @@ MIDITrigger::midi_run (BufferSet& bufs, samplepos_t start_sample, samplepos_t en samplepos_t last_event_samples = max_samplepos; /* see if we're going to start or stop or retrigger in this run() call */ - maybe_compute_next_transition (start_sample, start_beats, end_beats, nframes, dest_offset); + pframes_t ignore_computed_dest_offset = 0; + maybe_compute_next_transition (start_sample, start_beats, end_beats, nframes, ignore_computed_dest_offset); const pframes_t orig_nframes = nframes; DEBUG_TRACE (DEBUG::Triggers, string_compose ("%1 after checking for transition, state = %2\n", name(), enum_2_string (_state)));