+
+
+/* Device Mode functions */
+
+void
+LaunchControlXL::dm_select_prev_strip()
+{
+ access_action ("Editor/select-prev-stripable");
+}
+
+void
+LaunchControlXL::dm_select_next_strip()
+{
+ access_action ("Editor/select-next-stripable");
+}
+
+uint8_t
+LaunchControlXL::dm_check_dummy (DeviceStatus ds)
+{
+ return ds;
+}
+
+void
+LaunchControlXL::dm_fader (FaderID id) {
+
+ if (!first_selected_stripable()) {
+ return;
+ }
+
+ boost::shared_ptr<AutomationControl> ac;
+ boost::shared_ptr<Fader> fader;
+
+ IDFaderMap::iterator f = id_fader_map.find(id);
+
+ if (f != id_fader_map.end()) {
+ fader = f->second;
+ }
+
+ ac = first_selected_stripable()->gain_control();
+ if (ac && check_pick_up(fader, ac)) {
+ ac->set_value ( ac->interface_to_internal( fader->value() / 127.0), PBD::Controllable::UseGroup );
+ }
+}
+
+uint8_t
+LaunchControlXL::dm_check_pan_azi()
+{
+ if (!first_selected_stripable()) {
+ return dev_nonexistant;
+ }
+
+ uint8_t dev_status = dev_nonexistant;
+ if (first_selected_stripable()->pan_azimuth_control()) {
+ dev_status = dev_active;
+ }
+
+ return dev_status;
+}
+
+void
+LaunchControlXL::dm_pan_azi (KnobID k)
+{
+ if (!first_selected_stripable()) {
+ return;
+ }
+
+ boost::shared_ptr<AutomationControl> ac;
+ boost::shared_ptr<Knob> knob = knob_by_id (k);
+
+ ac = first_selected_stripable()->pan_azimuth_control();
+
+ if (ac && check_pick_up(knob, ac)) {
+ ac->set_value ( ac->interface_to_internal( knob->value() / 127.0), PBD::Controllable::UseGroup );
+ }
+}
+
+
+uint8_t
+LaunchControlXL::dm_check_pan_width()
+{
+ if (!first_selected_stripable()) {
+ return dev_nonexistant;
+ }
+
+ uint8_t dev_status = dev_nonexistant;
+ if (first_selected_stripable()->pan_width_control()) {
+ dev_status = dev_active;
+ }
+
+ return dev_status;
+}
+
+void
+LaunchControlXL::dm_pan_width (KnobID k)
+{
+ if (!first_selected_stripable()) {
+ return;
+ }
+
+ DEBUG_TRACE (DEBUG::LaunchControlXL, "dm_pan_width()\n");
+ boost::shared_ptr<AutomationControl> ac;
+ boost::shared_ptr<Knob> knob = knob_by_id (k);
+
+ ac = first_selected_stripable()->pan_width_control();
+
+ if (ac && check_pick_up(knob, ac)) {
+ ac->set_value ( ac->interface_to_internal( knob->value() / 127.0), PBD::Controllable::UseGroup );
+ }
+}
+
+uint8_t
+LaunchControlXL::dm_check_trim()
+{
+ if (!first_selected_stripable()) {
+ return dev_nonexistant;
+ }
+
+ uint8_t dev_status = dev_nonexistant;
+ if (first_selected_stripable()->trim_control()) {
+ dev_status = dev_active;
+ }
+
+ return dev_status;
+}
+
+void
+LaunchControlXL::dm_trim (KnobID k)
+{
+ if (!first_selected_stripable()) {
+ return;
+ }
+
+ boost::shared_ptr<AutomationControl> ac;
+ boost::shared_ptr<Knob> knob = knob_by_id (k);
+
+ ac = first_selected_stripable()->trim_control();
+
+ if (ac && check_pick_up(knob, ac)) {
+ ac->set_value ( ac->interface_to_internal( knob->value() / 127.0), PBD::Controllable::UseGroup );
+ }
+}
+
+uint8_t
+LaunchControlXL::dm_mute_enabled()
+{
+ if (!first_selected_stripable()) {
+ return dev_nonexistant;
+ }
+
+ uint8_t dev_status = dev_nonexistant;
+ if (first_selected_stripable()->mute_control()->get_value()) {
+ dev_status = dev_active;
+ } else {
+ dev_status = dev_inactive;
+ }
+
+ return dev_status;
+}
+
+void
+LaunchControlXL::dm_mute_switch()
+{
+ if (!first_selected_stripable()) {
+ return;
+ }
+
+ if (first_selected_stripable()->mute_control()) {
+ first_selected_stripable()->mute_control()->set_value(!first_selected_stripable()->mute_control()->get_value(), PBD::Controllable::NoGroup);
+ }
+}
+
+uint8_t
+LaunchControlXL::dm_solo_enabled()
+{
+ if (!first_selected_stripable() || first_selected_stripable()->is_master()) {
+ return dev_nonexistant;
+ }
+
+ uint8_t dev_status = dev_nonexistant;
+ if (first_selected_stripable()->solo_control()) {
+ if (first_selected_stripable()->solo_control()->get_value()) {
+ dev_status = dev_active;
+ } else {
+ dev_status = dev_inactive;
+ }
+ }
+
+ return dev_status;
+}
+
+void
+LaunchControlXL::dm_solo_switch()
+{
+ if (!first_selected_stripable()) {
+ return;
+ }
+
+ if (first_selected_stripable()->solo_control()) {
+ first_selected_stripable()->solo_control()->set_value(!first_selected_stripable()->solo_control()->get_value(), PBD::Controllable::NoGroup);
+ }
+}
+
+uint8_t
+LaunchControlXL::dm_recenable_enabled()
+{
+ if (!first_selected_stripable()) {
+ return dev_nonexistant;
+ }
+
+ uint8_t dev_status = dev_nonexistant;
+ if (first_selected_stripable()->rec_enable_control()) {
+ if (first_selected_stripable()->rec_enable_control()->get_value()) {
+ dev_status = dev_active;
+ } else {
+ dev_status = dev_inactive;
+ }
+ }
+
+ return dev_status;
+}
+
+void
+LaunchControlXL::dm_recenable_switch()
+{
+ if (!first_selected_stripable()) {
+ return;
+ }
+
+ if (first_selected_stripable()->rec_enable_control()) {
+ first_selected_stripable()->rec_enable_control()->set_value(!first_selected_stripable()->rec_enable_control()->get_value(), PBD::Controllable::NoGroup);
+ }
+}
+
+
+#ifdef MIXBUS
+uint8_t
+LaunchControlXL::dm_mb_eq_freq_enabled()
+{
+ if (!first_selected_stripable()) {
+ return dev_nonexistant;
+ }
+
+ uint8_t dev_status = dev_nonexistant;
+
+ if (first_selected_stripable()->eq_enable_controllable()) {
+ if (first_selected_stripable()->eq_enable_controllable()->get_value()) {
+ dev_status = dev_active;
+ } else {
+ dev_status = dev_inactive;
+ }
+ }
+
+ if (first_selected_stripable()->mixbus() || first_selected_stripable()->is_master()) {
+ dev_status = dev_nonexistant;
+ }
+
+ return dev_status;
+}
+
+
+uint8_t
+LaunchControlXL::dm_mb_eq_gain_enabled(uint8_t band)
+{
+ if (!first_selected_stripable()) {
+ return dev_nonexistant;
+ }
+
+ uint8_t dev_status = dev_nonexistant;
+
+ if (first_selected_stripable()->eq_enable_controllable()) {
+ if (first_selected_stripable()->eq_enable_controllable()->get_value()) {
+ dev_status = dev_active;
+ } else {
+ dev_status = dev_inactive;
+ }
+ }
+
+ if (first_selected_stripable()->mixbus() && band > 3) {
+ dev_status = dev_nonexistant;
+ }
+
+ return dev_status;
+}
+
+void
+LaunchControlXL::dm_mb_eq (KnobID k, bool gain, uint8_t band)
+{
+ if (!first_selected_stripable()) {
+ return;
+ }
+
+ boost::shared_ptr<AutomationControl> ac;
+ boost::shared_ptr<Knob> knob = knob_by_id (k);
+ if (gain) {
+ ac = first_selected_stripable()->eq_gain_controllable(band);
+ } else {
+ ac = first_selected_stripable()->eq_freq_controllable(band);
+ }
+
+ if (ac && check_pick_up(knob, ac)) {
+ ac->set_value ( ac->interface_to_internal( knob->value() / 127.0), PBD::Controllable::UseGroup );
+ }
+}
+
+void
+LaunchControlXL::dm_mb_eq_shape_switch (uint8_t band)
+{
+ if (!first_selected_stripable()) {
+ return;
+ }
+
+ if (first_selected_stripable()->eq_shape_controllable(band)) {
+ first_selected_stripable()->eq_shape_controllable(band)->set_value
+ (!first_selected_stripable()->eq_shape_controllable(band)->get_value(), PBD::Controllable::NoGroup );
+ }
+}
+
+
+uint8_t
+LaunchControlXL::dm_mb_eq_shape_enabled(uint8_t band)
+{
+ if (!first_selected_stripable()) {
+ return dev_nonexistant;
+ }
+
+ uint8_t dev_status = dev_nonexistant;
+
+ if (first_selected_stripable()->eq_shape_controllable(band)) {
+ if (first_selected_stripable()->eq_shape_controllable(band)->get_value()) {
+ dev_status = dev_active;
+ } else {
+ dev_status = dev_inactive;
+ }
+ }
+
+ return dev_status;
+}
+
+
+void
+LaunchControlXL::dm_mb_eq_switch()
+{
+ if (!first_selected_stripable()) {
+ return;
+ }
+
+ if (first_selected_stripable()->eq_enable_controllable()) {
+ first_selected_stripable()->eq_enable_controllable()->set_value
+ (!first_selected_stripable()->eq_enable_controllable()->get_value(), PBD::Controllable::NoGroup );
+ }
+}
+
+uint8_t
+LaunchControlXL::dm_mb_flt_enabled()
+{
+ if (!first_selected_stripable()) {
+ return dev_nonexistant;
+ }
+
+ DEBUG_TRACE (DEBUG::LaunchControlXL, "dm_mb_flt_enabled()\n");
+ uint8_t dev_status = dev_nonexistant;
+
+ if (first_selected_stripable()->filter_enable_controllable(true)) {
+ DEBUG_TRACE (DEBUG::LaunchControlXL, "dm_mb_flt_enabled() - filter exists\n");
+ if (first_selected_stripable()->filter_enable_controllable(true)->get_value()) {
+ DEBUG_TRACE (DEBUG::LaunchControlXL, "dm_mb_flt_enabled: get_value true\n");
+ dev_status = dev_active;
+ } else {
+ dev_status = dev_inactive;
+ }
+ }
+ DEBUG_TRACE (DEBUG::LaunchControlXL, string_compose("dm_mb_flt_enabled: dev_status: %1\n", (int)dev_status));
+ return dev_status;
+}
+
+
+void
+LaunchControlXL::dm_mb_flt_switch()
+{
+ if (!first_selected_stripable()) {
+ return;
+ }
+
+ if (first_selected_stripable()->filter_enable_controllable(true)) {
+ first_selected_stripable()->filter_enable_controllable(true)->set_value
+ (!first_selected_stripable()->filter_enable_controllable(true)->get_value(), PBD::Controllable::NoGroup );
+ }
+}
+
+
+
+void
+LaunchControlXL::dm_mb_flt_frq (KnobID k, bool hpf)
+{
+ if (!first_selected_stripable()) {
+ return;
+ }
+
+ boost::shared_ptr<AutomationControl> ac;
+ boost::shared_ptr<Knob> knob = knob_by_id (k);
+ if (hpf) {
+ ac = first_selected_stripable()->filter_freq_controllable(true);
+ } else {
+ ac = first_selected_stripable()->filter_freq_controllable(false);
+ }
+
+ if (ac && check_pick_up(knob, ac)) {
+ ac->set_value ( ac->interface_to_internal( knob->value() / 127.0), PBD::Controllable::UseGroup );
+ }
+}
+
+uint8_t
+LaunchControlXL::dm_mb_check_send_knob (KnobID k)
+{
+ if (!first_selected_stripable()) {
+ return dev_nonexistant;
+ }
+
+ uint8_t send = static_cast<uint8_t> (k) - 16 + 4 * send_bank_base();
+
+ uint8_t dev_status = dev_nonexistant;
+
+ if (first_selected_stripable()->send_enable_controllable(send)) {
+ dev_status = dev_inactive;
+ if (first_selected_stripable()->send_enable_controllable(send)->get_value()) {
+ dev_status = dev_active;
+ }
+ }
+
+ return dev_status;
+}
+
+uint8_t
+LaunchControlXL::dm_mb_check_send_button (uint8_t s)
+{
+ if (!first_selected_stripable()) {
+ return dev_nonexistant;
+ }
+
+
+ uint8_t send = s + 4 * send_bank_base();
+
+ uint8_t dev_status = dev_nonexistant;
+
+ if (first_selected_stripable()->send_enable_controllable(send)) {
+ dev_status = dev_inactive;
+ if (first_selected_stripable()->send_enable_controllable(send)->get_value()) {
+ dev_status = dev_active;
+ }
+ }
+
+ return dev_status;
+}
+
+
+
+void
+LaunchControlXL::dm_mb_sends (KnobID k)
+{
+ if (!first_selected_stripable()) {
+ return;
+ }
+
+ boost::shared_ptr<AutomationControl> ac;
+ boost::shared_ptr<Knob> knob = knob_by_id (k);
+
+ uint8_t send = static_cast<uint8_t> (k) - 16 + 4 * send_bank_base();
+ DEBUG_TRACE (DEBUG::LaunchControlXL, string_compose("dm_mb_send: knobid '%1'\n", k));
+ DEBUG_TRACE (DEBUG::LaunchControlXL, string_compose("dm_mb_send: send '%1'\n", (int)send));
+
+
+ if (buttons_down.find(Device) != buttons_down.end()) { // Device button hold
+ ac = first_selected_stripable()->send_pan_azi_controllable(send);
+ } else {
+ ac = first_selected_stripable()->send_level_controllable(send);
+ }
+
+ if (ac && check_pick_up(knob, ac)) {
+ ac->set_value ( ac->interface_to_internal( knob->value() / 127.0), PBD::Controllable::UseGroup );
+ }
+}
+
+uint8_t
+LaunchControlXL::dm_mb_comp_enabled()
+{
+ if (!first_selected_stripable()) {
+ return dev_nonexistant;
+ }
+
+ uint8_t dev_status = dev_nonexistant;
+ if (first_selected_stripable()->comp_enable_controllable()) {
+ if (first_selected_stripable()->comp_enable_controllable()->get_value()) {
+ dev_status = dev_active;
+ } else {
+ dev_status = dev_inactive;
+ }
+ }
+
+ return dev_status;
+}
+
+void
+LaunchControlXL::dm_mb_comp_switch()
+{
+ DEBUG_TRACE (DEBUG::LaunchControlXL, "dm_mb_comp_siwtch() \n");
+ if (!first_selected_stripable()) {
+ return;
+ }
+
+ if (first_selected_stripable()->comp_enable_controllable()) {
+ DEBUG_TRACE (DEBUG::LaunchControlXL, "comp_enable_controllable exists\n");
+ DEBUG_TRACE (DEBUG::LaunchControlXL, string_compose("comp_enable_controllable(): '%1'\n", first_selected_stripable()->comp_enable_controllable()->get_value() ));
+ first_selected_stripable()->comp_enable_controllable()->set_value
+ (!first_selected_stripable()->comp_enable_controllable()->get_value(), PBD::Controllable::NoGroup);
+ }
+
+}
+
+void
+LaunchControlXL::dm_mb_comp (KnobID k, CompParam c)
+{
+ if (!first_selected_stripable()) {
+ return;
+ }
+
+ boost::shared_ptr<AutomationControl> ac;
+ boost::shared_ptr<Knob> knob = knob_by_id (k);
+
+ switch (c) {
+ case (CompMakeup):
+ ac = first_selected_stripable()->comp_makeup_controllable();
+ break;
+ case (CompMode):
+ ac = first_selected_stripable()->comp_mode_controllable();
+ break;
+ case (CompSpeed):
+ ac = first_selected_stripable()->comp_speed_controllable();
+ break;
+ }
+
+ if (ac && check_pick_up(knob, ac)) {
+ ac->set_value ( ac->interface_to_internal( knob->value() / 127.0), PBD::Controllable::UseGroup );
+ }
+}
+
+void
+LaunchControlXL::dm_mb_comp_thresh (FaderID id) {
+
+ if (!first_selected_stripable()) {
+ return;
+ }
+
+ boost::shared_ptr<AutomationControl> ac;
+ boost::shared_ptr<Fader> fader;
+
+ IDFaderMap::iterator f = id_fader_map.find(id);
+
+ if (f != id_fader_map.end()) {
+ fader = f->second;
+ }
+
+ ac = first_selected_stripable()->comp_threshold_controllable();
+ if (ac && check_pick_up(fader, ac)) {
+ ac->set_value ( ac->interface_to_internal( fader->value() / 127.0), PBD::Controllable::UseGroup );
+ }
+}
+
+uint8_t
+LaunchControlXL::dm_mb_has_tapedrive()
+{
+ if (!first_selected_stripable()) {
+ return dev_nonexistant;
+ }
+
+ uint8_t dev_status = dev_nonexistant;
+
+ if (first_selected_stripable()->mixbus() || first_selected_stripable()->is_master()) {
+ dev_status = dev_active;
+ }
+
+ return dev_status;
+}
+
+void
+LaunchControlXL::dm_mb_tapedrive (KnobID k)
+{
+ if (!first_selected_stripable()) {
+ return;
+ }
+
+ boost::shared_ptr<AutomationControl> ac;
+ boost::shared_ptr<Knob> knob = knob_by_id (k);
+
+ ac = first_selected_stripable()->tape_drive_controllable();
+
+ if (ac && check_pick_up(knob, ac)) {
+ ac->set_value ( ac->interface_to_internal( knob->value() / 127.0), PBD::Controllable::UseGroup );
+ }
+}
+
+uint8_t
+LaunchControlXL::dm_mb_master_assign_enabled()
+{
+ if (!first_selected_stripable()) {
+ return dev_nonexistant;
+ }
+
+ uint8_t dev_status = dev_nonexistant;
+
+ if (first_selected_stripable()->master_send_enable_controllable()) {
+ if (first_selected_stripable()->master_send_enable_controllable()->get_value()) {
+ dev_status = dev_active;
+ } else {
+ dev_status = dev_inactive;
+ }
+ }
+
+ return dev_status;
+}
+
+void
+LaunchControlXL::dm_mb_master_assign_switch()
+{
+ if (!first_selected_stripable()) {
+ return;
+ }
+
+ if (first_selected_stripable()->master_send_enable_controllable()) {
+ first_selected_stripable()->master_send_enable_controllable()->set_value
+ (!first_selected_stripable()->master_send_enable_controllable()->get_value(), PBD::Controllable::NoGroup );
+ }
+}
+
+void
+LaunchControlXL::dm_mb_send_switch(ButtonID id)
+{
+ if (!first_selected_stripable()) {
+ return;
+ }
+
+ boost::shared_ptr<Button> button = id_note_button_map[id];;
+
+ uint8_t send = static_cast<uint8_t> (id) + 4 * send_bank_base();
+ DEBUG_TRACE (DEBUG::LaunchControlXL, string_compose("dm_mb_send: buttonid '%1'\n", (int)id));
+ DEBUG_TRACE (DEBUG::LaunchControlXL, string_compose("dm_mb_send: send '%1'\n", (int)send));
+
+ if (first_selected_stripable()->send_enable_controllable(send)) {
+ DEBUG_TRACE (DEBUG::LaunchControlXL, string_compose("dm_mb_send: send '%1' exists\n", (int)send));
+ first_selected_stripable()->send_enable_controllable(send)->set_value
+ (!first_selected_stripable()->send_enable_controllable(send)->get_value(), PBD::Controllable::UseGroup);
+ }
+}
+
+#endif