From ee09ae1c6bd285388159a3a69f12fc53faf247e2 Mon Sep 17 00:00:00 2001 From: Ben Loftis Date: Tue, 17 Oct 2017 13:27:08 -0500 Subject: [PATCH] US2400: allow selecting the master bus. LED does not respond, though :( --- libs/surfaces/us2400/button.cc | 2 ++ libs/surfaces/us2400/button.h | 1 + libs/surfaces/us2400/device_info.cc | 2 ++ libs/surfaces/us2400/led.h | 2 +- libs/surfaces/us2400/mcp_buttons.cc | 15 ++++++++++++ libs/surfaces/us2400/strip.cc | 2 +- libs/surfaces/us2400/surface.cc | 1 + .../us2400/us2400_control_protocol.cc | 23 ++++++++++++++++--- .../surfaces/us2400/us2400_control_protocol.h | 3 ++- 9 files changed, 45 insertions(+), 6 deletions(-) diff --git a/libs/surfaces/us2400/button.cc b/libs/surfaces/us2400/button.cc index 9f9448688e..5e577a6c0b 100644 --- a/libs/surfaces/us2400/button.cc +++ b/libs/surfaces/us2400/button.cc @@ -77,6 +77,7 @@ Button::name_to_id (const std::string& name) if (!g_ascii_strcasecmp (name.c_str(), "Bank Left")) { return Left; } if (!g_ascii_strcasecmp (name.c_str(), "Bank Right")) { return Right; } if (!g_ascii_strcasecmp (name.c_str(), "Flip")) { return Flip; } + if (!g_ascii_strcasecmp (name.c_str(), "Mstr Select")) { return MstrSelect; } if (!g_ascii_strcasecmp (name.c_str(), "F1")) { return F1; } if (!g_ascii_strcasecmp (name.c_str(), "F2")) { return F2; } if (!g_ascii_strcasecmp (name.c_str(), "F3")) { return F3; } @@ -115,6 +116,7 @@ Button::id_to_name (Button::ID id) if (id == Left) { return "Bank Left"; } if (id == Right) { return "Bank Right"; } if (id == Flip) { return "Flip"; } + if (id == MstrSelect) { return "Mstr Select"; } if (id == F1) { return "F1"; } if (id == F2) { return "F2"; } if (id == F3) { return "F3"; } diff --git a/libs/surfaces/us2400/button.h b/libs/surfaces/us2400/button.h index 4f5a306844..182e88fefc 100644 --- a/libs/surfaces/us2400/button.h +++ b/libs/surfaces/us2400/button.h @@ -57,6 +57,7 @@ public: Left, Right, Flip, + MstrSelect, FinalGlobalButton, diff --git a/libs/surfaces/us2400/device_info.cc b/libs/surfaces/us2400/device_info.cc index 784c114e55..946355226a 100644 --- a/libs/surfaces/us2400/device_info.cc +++ b/libs/surfaces/us2400/device_info.cc @@ -121,6 +121,8 @@ DeviceInfo::shared_buttons () _global_buttons[Button::Flip] = GlobalButtonInfo ("Flip", "assignment", 0x32); + _global_buttons[Button::MstrSelect] = GlobalButtonInfo ("Mstr Select", "assignment", 0x48); + _global_buttons[Button::F1] = GlobalButtonInfo ("F1", "function select", 0x36); _global_buttons[Button::F2] = GlobalButtonInfo ("F2", "function select", 0x37); _global_buttons[Button::F3] = GlobalButtonInfo ("F3", "function select", 0x38); diff --git a/libs/surfaces/us2400/led.h b/libs/surfaces/us2400/led.h index 99514b12ac..4ef4660d55 100644 --- a/libs/surfaces/us2400/led.h +++ b/libs/surfaces/us2400/led.h @@ -43,7 +43,7 @@ public: : Control (id, name, group) , state (off) , last_state (off) - , llast_state (off) + , llast_state (on) { } diff --git a/libs/surfaces/us2400/mcp_buttons.cc b/libs/surfaces/us2400/mcp_buttons.cc index 69a13cdd85..b88d88b312 100644 --- a/libs/surfaces/us2400/mcp_buttons.cc +++ b/libs/surfaces/us2400/mcp_buttons.cc @@ -769,6 +769,21 @@ US2400Protocol::flip_release (Button &) { return none; } + +LedState +US2400Protocol::mstr_press (Button &) +{ +// access_action("Mixer/select-none"); + SetStripableSelection( session->master_out() ); + return on; +} + +LedState +US2400Protocol::mstr_release (Button &) +{ + return none; +} + LedState US2400Protocol::name_value_press (Button &) { diff --git a/libs/surfaces/us2400/strip.cc b/libs/surfaces/us2400/strip.cc index 1a88d39855..185f49ca52 100644 --- a/libs/surfaces/us2400/strip.cc +++ b/libs/surfaces/us2400/strip.cc @@ -821,7 +821,7 @@ Strip::setup_trackview_vpot (boost::shared_ptr r) //EQ int eq_band = -1; - if (r->mixbus ()) { + if (r->mixbus () || r->is_master()) { switch (global_pos) { diff --git a/libs/surfaces/us2400/surface.cc b/libs/surfaces/us2400/surface.cc index 0a2594a245..08f40e4600 100644 --- a/libs/surfaces/us2400/surface.cc +++ b/libs/surfaces/us2400/surface.cc @@ -414,6 +414,7 @@ Surface::setup_master () _master_fader->set_control (m->gain_control()); m->gain_control()->Changed.connect (master_connection, MISSING_INVALIDATOR, boost::bind (&Surface::master_gain_changed, this), ui_context()); _last_master_gain_written = FLT_MAX; /* some essentially impossible value */ + _port->write (_master_fader->set_position (0.0)); master_gain_changed (); } diff --git a/libs/surfaces/us2400/us2400_control_protocol.cc b/libs/surfaces/us2400/us2400_control_protocol.cc index ea891bdb34..4a1ba6231e 100644 --- a/libs/surfaces/us2400/us2400_control_protocol.cc +++ b/libs/surfaces/us2400/us2400_control_protocol.cc @@ -117,7 +117,6 @@ US2400Protocol::US2400Protocol (Session& session) , _scrub_mode (false) , _view_mode (Mixer) , _subview_mode (None) - , _current_selected_track (-1) , _modifier_state (0) , _metering_active (true) , _initialized (false) @@ -343,7 +342,6 @@ US2400Protocol::switch_banks (uint32_t initial, bool force) } _current_initial_bank = initial; - _current_selected_track = -1; // Map current bank of stripables onto each surface(+strip) @@ -559,6 +557,9 @@ US2400Protocol::device_ready () update_global_button (Button::Flip, on); update_global_button (Button::Flip, off); + update_global_button (Button::MstrSelect, on); + update_global_button (Button::MstrSelect, off); + set_subview_mode (US2400Protocol::None, first_selected_stripable()); } @@ -1186,6 +1187,7 @@ US2400Protocol::build_button_map () DEFINE_BUTTON_HANDLER (Button::Left, &US2400Protocol::left_press, &US2400Protocol::left_release); DEFINE_BUTTON_HANDLER (Button::Right, &US2400Protocol::right_press, &US2400Protocol::right_release); DEFINE_BUTTON_HANDLER (Button::Flip, &US2400Protocol::flip_press, &US2400Protocol::flip_release); + DEFINE_BUTTON_HANDLER (Button::MstrSelect, &US2400Protocol::mstr_press, &US2400Protocol::mstr_release); // DEFINE_BUTTON_HANDLER (Button::F1, &US2400Protocol::F1_press, &US2400Protocol::F1_release); // DEFINE_BUTTON_HANDLER (Button::F2, &US2400Protocol::F2_press, &US2400Protocol::F2_release); // DEFINE_BUTTON_HANDLER (Button::F3, &US2400Protocol::F3_press, &US2400Protocol::F3_release); @@ -1851,7 +1853,21 @@ US2400Protocol::stripable_selection_changed () (*si)->update_strip_selection (); } - boost::shared_ptr s = first_selected_stripable (); +printf("stripable_selection_changed\n"); + + //first check for the dedicated Master strip + boost::shared_ptr s = ControlProtocol::first_selected_stripable(); + if (s && s->is_master()) { +printf("stripable_selection_changed found master as selected_stripable\n"); + update_global_button(Button::MstrSelect, on); //NOTE: surface does not respond to this + } else { +if (s) printf("stripable_selection_changed not master: %s\n", s->name().c_str()); + update_global_button(Button::MstrSelect, off); + + //not the master; now check for other strips ( this will only allow a selection if the strip is mapped on our surface ) + s = first_selected_stripable (); + } + if (s) { check_fader_automation_state (); @@ -1863,6 +1879,7 @@ US2400Protocol::stripable_selection_changed () */ if (set_subview_mode (TrackView, s)) { +printf("set_subview_mode failed for master... (?)\n"); set_subview_mode (None, boost::shared_ptr()); } diff --git a/libs/surfaces/us2400/us2400_control_protocol.h b/libs/surfaces/us2400/us2400_control_protocol.h index 861ada9e16..415b42ad08 100644 --- a/libs/surfaces/us2400/us2400_control_protocol.h +++ b/libs/surfaces/us2400/us2400_control_protocol.h @@ -293,7 +293,6 @@ class US2400Protocol ViewMode _view_mode; SubViewMode _subview_mode; boost::shared_ptr _subview_stripable; - int _current_selected_track; int _modifier_state; ButtonMap button_map; bool _metering_active; @@ -396,6 +395,8 @@ class US2400Protocol US2400::LedState dyn_release (US2400::Button &); US2400::LedState flip_press (US2400::Button &); US2400::LedState flip_release (US2400::Button &); + US2400::LedState mstr_press (US2400::Button &); + US2400::LedState mstr_release (US2400::Button &); US2400::LedState name_value_press (US2400::Button &); US2400::LedState name_value_release (US2400::Button &); // US2400::LedState F1_press (US2400::Button &);