From 4ee02182fe5633a8658dd84f81ccbdff799a8169 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Wed, 11 Aug 2021 22:54:13 -0600 Subject: [PATCH] triggerbox: 2 possible follow actions --- libs/ardour/ardour/triggerbox.h | 6 +++--- libs/ardour/triggerbox.cc | 20 +++++++++++++------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/libs/ardour/ardour/triggerbox.h b/libs/ardour/ardour/triggerbox.h index d40acd2064..9fae2b22bb 100644 --- a/libs/ardour/ardour/triggerbox.h +++ b/libs/ardour/ardour/triggerbox.h @@ -103,8 +103,8 @@ class LIBARDOUR_API Trigger : public PBD::Stateful { OtherTrigger, }; - FollowAction follow_action() const { return _follow_action; } - void set_follow_action (FollowAction); + FollowAction follow_action (size_t n) const { assert (n < 2); return _follow_action[n]; } + void set_follow_action (FollowAction, size_t n); virtual int set_region (boost::shared_ptr) = 0; boost::shared_ptr region() const { return _region; } @@ -154,7 +154,7 @@ class LIBARDOUR_API Trigger : public PBD::Stateful { size_t _index; int _next_trigger; LaunchStyle _launch_style; - FollowAction _follow_action; + FollowAction _follow_action[2]; boost::shared_ptr _region; Temporal::BBT_Offset _quantization; diff --git a/libs/ardour/triggerbox.cc b/libs/ardour/triggerbox.cc index 56e07eb7b9..952227e172 100644 --- a/libs/ardour/triggerbox.cc +++ b/libs/ardour/triggerbox.cc @@ -42,7 +42,7 @@ Trigger::Trigger (size_t n, TriggerBox& b) , _index (n) , _next_trigger (-1) , _launch_style (Toggle) - , _follow_action (NextTrigger) + , _follow_action { { NextTrigger }, { Stop } } , _quantization (Temporal::BBT_Offset (0, 1, 0)) { } @@ -60,9 +60,10 @@ Trigger::unbang () } void -Trigger::set_follow_action (FollowAction f) +Trigger::set_follow_action (FollowAction f, size_t n) { - _follow_action = f; + assert (n < 2); + _follow_action[n] = f; } void @@ -558,7 +559,7 @@ AudioTrigger::run (BufferSet& bufs, pframes_t nframes, pframes_t dest_offset, bo /* We reached the end */ - if (_follow_action == Again) { + if (_follow_action[0] == Again) { nframes -= this_read; dest_offset += this_read; DEBUG_TRACE (DEBUG::Triggers, string_compose ("%1 was reached end, but set to loop, so retrigger\n", index())); @@ -916,7 +917,7 @@ TriggerBox::run (BufferSet& bufs, samplepos_t start_sample, samplepos_t end_samp if (trigger.state() == Trigger::Stopped) { - if (trigger.follow_action() != Trigger::Stop) { + if (trigger.follow_action(0) != Trigger::Stop) { int nxt = trigger.next_trigger(); @@ -949,7 +950,7 @@ TriggerBox::set_next_trigger (size_t current) } } - switch (all_triggers[current]->follow_action()) { + switch (all_triggers[current]->follow_action(0)) { case Trigger::Stop: return; case Trigger::QueuedTrigger: @@ -962,7 +963,12 @@ TriggerBox::set_next_trigger (size_t current) } } - switch (all_triggers[current]->follow_action()) { + switch (all_triggers[current]->follow_action(0)) { + + case Trigger::Again: + all_triggers[current]->set_next_trigger (current); + return; + case Trigger::NextTrigger: n = current; while (true) {