From 756e0beb1ba9d677e5bebc4dcb27bc1ecd025b45 Mon Sep 17 00:00:00 2001 From: Ben Loftis Date: Tue, 4 Oct 2022 12:04:33 -0500 Subject: [PATCH] triggers: more session:: functions to access Triggers by index --- libs/ardour/ardour/session.h | 2 ++ libs/ardour/session_process.cc | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index 3caae966f0..41381e7494 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -1375,6 +1375,8 @@ public: void trigger_cue_row (int32_t); CueEvents const & cue_events() const { return _cue_events; } + boost::shared_ptr triggerbox_at (int32_t route_index) const; + TriggerPtr trigger_at (int32_t route_index, int32_t row_index) const; bool bang_trigger_at(int32_t route_index, int32_t row_index); bool unbang_trigger_at(int32_t route_index, int32_t row_index); diff --git a/libs/ardour/session_process.cc b/libs/ardour/session_process.cc index 9974cd3312..1ab2776b73 100644 --- a/libs/ardour/session_process.cc +++ b/libs/ardour/session_process.cc @@ -1782,6 +1782,40 @@ Session::unbang_trigger_at (int32_t route_index, int32_t row_index) return false; } +boost::shared_ptr +Session::triggerbox_at (int32_t route_index) const +{ + int index = 0; + StripableList sl; + get_stripables (sl); + sl.sort (Stripable::Sorter ()); + for (StripableList::iterator s = sl.begin (); s != sl.end (); ++s) { + boost::shared_ptr r = boost::dynamic_pointer_cast (*s); + if (!r || !r->triggerbox ()) { + continue; + } + /* we're only interested in Trigger Tracks */ + if (!(r->presentation_info ().trigger_track ())) { + continue; + } + if (index == route_index) { + return r->triggerbox(); + } + index++; + } + return boost::shared_ptr(); +} + +TriggerPtr +Session::trigger_at (int32_t route_index, int32_t trigger_index) const +{ + boost::shared_ptr tb = triggerbox_at(route_index); + if (tb) { + return tb->trigger(trigger_index); + } + return TriggerPtr(); +} + void Session::maybe_find_pending_cue () {