diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2015-12-13 08:33:02 -0500 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2015-12-13 08:33:09 -0500 |
commit | 8bdab38d4315414e7c884dd80a3040a2283cdb9c (patch) | |
tree | 40d6515313813fae798e38c6550246a6b76637d6 /libs/surfaces | |
parent | 6e13b91a354ae1540a74cd305853f22b31864465 (diff) |
track add/remove of monitor and/or master busses in mackie support code.
Somehow fails to move master fader to correct position when monitor section is added
Diffstat (limited to 'libs/surfaces')
-rw-r--r-- | libs/surfaces/mackie/mackie_control_protocol.cc | 19 | ||||
-rw-r--r-- | libs/surfaces/mackie/mackie_control_protocol.h | 1 | ||||
-rw-r--r-- | libs/surfaces/mackie/surface.cc | 54 | ||||
-rw-r--r-- | libs/surfaces/mackie/surface.h | 3 |
4 files changed, 60 insertions, 17 deletions
diff --git a/libs/surfaces/mackie/mackie_control_protocol.cc b/libs/surfaces/mackie/mackie_control_protocol.cc index 966a2cbedd..a69c99e383 100644 --- a/libs/surfaces/mackie/mackie_control_protocol.cc +++ b/libs/surfaces/mackie/mackie_control_protocol.cc @@ -696,6 +696,7 @@ MackieControlProtocol::connect_session_signals() { // receive routes added session->RouteAdded.connect(session_connections, MISSING_INVALIDATOR, boost::bind (&MackieControlProtocol::notify_route_added, this, _1), this); + session->RouteAddedOrRemoved.connect(session_connections, MISSING_INVALIDATOR, boost::bind (&MackieControlProtocol::notify_route_added_or_removed, this), this); // receive record state toggled session->RecordStateChanged.connect(session_connections, MISSING_INVALIDATOR, boost::bind (&MackieControlProtocol::notify_record_state_changed, this), this); // receive transport state changed @@ -1190,6 +1191,15 @@ void MackieControlProtocol::notify_parameter_changed (std::string const & p) } } +void +MackieControlProtocol::notify_route_added_or_removed () +{ + Glib::Threads::Mutex::Lock lm (surfaces_lock); + for (Surfaces::iterator s = surfaces.begin(); s != surfaces.end(); ++s) { + (*s)->master_monitor_may_have_changed (); + } +} + // RouteList is the set of routes that have just been added void MackieControlProtocol::notify_route_added (ARDOUR::RouteList & rl) @@ -1202,6 +1212,15 @@ MackieControlProtocol::notify_route_added (ARDOUR::RouteList & rl) } } + /* special case: single route, and it is the monitor or master out */ + + if (rl.size() == 1 && (rl.front()->is_monitor() || rl.front()->is_master())) { + Glib::Threads::Mutex::Lock lm (surfaces_lock); + for (Surfaces::iterator s = surfaces.begin(); s != surfaces.end(); ++s) { + (*s)->master_monitor_may_have_changed (); + } + } + // currently assigned banks are less than the full set of // strips, so activate the new strip now. diff --git a/libs/surfaces/mackie/mackie_control_protocol.h b/libs/surfaces/mackie/mackie_control_protocol.h index f5db794251..1ce45ce82f 100644 --- a/libs/surfaces/mackie/mackie_control_protocol.h +++ b/libs/surfaces/mackie/mackie_control_protocol.h @@ -187,6 +187,7 @@ class MackieControlProtocol void handle_button_event (Mackie::Surface&, Mackie::Button& button, Mackie::ButtonState); + void notify_route_added_or_removed (); void notify_route_added (ARDOUR::RouteList &); void notify_remote_id_changed(); diff --git a/libs/surfaces/mackie/surface.cc b/libs/surfaces/mackie/surface.cc index f886a5f594..0082bd480f 100644 --- a/libs/surfaces/mackie/surface.cc +++ b/libs/surfaces/mackie/surface.cc @@ -364,6 +364,14 @@ Surface::init_strips (uint32_t n) } void +Surface::master_monitor_may_have_changed () +{ + std::cerr << "MMmhc\n"; + setup_master (); + std::cerr << " done\n"; +} + +void Surface::setup_master () { boost::shared_ptr<Route> m; @@ -373,28 +381,37 @@ Surface::setup_master () } if (!m) { + _master_fader->set_control (boost::shared_ptr<AutomationControl>()); + master_connection.disconnect (); return; } - _master_fader = dynamic_cast<Fader*> (Fader::factory (*this, _mcp.device_info().strip_cnt(), "master", *groups["master"])); + if (!_master_fader) { + _master_fader = dynamic_cast<Fader*> (Fader::factory (*this, _mcp.device_info().strip_cnt(), "master", *groups["master"])); + + Groups::iterator group_it; + group_it = groups.find("master"); + + DeviceInfo device_info = _mcp.device_info(); + GlobalButtonInfo master_button = device_info.get_global_button(Button::MasterFaderTouch); + Button* bb = dynamic_cast<Button*> (Button::factory ( + *this, + Button::MasterFaderTouch, + master_button.id, + master_button.label, + *(group_it->second) + )); + + DEBUG_TRACE (DEBUG::MackieControl, string_compose ("surface %1 Master Fader new button BID %2 id %3\n", + number(), Button::MasterFaderTouch, bb->id())); + } else { + master_connection.disconnect (); + } _master_fader->set_control (m->gain_control()); - m->gain_control()->Changed.connect (*this, MISSING_INVALIDATOR, boost::bind (&Surface::master_gain_changed, this), ui_context()); - - Groups::iterator group_it; - group_it = groups.find("master"); - - DeviceInfo device_info = _mcp.device_info(); - GlobalButtonInfo master_button = device_info.get_global_button(Button::MasterFaderTouch); - Button* bb = dynamic_cast<Button*> (Button::factory ( - *this, - Button::MasterFaderTouch, - master_button.id, - master_button.label, - *(group_it->second) -)); - DEBUG_TRACE (DEBUG::MackieControl, string_compose ("surface %1 Master Fader new button BID %2 id %3\n", - number(), Button::MasterFaderTouch, bb->id())); + m->gain_control()->Changed.connect (master_connection, MISSING_INVALIDATOR, boost::bind (&Surface::master_gain_changed, this), ui_context()); + _last_master_gain_written = FLT_MAX; /* some essentially impossible value */ + master_gain_changed (); } void @@ -406,6 +423,7 @@ Surface::master_gain_changed () boost::shared_ptr<AutomationControl> ac = _master_fader->control(); if (!ac) { + std::cerr << "no control!\n"; return; } @@ -416,6 +434,8 @@ Surface::master_gain_changed () DEBUG_TRACE (DEBUG::MackieControl, "Surface::master_gain_changed: updating surface master fader\n"); + std::cerr << "send " << normalized_position << std::endl; + _port->write (_master_fader->set_position (normalized_position)); _last_master_gain_written = normalized_position; } diff --git a/libs/surfaces/mackie/surface.h b/libs/surfaces/mackie/surface.h index 166b8ed4bf..78bb42ab6a 100644 --- a/libs/surfaces/mackie/surface.h +++ b/libs/surfaces/mackie/surface.h @@ -169,6 +169,8 @@ public: bool connection_handler (boost::weak_ptr<ARDOUR::Port>, std::string name1, boost::weak_ptr<ARDOUR::Port>, std::string name2, bool); + void master_monitor_may_have_changed (); + XMLNode& get_state (); int set_state (const XMLNode&, int version); @@ -183,6 +185,7 @@ public: Mackie::JogWheel* _jog_wheel; Fader* _master_fader; float _last_master_gain_written; + PBD::ScopedConnection master_connection; void handle_midi_sysex (MIDI::Parser&, MIDI::byte *, size_t count); MidiByteArray host_connection_query (MidiByteArray& bytes); |