From fdf0c069ca93240c2e8bebac68ad8a32b6d4fede Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Wed, 26 Jan 2022 11:27:27 -0700 Subject: [PATCH] triggerbox: take start offset into account when computing ends --- libs/ardour/triggerbox.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/libs/ardour/triggerbox.cc b/libs/ardour/triggerbox.cc index aca8c99943..db09ba1cae 100644 --- a/libs/ardour/triggerbox.cc +++ b/libs/ardour/triggerbox.cc @@ -948,7 +948,8 @@ AudioTrigger::set_state (const XMLNode& node, int version) void AudioTrigger::set_start (timepos_t const & s) { - _start_offset = s.samples (); + /* XXX better minimum size needed */ + _start_offset = std::min (samplepos_t (4096), s.samples ()); } void @@ -995,7 +996,7 @@ AudioTrigger::set_expected_end_sample (Temporal::TempoMap::SharedPtr const & tma samplepos_t end_by_follow_length = tmap->sample_at (tmap->bbt_walk(transition_bbt, _follow_length)); samplepos_t end_by_beatcnt = tmap->sample_at (tmap->bbt_walk(transition_bbt, Temporal::BBT_Offset (0, round (_beatcnt), 0))); //OK? - samplepos_t end_by_data_length = transition_sample + data.length; + samplepos_t end_by_data_length = transition_sample + (data.length - _start_offset); DEBUG_TRACE (DEBUG::Triggers, string_compose ("%1 @ %2 / %3 / %4 ends: FL %5 (from %6) BC %7 DL %8\n", index(), transition_sample, transition_beats, transition_bbt, @@ -1026,7 +1027,7 @@ AudioTrigger::set_expected_end_sample (Temporal::TempoMap::SharedPtr const & tma if (internal_use_follow_length() && (end_by_follow_length < end_by_data_length)) { usable_length = tmap->sample_at (tmap->bbt_walk (Temporal::BBT_Time (), _follow_length)); } else { - usable_length = data.length; + usable_length = (data.length - _start_offset); } /* called from set_expected_end_sample() when we know the time (audio & @@ -1038,7 +1039,7 @@ AudioTrigger::set_expected_end_sample (Temporal::TempoMap::SharedPtr const & tma if (launch_style() != Repeat || (q == Temporal::BBT_Offset())) { - last_sample = _start_offset + usable_length; + last_sample = usable_length; } else {