{
// 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
}
}
+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)
}
}
+ /* 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.
}
}
+void
+Surface::master_monitor_may_have_changed ()
+{
+ std::cerr << "MMmhc\n";
+ setup_master ();
+ std::cerr << " done\n";
+}
+
void
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
boost::shared_ptr<AutomationControl> ac = _master_fader->control();
if (!ac) {
+ std::cerr << "no control!\n";
return;
}
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;
}
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);
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);