From 590400a95f25c7a953b426834f8e61ce250e9d23 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 21 Oct 2024 10:45:47 -0600 Subject: [PATCH] trigger arming must be mutually exclusive within a triggerbox --- libs/ardour/ardour/triggerbox.h | 1 + libs/ardour/triggerbox.cc | 26 ++++++++++++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/libs/ardour/ardour/triggerbox.h b/libs/ardour/ardour/triggerbox.h index ee01cce0db..a2fc984d04 100644 --- a/libs/ardour/ardour/triggerbox.h +++ b/libs/ardour/ardour/triggerbox.h @@ -814,6 +814,7 @@ class LIBARDOUR_API TriggerBox : public Processor, public std::enable_shared_fro void arm_from_another_thread (Trigger& slot, samplepos_t, uint32_t chans); void disarm(); + void disarm_all(); bool armed() const { return (bool) _arm_info.load(); } PBD::Signal ArmedChanged; diff --git a/libs/ardour/triggerbox.cc b/libs/ardour/triggerbox.cc index 09adf400c6..90be239bec 100644 --- a/libs/ardour/triggerbox.cc +++ b/libs/ardour/triggerbox.cc @@ -290,8 +290,20 @@ Trigger::request_trigger_delete (Trigger* t) void Trigger::arm () { -#warning paul need channel count here, somehow - _box.arm_from_another_thread (*this, _box.session().transport_sample(), 2); + /* trigger arming is mutually exclusive within a given TriggerBox */ + + _box.disarm_all (); + + Track* trk = static_cast (_box.owner()); + int chns; + + if (trk->data_type() == DataType::AUDIO) { + chns = dynamic_cast (trk)->input()->n_ports().n_audio(); + } else { + chns = 0; + } + + _box.arm_from_another_thread (*this, _box.session().transport_sample(), chns); _armed = true; ArmChanged(); /* EMIT SIGNAL */ TriggerArmChanged (this); @@ -3569,6 +3581,16 @@ TriggerBox::arm_from_another_thread (Trigger& slot, samplepos_t now, uint32_t ch void TriggerBox::disarm () { + delete _arm_info; + _arm_info = nullptr; +} + +void +TriggerBox::disarm_all () +{ + for (auto & t : all_triggers) { + t->disarm (); + } } void