From 2829f4385ff38413c9944549781c1aa0b34a83ab Mon Sep 17 00:00:00 2001 From: Ben Loftis Date: Sat, 1 Oct 2022 07:38:58 -0500 Subject: [PATCH] triggerbox: publish some trigger functions to ::session (for the convenience of control surfaces) Grid controllers will largely want to access clips in the order they appear on the Cue page It is up to the device (and/or its ControlProtocol) to handle banking --- libs/ardour/ardour/session.h | 3 ++ libs/ardour/session_process.cc | 53 ++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index 238445c17b..1c5d340ba1 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -1374,6 +1374,9 @@ public: void trigger_cue_row (int32_t); CueEvents const & cue_events() const { return _cue_events; } + bool bang_trigger_at(int32_t route_index, int32_t row_index); + bool unbang_trigger_at(int32_t route_index, int32_t row_index); + protected: friend class AudioEngine; void set_block_size (pframes_t nframes); diff --git a/libs/ardour/session_process.cc b/libs/ardour/session_process.cc index f32a9bb81f..b15283aaa6 100644 --- a/libs/ardour/session_process.cc +++ b/libs/ardour/session_process.cc @@ -1727,6 +1727,59 @@ Session::trigger_cue_row (int32_t cue) request_transport_speed (1.0); } + +bool +Session::bang_trigger_at (int32_t route_index, int32_t row_index) +{ + /* this is a convenience function for simple control surfaces to bang a trigger without any regards to banking */ + + 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) { + r->triggerbox()->bang_trigger_at(row_index); + return 1; + } + index++; + } +} + +bool +Session::unbang_trigger_at (int32_t route_index, int32_t row_index) +{ + /* this is a convenience function for simple control surfaces to un-bang a trigger without any regards to banking */ + + 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) { + r->triggerbox()->unbang_trigger_at(row_index); + return 1; + } + index++; + } +} + void Session::maybe_find_pending_cue () {