LCXL: Add some Mixbus functionality
[ardour.git] / libs / surfaces / launch_control_xl / launch_control_xl.cc
index aeeae77ce8c6cb4864ccf4015b020036dc3bd53c..f92d6125aae9a99ee3fe8dfb5937252cbfa2e1de 100644 (file)
@@ -81,9 +81,6 @@ LaunchControlXL::LaunchControlXL (ARDOUR::Session& s)
 
        /* master cannot be removed, so no need to connect to going-away signal */
        master = session->master_out ();
-       /* the master bus will always be on the last channel on the lcxl */
-       stripable[7] = master;
-
 
        run_event_loop ();
 
@@ -120,6 +117,7 @@ LaunchControlXL::~LaunchControlXL ()
        ports_release ();
 
        stop_event_loop ();
+       tear_down_gui ();
 }
 
 
@@ -150,6 +148,9 @@ LaunchControlXL::begin_using_device ()
 
        in_use = true;
 
+       DEBUG_TRACE (DEBUG::LaunchControlXL, string_compose("use_fader8master inital value  '%1'\n", use_fader8master));
+       set_fader8master(use_fader8master);
+
        return 0;
 }
 
@@ -466,13 +467,21 @@ LaunchControlXL::handle_knob_message (Knob* knob)
                }
        } else if (knob->id() >= 8 && knob->id() < 16) { // sendB knob
                if (buttons_down.find(Device) != buttons_down.end()) { // Device button hold
+#ifdef MIXBUS
+                       ac = stripable[chan]->filter_freq_controllable (true);
+#else
                        /* something */
+#endif
                } else {
                        ac = stripable[chan]->send_level_controllable (1);
                }
        } else if (knob->id() >= 16 && knob->id() < 24) { // pan knob
                if (buttons_down.find(Device) != buttons_down.end()) { // Device button hold
+#ifdef MIXBUS
+                       ac = stripable[chan]->comp_threshold_controllable();
+#else
                        ac = stripable[chan]->pan_width_control();
+#endif
                } else {
                        ac = stripable[chan]->pan_azimuth_control();
                }
@@ -646,6 +655,10 @@ LaunchControlXL::get_state()
        child->add_child_nocopy (_async_out->get_state());
        node.add_child_nocopy (*child);
 
+       child = new XMLNode (X_("Configuration"));
+       child->set_property ("fader8master", LaunchControlXL::use_fader8master);
+       node.add_child_nocopy (*child);
+
        return node;
 }
 
@@ -676,6 +689,11 @@ LaunchControlXL::set_state (const XMLNode & node, int version)
                }
        }
 
+       if ((child = node.child (X_("Configuration"))) !=0) {
+               /* this should propably become a for-loop at some point */
+               child->get_property ("fader8master", use_fader8master);
+       }
+
        return retval;
 }
 
@@ -811,10 +829,10 @@ LaunchControlXL::stripable_property_change (PropertyChange const& what_changed,
                        return;
                }
                if (which < 8) {
-                       button_track_focus((uint8_t)which);
+                       update_track_focus_led ((uint8_t) which);
+                       update_knob_led((uint8_t) which);
                }
        }
-
 }
 
 void
@@ -834,8 +852,15 @@ LaunchControlXL::switch_bank (uint32_t base)
 
        boost::shared_ptr<Stripable> s[8];
        uint32_t different = 0;
+       int stripable_counter;
 
-       for (int n = 0; n < 7; ++n) {
+       if (LaunchControlXL::use_fader8master) {
+               stripable_counter = 7;
+       } else {
+               stripable_counter = 8;
+       }
+
+       for (int n = 0; n < stripable_counter; ++n) {
                s[n] = session->get_remote_nth_stripable (base+n, PresentationInfo::Flag (PresentationInfo::Route|PresentationInfo::VCA));
                if (s[n] != stripable[n]) {
                        different++;
@@ -854,7 +879,7 @@ LaunchControlXL::switch_bank (uint32_t base)
 
        stripable_connections.drop_connections ();
 
-       for (int n = 0; n < 7; ++n) {
+       for (int n = 0; n < stripable_counter; ++n) {
                stripable[n] = s[n];
        }
 
@@ -875,8 +900,9 @@ LaunchControlXL::switch_bank (uint32_t base)
                                stripable[n]->rec_enable_control()->Changed.connect (stripable_connections, MISSING_INVALIDATOR, boost::bind (&LaunchControlXL::rec_changed, this, n), lcxl);
                        }
                }
-               button_track_focus(n);
+               update_track_focus_led(n);
                button_track_mode(track_mode());
+               update_knob_led(n);
        }
 }
 
@@ -907,3 +933,12 @@ void LaunchControlXL::set_track_mode (TrackMode mode) {
                break;
        }
 }
+
+void
+LaunchControlXL::set_fader8master (bool yn)
+{
+       if (yn) {
+               stripable[7] = master;
+       }
+       switch_bank(bank_start);
+}