diff --git a/libs/ardour/ardour/triggerbox.h b/libs/ardour/ardour/triggerbox.h index 0d64318f7b..3b527412db 100644 --- a/libs/ardour/ardour/triggerbox.h +++ b/libs/ardour/ardour/triggerbox.h @@ -167,6 +167,9 @@ class LIBARDOUR_API Trigger : public PBD::Stateful { virtual void jump_start (); virtual void jump_stop (); + uint32_t follow_count() const { return _follow_count; } + void set_follow_count (uint32_t n); + void set_ui (void*); void* ui () const { return _ui; } @@ -182,6 +185,8 @@ class LIBARDOUR_API Trigger : public PBD::Stateful { PBD::Property _use_follow; FollowAction _follow_action[2]; int _follow_action_probability; + uint32_t _follow_cnt; + uint32_t _follow_count; boost::shared_ptr _region; Temporal::BBT_Offset _quantization; PBD::Property _legato; diff --git a/libs/ardour/triggerbox.cc b/libs/ardour/triggerbox.cc index 9dea409201..3a68b4fb22 100644 --- a/libs/ardour/triggerbox.cc +++ b/libs/ardour/triggerbox.cc @@ -56,6 +56,8 @@ Trigger::Trigger (uint64_t n, TriggerBox& b) , _use_follow (Properties::use_follow, true) , _follow_action { NextTrigger, Stop } , _follow_action_probability (100) + , _follow_cnt (0) + , _follow_count (1) , _quantization (Temporal::BBT_Offset (0, 1, 0)) , _legato (Properties::legato, true) , _stretch (1.0) @@ -98,6 +100,13 @@ Trigger::unbang () DEBUG_TRACE (DEBUG::Triggers, string_compose ("un-bang on %1\n", _index)); } + +void +Trigger::set_follow_count (uint32_t n) +{ + _follow_count = n; +} + void Trigger::set_follow_action (FollowAction f, uint64_t n) { @@ -222,6 +231,7 @@ void Trigger::startup() { _state = WaitingToStart; + _follow_cnt = _follow_count; PropertyChanged (ARDOUR::Properties::running); } @@ -811,7 +821,9 @@ AudioTrigger::run (BufferSet& bufs, pframes_t nframes, pframes_t dest_offset, bo /* We reached the end */ - if ((_launch_style == Repeat) || (_box.peek_next_trigger() == this)) { /* self repeat */ + _follow_cnt--; + + if ((_follow_cnt != 0) || (_launch_style == Repeat) || (_box.peek_next_trigger() == this)) { /* self repeat */ nframes -= this_read; dest_offset += this_read; DEBUG_TRACE (DEBUG::Triggers, string_compose ("%1 reached end, but set to loop, so retrigger\n", index()));