2 Copyright (C) 2016 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #include "pbd/compose.h"
23 #include "pbd/convert.h"
24 #include "pbd/debug.h"
25 #include "pbd/failed_constructor.h"
26 #include "pbd/file_utils.h"
27 #include "pbd/search_path.h"
28 #include "pbd/enumwriter.h"
30 #include "midi++/parser.h"
32 #include "ardour/amp.h"
33 #include "ardour/async_midi_port.h"
34 #include "ardour/audioengine.h"
35 #include "ardour/debug.h"
36 #include "ardour/midiport_manager.h"
37 #include "ardour/midi_track.h"
38 #include "ardour/midi_port.h"
39 #include "ardour/session.h"
40 #include "ardour/tempo.h"
41 #include "ardour/types_convert.h"
42 #include "ardour/vca_manager.h"
45 #include "gtkmm2ext/gui_thread.h"
48 #include "launch_control_xl.h"
52 #ifdef PLATFORM_WINDOWS
53 #define random() rand()
56 using namespace ARDOUR;
60 using namespace ArdourSurface;
61 #include "pbd/abstract_ui.cc" // instantiate template
63 /* init global object */
64 LaunchControlXL* lcxl = 0;
66 LaunchControlXL::LaunchControlXL (ARDOUR::Session& s)
67 : ControlProtocol (s, string (X_("Novation Launch Control XL")))
68 , AbstractUI<LaunchControlRequest> (name())
70 , _track_mode(TrackMute)
71 , _template_number(8) // default template (factory 1)
73 , connection_state (ConnectionState (0))
75 , in_range_select (false)
78 /* we're going to need this */
82 /* master cannot be removed, so no need to connect to going-away signal */
83 master = session->master_out ();
87 /* Ports exist for the life of this instance */
91 /* catch arrival and departure of LaunchControlXL itself */
92 ARDOUR::AudioEngine::instance()->PortRegisteredOrUnregistered.connect (port_reg_connection, MISSING_INVALIDATOR, boost::bind (&LaunchControlXL::port_registration_handler, this), this);
94 /* Catch port connections and disconnections */
95 ARDOUR::AudioEngine::instance()->PortConnectedOrDisconnected.connect (port_connection, MISSING_INVALIDATOR, boost::bind (&LaunchControlXL::connection_handler, this, _1, _2, _3, _4, _5), this);
97 /* Launch Control XL ports might already be there */
98 port_registration_handler ();
100 session->RouteAdded.connect (session_connections, MISSING_INVALIDATOR, boost::bind (&LaunchControlXL::stripables_added, this), lcxl);
101 session->vca_manager().VCAAdded.connect (session_connections, MISSING_INVALIDATOR, boost::bind (&LaunchControlXL::stripables_added, this), lcxl);
103 switch_bank (bank_start);
106 LaunchControlXL::~LaunchControlXL ()
108 DEBUG_TRACE (DEBUG::LaunchControlXL, "Launch Control XL control surface object being destroyed\n");
110 /* do this before stopping the event loop, so that we don't get any notifications */
111 port_reg_connection.disconnect ();
112 port_connection.disconnect ();
113 session_connections.drop_connections ();
114 stripable_connections.drop_connections ();
116 stop_using_device ();
125 LaunchControlXL::run_event_loop ()
127 DEBUG_TRACE (DEBUG::LaunchControlXL, "start event loop\n");
132 LaunchControlXL::stop_event_loop ()
134 DEBUG_TRACE (DEBUG::LaunchControlXL, "stop event loop\n");
139 LaunchControlXL::begin_using_device ()
141 DEBUG_TRACE (DEBUG::LaunchControlXL, "begin using device\n");
143 switch_template(template_number()); // first factory template
145 connect_session_signals ();
151 DEBUG_TRACE (DEBUG::LaunchControlXL, string_compose("use_fader8master inital value '%1'\n", use_fader8master));
152 set_fader8master(use_fader8master);
158 LaunchControlXL::stop_using_device ()
160 DEBUG_TRACE (DEBUG::LaunchControlXL, "stop using device\n");
163 DEBUG_TRACE (DEBUG::LaunchControlXL, "nothing to do, device not in use\n");
167 init_buttons (false);
169 session_connections.drop_connections ();
176 LaunchControlXL::ports_acquire ()
178 DEBUG_TRACE (DEBUG::LaunchControlXL, "acquiring ports\n");
182 _async_in = AudioEngine::instance()->register_input_port (DataType::MIDI, X_("Launch Control XL in"), true);
183 _async_out = AudioEngine::instance()->register_output_port (DataType::MIDI, X_("Launch Control XL out"), true);
185 if (_async_in == 0 || _async_out == 0) {
186 DEBUG_TRACE (DEBUG::LaunchControlXL, "cannot register ports\n");
190 /* We do not add our ports to the input/output bundles because we don't
191 * want users wiring them by hand. They could use JACK tools if they
192 * really insist on that (and use JACK)
195 _input_port = boost::dynamic_pointer_cast<AsyncMIDIPort>(_async_in).get();
196 _output_port = boost::dynamic_pointer_cast<AsyncMIDIPort>(_async_out).get();
198 session->BundleAddedOrRemoved ();
200 connect_to_parser ();
202 /* Connect input port to event loop */
206 asp = static_cast<AsyncMIDIPort*> (_input_port);
207 asp->xthread().set_receive_handler (sigc::bind (sigc::mem_fun (this, &LaunchControlXL::midi_input_handler), _input_port));
208 asp->xthread().attach (main_loop()->get_context());
214 LaunchControlXL::ports_release ()
216 DEBUG_TRACE (DEBUG::LaunchControlXL, "releasing ports\n");
218 /* wait for button data to be flushed */
220 asp = static_cast<AsyncMIDIPort*> (_output_port);
221 asp->drain (10000, 500000);
224 Glib::Threads::Mutex::Lock em (AudioEngine::instance()->process_lock());
225 AudioEngine::instance()->unregister_port (_async_in);
226 AudioEngine::instance()->unregister_port (_async_out);
229 _async_in.reset ((ARDOUR::Port*) 0);
230 _async_out.reset ((ARDOUR::Port*) 0);
235 list<boost::shared_ptr<ARDOUR::Bundle> >
236 LaunchControlXL::bundles ()
238 list<boost::shared_ptr<ARDOUR::Bundle> > b;
240 if (_output_bundle) {
241 b.push_back (_output_bundle);
249 LaunchControlXL::init_buttons (bool startup)
251 reset(template_number());
254 switch_bank(bank_start);
259 LaunchControlXL::probe ()
265 LaunchControlXL::request_factory (uint32_t num_requests)
267 /* AbstractUI<T>::request_buffer_factory() is a template method only
268 instantiated in this source module. To provide something visible for
269 use in the interface/descriptor, we have this static method that is
272 return request_buffer_factory (num_requests);
276 LaunchControlXL::do_request (LaunchControlRequest * req)
278 if (req->type == CallSlot) {
280 call_slot (MISSING_INVALIDATOR, req->the_slot);
282 } else if (req->type == Quit) {
284 stop_using_device ();
289 LaunchControlXL::reset(uint8_t chan)
291 MidiByteArray msg (3, 176 + chan, 0, 0); // turn off all leds, reset buffer settings and duty cycle
296 LaunchControlXL::set_active (bool yn)
298 DEBUG_TRACE (DEBUG::LaunchControlXL, string_compose("LaunchControlProtocol::set_active init with yn: '%1'\n", yn));
300 if (yn == active()) {
305 if ((connection_state & (InputConnected|OutputConnected)) == (InputConnected|OutputConnected)) {
306 begin_using_device ();
308 /* begin_using_device () will get called once we're connected */
312 /* Control Protocol Manager never calls us with false, but
313 * insteads destroys us.
317 ControlProtocol::set_active (yn);
319 DEBUG_TRACE (DEBUG::LaunchControlXL, string_compose("LaunchControlProtocol::set_active done with yn: '%1'\n", yn));
325 LaunchControlXL::write (const MidiByteArray& data)
327 /* immediate delivery */
328 _output_port->write (&data[0], data.size(), 0);
331 /* Device to Ardour message handling */
334 LaunchControlXL::midi_input_handler (IOCondition ioc, MIDI::Port* port)
337 DEBUG_TRACE (DEBUG::LaunchControlXL, "MIDI port closed\n");
343 DEBUG_TRACE (DEBUG::LaunchControlXL, string_compose ("something happened on %1\n", port->name()));
345 AsyncMIDIPort* asp = static_cast<AsyncMIDIPort*>(port);
350 DEBUG_TRACE (DEBUG::LaunchControlXL, string_compose ("data available on %1\n", port->name()));
352 samplepos_t now = AudioEngine::instance()->sample_time();
362 LaunchControlXL::connect_to_parser ()
364 DEBUG_TRACE (DEBUG::LaunchControlXL, string_compose ("Connecting to signals on port %1\n", _input_port->name()));
366 MIDI::Parser* p = _input_port->parser();
369 p->sysex.connect_same_thread (*this, boost::bind (&LaunchControlXL::handle_midi_sysex, this, _1, _2, _3));
371 for (MIDI::channel_t n = 0; n < 16; ++n) {
373 p->channel_controller[(int)n].connect_same_thread (*this, boost::bind (&LaunchControlXL::handle_midi_controller_message, this, _1, _2, n));
374 /* Button messages are NoteOn */
375 p->channel_note_on[(int)n].connect_same_thread (*this, boost::bind (&LaunchControlXL::handle_midi_note_on_message, this, _1, _2, n));
376 /* Button messages are NoteOn but libmidi++ sends note-on w/velocity = 0 as note-off so catch them too */
377 p->channel_note_off[(int)n].connect_same_thread (*this, boost::bind (&LaunchControlXL::handle_midi_note_off_message, this, _1, _2, n));
382 LaunchControlXL::handle_midi_sysex (MIDI::Parser&, MIDI::byte* raw_bytes, size_t sz)
384 DEBUG_TRACE (DEBUG::LaunchControlXL, string_compose ("Sysex, %1 bytes\n", sz));
390 MidiByteArray msg (sz, raw_bytes);
391 MidiByteArray lcxl_sysex_header (6, 0xF0, 0x00, 0x20, 0x29, 0x02, 0x11);
393 if (!lcxl_sysex_header.compare_n (msg, 6)) {
399 case 0x77: /* template change */
400 DEBUG_TRACE (DEBUG::LaunchControlXL, string_compose ("Template change: %1 n", msg[7]));
401 _template_number = msg[7];
408 LaunchControlXL::handle_button_message(Button* button, MIDI::EventTwoBytes* ev)
411 /* any press cancels any pending long press timeouts */
412 for (set<ButtonID>::iterator x = buttons_down.begin(); x != buttons_down.end(); ++x) {
413 ControllerButton* cb = id_controller_button_map[*x];
414 NoteButton* nb = id_note_button_map[*x];
416 cb->timeout_connection.disconnect();
417 } else if (nb != 0) {
418 nb->timeout_connection.disconnect();
422 buttons_down.insert(button->id());
423 DEBUG_TRACE(DEBUG::LaunchControlXL, string_compose("button pressed: %1\n", LaunchControlXL::button_name_by_id(button->id())));
424 start_press_timeout(button, button->id());
426 DEBUG_TRACE(DEBUG::LaunchControlXL, string_compose("button depressed: %1\n", LaunchControlXL::button_name_by_id(button->id())));
427 buttons_down.erase(button->id());
428 button->timeout_connection.disconnect();
431 set<ButtonID>::iterator c = consumed.find(button->id());
433 if (c == consumed.end()) {
434 if (ev->value == 0) {
435 (this->*button->release_method)();
437 (this->*button->press_method)();
440 DEBUG_TRACE(DEBUG::LaunchControlXL, "button was consumed, ignored\n");
446 LaunchControlXL::check_pick_up(Controller* controller, boost::shared_ptr<AutomationControl> ac)
448 /* returns false until the controller value matches with the current setting of the stripable's ac */
449 return ( abs( controller->value() / 127.0 - ac->internal_to_interface(ac->get_value()) ) < 0.007875 );
453 LaunchControlXL::handle_knob_message (Knob* knob)
455 uint8_t chan = knob->id() % 8; // get the strip channel number
456 if (!stripable[chan]) {
460 boost::shared_ptr<AutomationControl> ac;
462 if (knob->id() < 8) { // sendA knob
463 if (buttons_down.find(Device) != buttons_down.end()) { // Device button hold
464 ac = stripable[chan]->trim_control();
466 ac = stripable[chan]->send_level_controllable (0);
468 } else if (knob->id() >= 8 && knob->id() < 16) { // sendB knob
469 if (buttons_down.find(Device) != buttons_down.end()) { // Device button hold
471 ac = stripable[chan]->filter_freq_controllable (true);
476 ac = stripable[chan]->send_level_controllable (1);
478 } else if (knob->id() >= 16 && knob->id() < 24) { // pan knob
479 if (buttons_down.find(Device) != buttons_down.end()) { // Device button hold
481 ac = stripable[chan]->comp_threshold_controllable();
483 ac = stripable[chan]->pan_width_control();
486 ac = stripable[chan]->pan_azimuth_control();
490 if (ac && check_pick_up(knob, ac)) {
491 ac->set_value ( ac->interface_to_internal( knob->value() / 127.0), PBD::Controllable::UseGroup );
496 LaunchControlXL::handle_fader_message (Fader* fader)
499 if (!stripable[fader->id()]) {
503 boost::shared_ptr<AutomationControl> ac = stripable[fader->id()]->gain_control();
504 if (ac && check_pick_up(fader, ac)) {
505 ac->set_value ( ac->interface_to_internal( fader->value() / 127.0), PBD::Controllable::UseGroup );
510 LaunchControlXL::handle_midi_controller_message (MIDI::Parser& parser, MIDI::EventTwoBytes* ev, MIDI::channel_t chan)
512 _template_number = (int)chan;
514 if (template_number() < 8) {
515 return; // only treat factory templates
517 // DEBUG_TRACE (DEBUG::LaunchControlXL, string_compose ("CC %1 (value %2)\n", (int) ev->controller_number, (int) ev->value));
519 CCControllerButtonMap::iterator b = cc_controller_button_map.find (ev->controller_number);
520 CCFaderMap::iterator f = cc_fader_map.find (ev->controller_number);
521 CCKnobMap::iterator k = cc_knob_map.find (ev->controller_number);
523 if (b != cc_controller_button_map.end()) {
524 Button* button = b->second;
525 handle_button_message(button, ev);
526 } else if (f != cc_fader_map.end()) {
527 Fader* fader = f->second;
528 fader->set_value(ev->value);
529 handle_fader_message(fader);
531 } else if (k != cc_knob_map.end()) {
532 Knob* knob = k->second;
533 knob->set_value(ev->value);
534 handle_knob_message(knob);
539 LaunchControlXL::handle_midi_note_on_message (MIDI::Parser& parser, MIDI::EventTwoBytes* ev, MIDI::channel_t chan)
541 _template_number = (int)chan;
543 if (template_number() < 8) {
544 return; // only treat factory templates
547 //DEBUG_TRACE (DEBUG::LaunchControlXL, string_compose ("Note On %1 (velocity %2)\n", (int) ev->note_number, (int) ev->velocity));
549 NNNoteButtonMap::iterator b = nn_note_button_map.find (ev->controller_number);
551 if (b != nn_note_button_map.end()) {
552 Button* button = b->second;
553 handle_button_message(button, ev);
557 void LaunchControlXL::handle_midi_note_off_message(MIDI::Parser & parser, MIDI::EventTwoBytes *ev, MIDI::channel_t chan)
559 //DEBUG_TRACE(DEBUG::LaunchControlXL, string_compose("Note Off %1 (velocity %2)\n",(int)ev->note_number, (int)ev->velocity));
560 handle_midi_note_on_message(parser, ev, chan); /* we handle both case in handle_midi_note_on_message */
563 /* Ardour session signals connection */
566 LaunchControlXL::thread_init ()
568 pthread_set_name (event_loop_name().c_str());
570 PBD::notify_event_loops_about_thread_creation (pthread_self(), event_loop_name(), 2048);
571 ARDOUR::SessionEvent::create_per_thread_pool (event_loop_name(), 128);
573 set_thread_priority ();
577 LaunchControlXL::connect_session_signals()
579 // receive transport state changed
580 session->TransportStateChange.connect(session_connections, MISSING_INVALIDATOR, boost::bind (&LaunchControlXL::notify_transport_state_changed, this), this);
581 session->TransportLooped.connect (session_connections, MISSING_INVALIDATOR, boost::bind (&LaunchControlXL::notify_loop_state_changed, this), this);
582 // receive punch-in and punch-out
583 Config->ParameterChanged.connect(session_connections, MISSING_INVALIDATOR, boost::bind (&LaunchControlXL::notify_parameter_changed, this, _1), this);
584 session->config.ParameterChanged.connect (session_connections, MISSING_INVALIDATOR, boost::bind (&LaunchControlXL::notify_parameter_changed, this, _1), this);
586 // receive rude solo changed
587 //session->SoloActive.connect(session_connections, MISSING_INVALIDATOR, boost::bind (&LaunchControlXL::notify_solo_active_changed, this, _1), this);
588 // receive record state toggled
589 //session->RecordStateChanged.connect(session_connections, MISSING_INVALIDATOR, boost::bind (&LaunchControlXL::notify_record_state_changed, this), this);
595 LaunchControlXL::notify_transport_state_changed ()
597 Button* b = id_button_map[Play];
599 if (session->transport_rolling()) {
600 b->set_state (LED::OneShot24th);
601 b->set_color (LED::GreenFull);
604 disable any blink on FixedLength from pending edit range op
605 Button* fl = id_button_map[FixedLength];
607 fl->set_color (LED::Black);
608 fl->set_state (LED::NoTransition);
609 write (fl->state_msg());
611 b->set_color (LED::White);
612 b->set_state (LED::NoTransition);
615 write (b->state_msg()); */
619 LaunchControlXL::notify_loop_state_changed ()
624 LaunchControlXL::notify_parameter_changed (std::string param)
626 IDButtonMap::iterator b;
628 if (param == "clicking") {
629 if ((b = id_button_map.find (Metronome)) == id_button_map.end()) {
632 if (Config->get_clicking()) {
633 b->second->set_state (LED::Blinking4th);
634 b->second->set_color (LED::White);
636 b->second->set_color (LED::White);
637 b->second->set_state (LED::NoTransition);
639 write (b->second->state_msg ()) ;
643 /* connection handling */
646 LaunchControlXL::get_state()
648 XMLNode& node (ControlProtocol::get_state());
651 child = new XMLNode (X_("Input"));
652 child->add_child_nocopy (_async_in->get_state());
653 node.add_child_nocopy (*child);
654 child = new XMLNode (X_("Output"));
655 child->add_child_nocopy (_async_out->get_state());
656 node.add_child_nocopy (*child);
658 child = new XMLNode (X_("Configuration"));
659 child->set_property ("fader8master", LaunchControlXL::use_fader8master);
660 node.add_child_nocopy (*child);
666 LaunchControlXL::set_state (const XMLNode & node, int version)
668 DEBUG_TRACE (DEBUG::LaunchControlXL, string_compose ("LaunchControlXL::set_state: active %1\n", active()));
672 if (ControlProtocol::set_state (node, version)) {
678 if ((child = node.child (X_("Input"))) != 0) {
679 XMLNode* portnode = child->child (Port::state_node_name.c_str());
681 _async_in->set_state (*portnode, version);
685 if ((child = node.child (X_("Output"))) != 0) {
686 XMLNode* portnode = child->child (Port::state_node_name.c_str());
688 _async_out->set_state (*portnode, version);
692 if ((child = node.child (X_("Configuration"))) !=0) {
693 /* this should propably become a for-loop at some point */
694 child->get_property ("fader8master", use_fader8master);
701 LaunchControlXL::port_registration_handler ()
703 if (!_async_in && !_async_out) {
704 /* ports not registered yet */
708 if (_async_in->connected() && _async_out->connected()) {
709 /* don't waste cycles here */
714 /* the origin of the numeric magic identifiers is known only to Ableton
715 and may change in time. This is part of how CoreMIDI works.
717 string input_port_name = X_("system:midi_capture_1319078870");
718 string output_port_name = X_("system:midi_playback_3409210341");
720 string input_port_name = X_("Novation Launch Control XL MIDI 1 in");
721 string output_port_name = X_("Novation Launch Control XL MIDI 1 out");
726 AudioEngine::instance()->get_ports (string_compose (".*%1", input_port_name), DataType::MIDI, PortFlags (IsPhysical|IsOutput), in);
727 AudioEngine::instance()->get_ports (string_compose (".*%1", output_port_name), DataType::MIDI, PortFlags (IsPhysical|IsInput), out);
729 if (!in.empty() && !out.empty()) {
730 cerr << "LaunchControlXL: both ports found\n";
731 cerr << "\tconnecting to " << in.front() << " + " << out.front() << endl;
732 if (!_async_in->connected()) {
733 AudioEngine::instance()->connect (_async_in->name(), in.front());
735 if (!_async_out->connected()) {
736 AudioEngine::instance()->connect (_async_out->name(), out.front());
742 LaunchControlXL::connection_handler (boost::weak_ptr<ARDOUR::Port>, std::string name1, boost::weak_ptr<ARDOUR::Port>, std::string name2, bool yn)
744 DEBUG_TRACE (DEBUG::LaunchControlXL, "LaunchControlXL::connection_handler start\n");
745 if (!_input_port || !_output_port) {
749 string ni = ARDOUR::AudioEngine::instance()->make_port_name_non_relative (boost::shared_ptr<ARDOUR::Port>(_async_in)->name());
750 string no = ARDOUR::AudioEngine::instance()->make_port_name_non_relative (boost::shared_ptr<ARDOUR::Port>(_async_out)->name());
752 if (ni == name1 || ni == name2) {
754 connection_state |= InputConnected;
756 connection_state &= ~InputConnected;
758 } else if (no == name1 || no == name2) {
760 connection_state |= OutputConnected;
762 connection_state &= ~OutputConnected;
765 DEBUG_TRACE (DEBUG::LaunchControlXL, string_compose ("Connections between %1 and %2 changed, but I ignored it\n", name1, name2));
770 DEBUG_TRACE (DEBUG::LaunchControlXL, string_compose ("our ports changed connection state: %1 -> %2 connected ? %3\n",
773 if ((connection_state & (InputConnected|OutputConnected)) == (InputConnected|OutputConnected)) {
775 /* XXX this is a horrible hack. Without a short sleep here,
776 something prevents the device wakeup messages from being
777 sent and/or the responses from being received.
781 DEBUG_TRACE (DEBUG::LaunchControlXL, "device now connected for both input and output\n");
783 begin_using_device ();
786 DEBUG_TRACE (DEBUG::LaunchControlXL, "Device disconnected (input or output or both) or not yet fully connected\n");
787 stop_using_device ();
790 ConnectionChange (); /* emit signal for our GUI */
792 DEBUG_TRACE (DEBUG::LaunchControlXL, "LaunchControlXL::connection_handler end\n");
794 return true; /* connection status changed */
798 boost::shared_ptr<Port>
799 LaunchControlXL::output_port()
804 boost::shared_ptr<Port>
805 LaunchControlXL::input_port()
810 /* Stripables handling */
813 LaunchControlXL::stripable_selection_changed () // we don't need it but it's needs to be declared...
819 LaunchControlXL::stripable_property_change (PropertyChange const& what_changed, uint32_t which)
822 if (what_changed.contains (Properties::hidden)) {
823 switch_bank (bank_start);
826 if (what_changed.contains (Properties::selected)) {
828 if (!stripable[which]) {
832 update_track_focus_led ((uint8_t) which);
833 update_knob_led((uint8_t) which);
839 LaunchControlXL::switch_template (uint8_t t)
841 MidiByteArray msg (9, 0xf0, 0x00, 0x20, 0x29, 0x02, 0x11, 0x77, t, 0xf7);
846 LaunchControlXL::switch_bank (uint32_t base)
848 SelectButton* sl = static_cast<SelectButton*>(id_controller_button_map[SelectLeft]);
849 SelectButton* sr = static_cast<SelectButton*>(id_controller_button_map[SelectRight]);
851 /* work backwards so we can tell if we should actually switch banks */
853 boost::shared_ptr<Stripable> s[8];
854 uint32_t different = 0;
855 int stripable_counter;
857 if (LaunchControlXL::use_fader8master) {
858 stripable_counter = 7;
860 stripable_counter = 8;
863 for (int n = 0; n < stripable_counter; ++n) {
864 s[n] = session->get_remote_nth_stripable (base+n, PresentationInfo::Flag (PresentationInfo::Route|PresentationInfo::VCA));
865 if (s[n] != stripable[n]) {
871 write(sl->state_msg((base)));
872 write(sr->state_msg((s[1] != 0)));
876 /* not even the first stripable exists, do nothing */
880 stripable_connections.drop_connections ();
882 for (int n = 0; n < stripable_counter; ++n) {
886 /* at least one stripable in this bank */
890 for (int n = 0; n < 8; ++n) {
893 /* stripable goes away? refill the bank, starting at the same point */
895 stripable[n]->DropReferences.connect (stripable_connections, MISSING_INVALIDATOR, boost::bind (&LaunchControlXL::switch_bank, this, bank_start), lcxl);
896 stripable[n]->presentation_info().PropertyChanged.connect (stripable_connections, MISSING_INVALIDATOR, boost::bind (&LaunchControlXL::stripable_property_change, this, _1, n), lcxl);
897 stripable[n]->solo_control()->Changed.connect (stripable_connections, MISSING_INVALIDATOR, boost::bind (&LaunchControlXL::solo_changed, this, n), lcxl);
898 stripable[n]->mute_control()->Changed.connect (stripable_connections, MISSING_INVALIDATOR, boost::bind (&LaunchControlXL::mute_changed, this, n), lcxl);
899 if (stripable[n]->rec_enable_control()) {
900 stripable[n]->rec_enable_control()->Changed.connect (stripable_connections, MISSING_INVALIDATOR, boost::bind (&LaunchControlXL::rec_changed, this, n), lcxl);
903 update_track_focus_led(n);
904 button_track_mode(track_mode());
910 LaunchControlXL::stripables_added ()
912 DEBUG_TRACE (DEBUG::LaunchControlXL, "LaunchControlXL::new stripable added!\n");
913 /* reload current bank */
914 switch_bank (bank_start);
918 void LaunchControlXL::set_track_mode (TrackMode mode) {
921 // now do led stuffs to signify the change
938 LaunchControlXL::set_fader8master (bool yn)
941 stripable[7] = master;
943 switch_bank(bank_start);