diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2014-02-19 12:50:28 -0500 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2014-02-19 13:22:52 -0500 |
commit | 29b3c299a1bb037bdc2870d642bb6a23bdedabee (patch) | |
tree | a18a30ae06c52d79f73952edfad3afc8d3079713 /libs | |
parent | f6541d7addb16ca5aa4462b0094237b2bb147b77 (diff) |
add a hack to deal with device discovery race, in which the devices were not actually known to be ready before the last update_surfaces() call (which is where binding between strips and routes occurs) ; add support for Mackie Control touch on/off messages
Diffstat (limited to 'libs')
-rw-r--r-- | libs/surfaces/mackie/mackie_control_protocol.cc | 18 | ||||
-rw-r--r-- | libs/surfaces/mackie/mackie_control_protocol.h | 2 | ||||
-rw-r--r-- | libs/surfaces/mackie/strip.cc | 11 | ||||
-rw-r--r-- | libs/surfaces/mackie/strip.h | 1 | ||||
-rw-r--r-- | libs/surfaces/mackie/surface.cc | 35 |
5 files changed, 61 insertions, 6 deletions
diff --git a/libs/surfaces/mackie/mackie_control_protocol.cc b/libs/surfaces/mackie/mackie_control_protocol.cc index e9bef5a9b0..fc1491d9e8 100644 --- a/libs/surfaces/mackie/mackie_control_protocol.cc +++ b/libs/surfaces/mackie/mackie_control_protocol.cc @@ -345,7 +345,9 @@ MackieControlProtocol::switch_banks (uint32_t initial, bool force) if (_current_initial_bank <= sorted.size()) { - DEBUG_TRACE (DEBUG::MackieControl, string_compose ("switch to %1, %2, available routes %3\n", _current_initial_bank, strip_cnt, sorted.size())); + DEBUG_TRACE (DEBUG::MackieControl, string_compose ("switch to %1, %2, available routes %3 on %4 surfaces\n", + _current_initial_bank, strip_cnt, sorted.size(), + surfaces.size())); // link routes to strips @@ -521,11 +523,23 @@ MackieControlProtocol::update_global_led (int id, LedState ls) } } +void +MackieControlProtocol::device_ready () +{ + /* this is not required to be called, but for devices which do + * handshaking, it can be called once the device has verified the + * connection. + */ + + DEBUG_TRACE (DEBUG::MackieControl, string_compose ("device ready init (active=%1)\n", active())); + update_surfaces (); +} + // send messages to surface to set controls to correct values void MackieControlProtocol::update_surfaces() { - DEBUG_TRACE (DEBUG::MackieControl, "MackieControlProtocol::update_surfaces() init\n"); + DEBUG_TRACE (DEBUG::MackieControl, string_compose ("MackieControlProtocol::update_surfaces() init (active=%1)\n", active())); if (!active()) { return; } diff --git a/libs/surfaces/mackie/mackie_control_protocol.h b/libs/surfaces/mackie/mackie_control_protocol.h index e1a71a2460..fc965d868b 100644 --- a/libs/surfaces/mackie/mackie_control_protocol.h +++ b/libs/surfaces/mackie/mackie_control_protocol.h @@ -119,6 +119,8 @@ class MackieControlProtocol const Mackie::DeviceInfo& device_info() const { return _device_info; } Mackie::DeviceProfile& device_profile() { return _device_profile; } + void device_ready (); + int set_active (bool yn); int set_device (const std::string&); void set_profile (const std::string&); diff --git a/libs/surfaces/mackie/strip.cc b/libs/surfaces/mackie/strip.cc index ef4447d900..1893e31b8d 100644 --- a/libs/surfaces/mackie/strip.cc +++ b/libs/surfaces/mackie/strip.cc @@ -627,12 +627,21 @@ Strip::do_parameter_display (AutomationType type, float val) } void +Strip::handle_fader_touch (Fader& fader, bool touch_on) +{ + if (touch_on) { + fader.start_touch (_surface->mcp().transport_frame()); + } else { + fader.stop_touch (_surface->mcp().transport_frame(), false); + } +} + +void Strip::handle_fader (Fader& fader, float position) { DEBUG_TRACE (DEBUG::MackieControl, string_compose ("fader to %1\n", position)); fader.set_value (position); - fader.start_touch (_surface->mcp().transport_frame()); queue_display_reset (2000); // must echo bytes back to slider now, because diff --git a/libs/surfaces/mackie/strip.h b/libs/surfaces/mackie/strip.h index 225783d0fe..c330e0e54d 100644 --- a/libs/surfaces/mackie/strip.h +++ b/libs/surfaces/mackie/strip.h @@ -61,6 +61,7 @@ public: void handle_button (Button&, ButtonState bs); void handle_fader (Fader&, float position); + void handle_fader_touch (Fader&, bool touch_on); void handle_pot (Pot&, float delta); void periodic (uint64_t now_usecs); diff --git a/libs/surfaces/mackie/surface.cc b/libs/surfaces/mackie/surface.cc index 694c73b1bc..09c5fff051 100644 --- a/libs/surfaces/mackie/surface.cc +++ b/libs/surfaces/mackie/surface.cc @@ -369,7 +369,7 @@ Surface::connect_to_signals () p->controller.connect_same_thread (*this, boost::bind (&Surface::handle_midi_controller_message, this, _1, _2)); /* Button messages are NoteOn */ p->note_on.connect_same_thread (*this, boost::bind (&Surface::handle_midi_note_on_message, this, _1, _2)); - /* Button messages are NoteOn. libmidi++ sends note-on w/velocity = 0 as note-off so catch them too */ + /* Button messages are NoteOn but libmidi++ sends note-on w/velocity = 0 as note-off so catch them too */ p->note_off.connect_same_thread (*this, boost::bind (&Surface::handle_midi_note_on_message, this, _1, _2)); /* Fader messages are Pitchbend */ uint32_t i; @@ -386,7 +386,7 @@ Surface::connect_to_signals () void Surface::handle_midi_pitchbend_message (MIDI::Parser&, MIDI::pitchbend_t pb, uint32_t fader_id) { - /* Pitchbend messages are fader messages. Nothing in the data we get + /* Pitchbend messages are fader position messages. Nothing in the data we get * from the MIDI::Parser conveys the fader ID, which was given by the * channel ID in the status byte. * @@ -394,7 +394,6 @@ Surface::handle_midi_pitchbend_message (MIDI::Parser&, MIDI::pitchbend_t pb, uin * when we connected to the per-channel pitchbend events. */ - DEBUG_TRACE (DEBUG::MackieControl, string_compose ("Surface::handle_midi_pitchbend_message on port %3, fader = %1 value = %2\n", fader_id, pb, _number)); @@ -429,6 +428,28 @@ Surface::handle_midi_note_on_message (MIDI::Parser &, MIDI::EventTwoBytes* ev) turn_it_on (); } + /* fader touch sense is given by "buttons" 0xe..0xe7 and 0xe8 for the + * master. + */ + + if (ev->note_number >= 0xE0 && ev->note_number <= 0xE8) { + Fader* fader = faders[ev->note_number]; + + DEBUG_TRACE (DEBUG::MackieControl, string_compose ("Surface: fader touch message, fader = %1\n", fader)); + + if (fader) { + + Strip* strip = dynamic_cast<Strip*> (&fader->group()); + + if (ev->velocity > 64) { + strip->handle_fader_touch (*fader, true); + } else { + strip->handle_fader_touch (*fader, false); + } + } + return; + } + Button* button = buttons[ev->note_number]; if (button) { @@ -516,8 +537,10 @@ Surface::handle_midi_sysex (MIDI::Parser &, MIDI::byte * raw_bytes, size_t count LCP: Connection Challenge */ if (bytes[4] == 0x10 || bytes[4] == 0x11) { + DEBUG_TRACE (DEBUG::MackieControl, "Logic Control Device connection challenge\n"); write_sysex (host_connection_query (bytes)); } else { + DEBUG_TRACE (DEBUG::MackieControl, string_compose ("Mackie Control Device ready, current status = %1\n", _active)); if (!_active) { turn_it_on (); } @@ -525,6 +548,7 @@ Surface::handle_midi_sysex (MIDI::Parser &, MIDI::byte * raw_bytes, size_t count break; case 0x03: /* LCP Connection Confirmation */ + DEBUG_TRACE (DEBUG::MackieControl, "Logic Control Device confirms connection, ardour replies\n"); if (bytes[4] == 0x10 || bytes[4] == 0x11) { write_sysex (host_connection_confirmation (bytes)); _active = true; @@ -532,6 +556,7 @@ Surface::handle_midi_sysex (MIDI::Parser &, MIDI::byte * raw_bytes, size_t count break; case 0x04: /* LCP: Confirmation Denied */ + DEBUG_TRACE (DEBUG::MackieControl, "Logic Control Device denies connection\n"); _active = false; break; default: @@ -610,6 +635,8 @@ Surface::turn_it_on () _active = true; + _mcp.device_ready (); + for (Strips::iterator s = strips.begin(); s != strips.end(); ++s) { (*s)->notify_all (); } @@ -739,6 +766,8 @@ Surface::map_routes (const vector<boost::shared_ptr<Route> >& routes) vector<boost::shared_ptr<Route> >::const_iterator r; Strips::iterator s = strips.begin(); + DEBUG_TRACE (DEBUG::MackieControl, string_compose ("Mapping %1 routes", routes.size())); + for (r = routes.begin(); r != routes.end() && s != strips.end(); ++s) { /* don't try to assign routes to a locked strip. it won't |