From 6e1371136138d882e95520aa5c70bac1a55fd865 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sun, 8 Apr 2012 14:51:14 +0000 Subject: [PATCH] MCP: stop using signals to handle parsed control events; add debugging git-svn-id: svn://localhost/ardour2/branches/3.0@11826 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/surfaces/mackie/dummy_port.h | 1 + .../mackie/mackie_control_protocol.cc | 33 ++++++++++++------- .../surfaces/mackie/mackie_control_protocol.h | 28 +++++----------- libs/surfaces/mackie/mackie_port.cc | 8 +++-- libs/surfaces/mackie/mackie_port.h | 2 ++ libs/surfaces/mackie/surface_port.h | 5 ++- 6 files changed, 42 insertions(+), 35 deletions(-) diff --git a/libs/surfaces/mackie/dummy_port.h b/libs/surfaces/mackie/dummy_port.h index 4ed0a3043b..056e30fa0d 100644 --- a/libs/surfaces/mackie/dummy_port.h +++ b/libs/surfaces/mackie/dummy_port.h @@ -53,6 +53,7 @@ public: virtual const MidiByteArray & sysex_hdr() const; virtual int strips() const; + }; } diff --git a/libs/surfaces/mackie/mackie_control_protocol.cc b/libs/surfaces/mackie/mackie_control_protocol.cc index f5d7c9b8f0..8ad9db142e 100644 --- a/libs/surfaces/mackie/mackie_control_protocol.cc +++ b/libs/surfaces/mackie/mackie_control_protocol.cc @@ -657,12 +657,6 @@ MackieControlProtocol::initialize_surface() } _surface->init(); - - // Connect events. Must be after route table otherwise there will be trouble - - for (MackiePorts::iterator it = _ports.begin(); it != _ports.end(); ++it) { - (*it)->control_event.connect_same_thread (port_connections, boost::bind (&MackieControlProtocol::handle_control_event, this, _1, _2, _3)); - } } void @@ -767,15 +761,26 @@ MackieControlProtocol::handle_control_event (SurfacePort & port, Control & contr { // find the route for the control, if there is one boost::shared_ptr route; + if (control.group().is_strip()) { if (control.group().is_master()) { + DEBUG_TRACE (DEBUG::MackieControl, "master strip control event\n"); route = master_route(); } else { uint32_t index = control.ordinal() - 1 + (port.number() * port.strips()); - if (index < route_table.size()) + DEBUG_TRACE (DEBUG::MackieControl, string_compose ("strip control event, index = %1, rt size = %2\n", + index, route_table.size())); + if (index < route_table.size()) { route = route_table[index]; - else + if (route) { + DEBUG_TRACE (DEBUG::MackieControl, string_compose ("modifying %1\n", route->name())); + } else { + DEBUG_TRACE (DEBUG::MackieControl, "no route found!\n"); + } + } else { cerr << "Warning: index is " << index << " which is not in the route table, size: " << route_table.size() << endl; + DEBUG_TRACE (DEBUG::MackieControl, "illegal route index found!\n"); + } } } @@ -789,6 +794,8 @@ MackieControlProtocol::handle_control_event (SurfacePort & port, Control & contr // at which point the fader should just reset itself if (route != 0) { + DEBUG_TRACE (DEBUG::MackieControl, string_compose ("fader to %1\n", state.pos)); + route->gain_control()->set_value (slider_position_to_gain (state.pos)); if (ARDOUR::Config->get_mackie_emulation() == "bcf") { @@ -806,6 +813,7 @@ MackieControlProtocol::handle_control_event (SurfacePort & port, Control & contr case Control::type_button: if (control.group().is_strip()) { // strips + DEBUG_TRACE (DEBUG::MackieControl, string_compose ("strip button %1\n", control.id())); if (route != 0) { handle_strip_button (port, control, state.button_state, route); } else { @@ -815,11 +823,13 @@ MackieControlProtocol::handle_control_event (SurfacePort & port, Control & contr } } else if (control.group().is_master()) { // master fader touch + DEBUG_TRACE (DEBUG::MackieControl, string_compose ("master strip button %1\n", control.id())); if (route != 0) { handle_strip_button (port, control, state.button_state, route); } } else { // handle all non-strip buttons + DEBUG_TRACE (DEBUG::MackieControl, string_compose ("global button %1\n", control.id())); surface().handle_button (*this, state.button_state, dynamic_cast (control)); } break; @@ -827,6 +837,7 @@ MackieControlProtocol::handle_control_event (SurfacePort & port, Control & contr // pot (jog wheel, external control) case Control::type_pot: if (control.group().is_strip()) { + DEBUG_TRACE (DEBUG::MackieControl, string_compose ("strip pot %1\n", control.id())); if (route) { boost::shared_ptr panner = route->panner_shell()->panner(); // pan for mono input routes, or stereo linked panners @@ -843,12 +854,12 @@ MackieControlProtocol::handle_control_event (SurfacePort & port, Control & contr // it's a pot for an umnapped route, so turn all the lights off port.write (builder.build_led_ring (dynamic_cast (control), off)); } - } - else - { + } else { if (control.is_jog()) { + DEBUG_TRACE (DEBUG::MackieControl, string_compose ("Jog wheel moved %1\n", state.ticks)); _jog_wheel.jog_event (port, control, state); } else { + DEBUG_TRACE (DEBUG::MackieControl, string_compose ("External controller moved %1\n", state.ticks)); cout << "external controller" << state.ticks * state.sign << endl; } } diff --git a/libs/surfaces/mackie/mackie_control_protocol.h b/libs/surfaces/mackie/mackie_control_protocol.h index 69b9d6a4aa..b42dbae258 100644 --- a/libs/surfaces/mackie/mackie_control_protocol.h +++ b/libs/surfaces/mackie/mackie_control_protocol.h @@ -101,26 +101,18 @@ class MackieControlProtocol void tear_down_gui (); // control events - void handle_control_event(Mackie::SurfacePort & port, Mackie::Control & control, const Mackie::ControlState & state); + void handle_control_event (Mackie::SurfacePort & port, Mackie::Control & control, const Mackie::ControlState & state); // strip/route related stuff public: - /// Signal handler for Route::solo - void notify_solo_changed(Mackie::RouteSignal *); - /// Signal handler for Route::mute - void notify_mute_changed(Mackie::RouteSignal *); - /// Signal handler for Route::record_enable_changed - void notify_record_enable_changed(Mackie::RouteSignal *); - /// Signal handler for Route::gain_changed (from IO) - void notify_gain_changed(Mackie::RouteSignal *, bool force_update = true); - /// Signal handler for Route::name_change - void notify_property_changed(const PBD::PropertyChange&, Mackie::RouteSignal *); - /// Signal handler from Panner::Change - void notify_panner_changed(Mackie::RouteSignal *, bool force_update = true); - /// Signal handler for new routes added - void notify_route_added(ARDOUR::RouteList &); - /// Signal handler for Route::active_changed - void notify_active_changed(Mackie::RouteSignal *); + void notify_solo_changed (Mackie::RouteSignal *); + void notify_mute_changed (Mackie::RouteSignal *); + void notify_record_enable_changed (Mackie::RouteSignal *); + void notify_gain_changed (Mackie::RouteSignal *, bool force_update = true); + void notify_property_changed (const PBD::PropertyChange&, Mackie::RouteSignal *); + void notify_panner_changed (Mackie::RouteSignal *, bool force_update = true); + void notify_route_added (ARDOUR::RouteList &); + void notify_active_changed (Mackie::RouteSignal *); void notify_remote_id_changed(); @@ -128,8 +120,6 @@ class MackieControlProtocol /// remote id changed. void refresh_current_bank(); - // global buttons (ie button not part of strips) - public: // button-related signals void notify_record_state_changed(); diff --git a/libs/surfaces/mackie/mackie_port.cc b/libs/surfaces/mackie/mackie_port.cc index d751437cb8..772b668a75 100644 --- a/libs/surfaces/mackie/mackie_port.cc +++ b/libs/surfaces/mackie/mackie_port.cc @@ -338,7 +338,7 @@ MackiePort::handle_midi_pitchbend_message (MIDI::Parser&, MIDI::pitchbend_t pb, // in_use is set by the MackieControlProtocol::handle_strip_button // relies on implicit ControlState constructor - control_event (*this, *control, float (midi_pos) / float(0x3ff)); + _mcp.handle_control_event (*this, *control, float (midi_pos) / float(0x3ff)); } } @@ -385,7 +385,6 @@ MackiePort::handle_midi_controller_message (MIDI::Parser &, MIDI::EventTwoBytes* control->set_in_use (true); add_in_use_timeout (*control, control); - // emit the control event control_event (*this, *control, state); } break; @@ -395,3 +394,8 @@ MackiePort::handle_midi_controller_message (MIDI::Parser &, MIDI::EventTwoBytes* } } +void +MackiePort::control_event (SurfacePort& sp, Control& c, const ControlState& cs) +{ + _mcp.handle_control_event (sp, c, cs); +} diff --git a/libs/surfaces/mackie/mackie_port.h b/libs/surfaces/mackie/mackie_port.h index dbd5553a63..086043a1f5 100644 --- a/libs/surfaces/mackie/mackie_port.h +++ b/libs/surfaces/mackie/mackie_port.h @@ -104,6 +104,8 @@ protected: */ void probe_emulation( const MidiByteArray & bytes ); + void control_event (SurfacePort &, Control &, const ControlState &); + private: MackieControlProtocol & _mcp; port_type_t _port_type; diff --git a/libs/surfaces/mackie/surface_port.h b/libs/surfaces/mackie/surface_port.h index 91ca21c0b0..350ee561f6 100644 --- a/libs/surfaces/mackie/surface_port.h +++ b/libs/surfaces/mackie/surface_port.h @@ -65,9 +65,6 @@ public: MIDI::Port & output_port() { return *_output_port; } const MIDI::Port & output_port() const { return *_output_port; } - // all control notofications are sent from here - PBD::Signal3 control_event; - // emitted just before the port goes into initialisation // where it tries to establish that its device is connected PBD::Signal0 init_event; @@ -92,6 +89,8 @@ public: protected: /// Only for use by DummyPort SurfacePort(); + + virtual void control_event (SurfacePort &, Control &, const ControlState &) {} private: bool control_in_use_timeout (Control *, Control *);