diff --git a/libs/surfaces/control_protocol/basic_ui.cc b/libs/surfaces/control_protocol/basic_ui.cc index 9426b3a7ed..e47a638be4 100644 --- a/libs/surfaces/control_protocol/basic_ui.cc +++ b/libs/surfaces/control_protocol/basic_ui.cc @@ -44,7 +44,9 @@ using namespace Temporal; PBD::Signal2 BasicUI::AccessAction; BasicUI::BasicUI (Session& s) - : session (&s) + : session (&s), + _tbank_start_route (0), + _tbank_start_row (0) { } @@ -441,6 +443,24 @@ BasicUI::trigger_cue_row (int cue_idx) session->trigger_cue_row (cue_idx); } +void +BasicUI::tbank_step_route (int step_size) +{ + _tbank_start_route += step_size; + if (_tbank_start_route < 0) { + _tbank_start_route=0; + } +} + +void +BasicUI::tbank_step_row (int step_size) +{ + _tbank_start_row += step_size; + if (_tbank_start_row < 0) { + _tbank_start_row=0; + } +} + void BasicUI::undo () { @@ -804,16 +824,49 @@ BasicUI::find_trigger (int x, int y) return tp; } +float +BasicUI::trigger_progress_at (int x) +{ + boost::shared_ptr tb = session->triggerbox_at (_tbank_start_route + x); + if (tb) { + ARDOUR::TriggerPtr trigger = tb->currently_playing (); + if (trigger) { + return trigger->position_as_fraction (); + } + } + return -1; +} + +BasicUI::TriggerDisplay +BasicUI::trigger_display_at (int x, int y) +{ + TriggerDisplay disp; + + boost::shared_ptr tb = session->triggerbox_at (_tbank_start_route + x); + if (tb) { + ARDOUR::TriggerPtr current = tb->currently_playing (); + TriggerPtr tp = tb->trigger (_tbank_start_row + y); + if (tp) { + if (!tp->region()) { + disp.state = -1; + } else if (tp == current) { + disp.state = 1; + } + } + } + return disp; +} + void BasicUI::bang_trigger_at (int x, int y) { - session->bang_trigger_at (x, y); + session->bang_trigger_at (_tbank_start_route + x, _tbank_start_row + y); } void BasicUI::unbang_trigger_at (int x, int y) { - session->unbang_trigger_at (x, y); + session->unbang_trigger_at (_tbank_start_route + x, _tbank_start_row + y); } diff --git a/libs/surfaces/control_protocol/control_protocol/basic_ui.h b/libs/surfaces/control_protocol/control_protocol/basic_ui.h index b17d568e0b..1d271c1517 100644 --- a/libs/surfaces/control_protocol/control_protocol/basic_ui.h +++ b/libs/surfaces/control_protocol/control_protocol/basic_ui.h @@ -167,6 +167,24 @@ class LIBCONTROLCP_API BasicUI { bool rewind_button_onoff() const; bool loop_button_onoff() const; + /* These functions access Triggers in the order they are displayed on the Cue page, WITH an optional bank offset + Use this for a launchpad-style NxM (route x row) matrix that maps directly to the Cue page layout. + Trigger banking is separate from 'route' banking implemented by a fader surface. + To match a fader/mute/solo to the Trigger banking, the tentative plan is: + request trigger-tracks-only to be displayed on the surface + bank the faders using the offset reported here + */ + void tbank_step_route (int step_size); + void tbank_step_row (int step_size); + float trigger_progress_at (int x); /* 0..1 or -1 for not playing; */ + struct TriggerDisplay { + int state; + TriggerDisplay () { + state = 0; /* -1=empty; 0=stopped; 1=playing */ /*potentially extend to include */ + //potentially name, color, launch style, follow action(s) etc + } + }; + TriggerDisplay trigger_display_at (int x, int y); void bang_trigger_at (int x, int y); void unbang_trigger_at (int x, int y); @@ -176,6 +194,8 @@ class LIBCONTROLCP_API BasicUI { protected: BasicUI (); ARDOUR::Session* session; + + int _tbank_start_route, _tbank_start_row; }; #endif /* __ardour_basic_ui_h__ */