From 17b442971bfa7eee99dad5287054ffbe9b5d9bf0 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 12 Apr 2012 17:52:57 +0000 Subject: [PATCH] MCP: more surface properties, correctly close IOSources when switching surfaces; write select button msgs one by one, change port name back to generic terms git-svn-id: svn://localhost/ardour2/branches/3.0@11945 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/surfaces/mackie/device_info.cc | 26 +++++++++++++++ libs/surfaces/mackie/device_info.h | 4 +++ .../mackie/mackie_control_protocol.cc | 8 ++--- libs/surfaces/mackie/surface.cc | 33 +++++++------------ libs/surfaces/mackie/surface.h | 2 +- mcp_devices/mcpro.xml | 1 + mcp_devices/nucleus.xml | 1 + 7 files changed, 48 insertions(+), 27 deletions(-) diff --git a/libs/surfaces/mackie/device_info.cc b/libs/surfaces/mackie/device_info.cc index d0e120ea95..88ea659fdf 100644 --- a/libs/surfaces/mackie/device_info.cc +++ b/libs/surfaces/mackie/device_info.cc @@ -45,6 +45,8 @@ DeviceInfo::DeviceInfo() , _has_master_fader (true) , _has_segmented_display (false) , _has_timecode_display (true) + , _has_global_controls (true) + , _has_jog_wheel (true) , _name (X_("Mackie Control Universal Pro")) { @@ -114,6 +116,18 @@ DeviceInfo::set_state (const XMLNode& node, int /* version */) } } + if ((child = node.child ("GlobalControls")) != 0) { + if ((prop = child->property ("value")) != 0) { + _has_global_controls = string_is_affirmative (prop->value()); + } + } + + if ((child = node.child ("JogWheel")) != 0) { + if ((prop = child->property ("value")) != 0) { + _has_jog_wheel = string_is_affirmative (prop->value()); + } + } + return 0; } @@ -159,6 +173,18 @@ DeviceInfo::has_timecode_display () const return _has_timecode_display; } +bool +DeviceInfo::has_global_controls () const +{ + return _has_global_controls; +} + +bool +DeviceInfo::has_jog_wheel () const +{ + return _has_jog_wheel; +} + static const char * const devinfo_env_variable_name = "ARDOUR_MCP_DEVINFO_PATH"; static const char* const devinfo_dir_name = "mcp_devices"; static const char* const devinfo_suffix = ".xml"; diff --git a/libs/surfaces/mackie/device_info.h b/libs/surfaces/mackie/device_info.h index f605237510..60d2832435 100644 --- a/libs/surfaces/mackie/device_info.h +++ b/libs/surfaces/mackie/device_info.h @@ -43,6 +43,8 @@ class DeviceInfo bool has_master_fader () const; bool has_segmented_display() const; bool has_timecode_display() const; + bool has_global_controls() const; + bool has_jog_wheel () const; const std::string& name() const; static std::map device_info; @@ -55,6 +57,8 @@ class DeviceInfo bool _has_master_fader; bool _has_segmented_display; bool _has_timecode_display; + bool _has_global_controls; + bool _has_jog_wheel; std::string _name; }; diff --git a/libs/surfaces/mackie/mackie_control_protocol.cc b/libs/surfaces/mackie/mackie_control_protocol.cc index dc57b052d6..490e7eef20 100644 --- a/libs/surfaces/mackie/mackie_control_protocol.cc +++ b/libs/surfaces/mackie/mackie_control_protocol.cc @@ -354,7 +354,6 @@ MackieControlProtocol::set_active (bool yn) create_surfaces (); connect_session_signals (); - _active = true; update_surfaces (); @@ -508,6 +507,7 @@ MackieControlProtocol::set_device (const string& device_name) _device_info = d->second; if (_active) { + clear_ports (); surfaces.clear (); create_surfaces (); switch_banks (0, true); @@ -517,9 +517,8 @@ MackieControlProtocol::set_device (const string& device_name) void MackieControlProtocol::create_surfaces () { - string device_name = _device_info.name(); + string device_name = X_("MC Main"); surface_type_t stype = mcu; - char buf[128]; DEBUG_TRACE (DEBUG::MackieControl, string_compose ("Create %1 surfaces\n", 1 + _device_info.extenders())); @@ -530,8 +529,7 @@ MackieControlProtocol::create_surfaces () /* next device will be an extender */ - snprintf (buf, sizeof (buf), "%s XT%d", _device_info.name().c_str(), n+1); - device_name = buf; + device_name = X_("MC Extender"); stype = ext; _input_bundle->add_channel ( diff --git a/libs/surfaces/mackie/surface.cc b/libs/surfaces/mackie/surface.cc index b056d7b2ec..91162c7962 100644 --- a/libs/surfaces/mackie/surface.cc +++ b/libs/surfaces/mackie/surface.cc @@ -138,23 +138,18 @@ Surface::Surface (MackieControlProtocol& mcp, const std::string& device_name, ui _port = new SurfacePort (*this); - switch (stype) { - case mcu: + if (_mcp.device_info().has_global_controls()) { init_controls (); + } + + if (_mcp.device_info().has_jog_wheel()) { _jog_wheel = new Mackie::JogWheel (_mcp); - break; - default: - break; } - switch (stype) { - case mcu: - case ext: - strips.resize (8); - init_strips (); - break; - default: - break; + uint32_t n = _mcp.device_info().strip_cnt(); + + if (n) { + init_strips (n); } connect_to_signals (); @@ -237,9 +232,9 @@ static StripControlDefinition mackie_strip_controls[] = { }; void -Surface::init_strips () +Surface::init_strips (uint32_t n) { - for (uint32_t i = 0; i < 8; ++i) { + for (uint32_t i = 0; i < n; ++i) { char name[32]; @@ -248,7 +243,7 @@ Surface::init_strips () Strip* strip = new Strip (*this, name, i, mackie_strip_controls); groups[name] = strip; - strips[i] = strip; + strips.push_back (strip); } } @@ -833,12 +828,8 @@ Surface::update_view_mode_display () void Surface::gui_selection_changed (ARDOUR::RouteNotificationListPtr routes) { - MidiByteArray msg; - for (Strips::iterator s = strips.begin(); s != strips.end(); ++s) { - msg << (*s)->gui_selection_changed (routes); + _port->write ((*s)->gui_selection_changed (routes)); } - - _port->write (msg); } diff --git a/libs/surfaces/mackie/surface.h b/libs/surfaces/mackie/surface.h index a105125a0c..8dd8792231 100644 --- a/libs/surfaces/mackie/surface.h +++ b/libs/surfaces/mackie/surface.h @@ -151,7 +151,7 @@ public: protected: void init_controls(); - void init_strips (); + void init_strips (uint32_t n); private: MackieControlProtocol& _mcp; diff --git a/mcp_devices/mcpro.xml b/mcp_devices/mcpro.xml index 3c034be937..9afc0bbc7d 100644 --- a/mcp_devices/mcpro.xml +++ b/mcp_devices/mcpro.xml @@ -8,4 +8,5 @@ + diff --git a/mcp_devices/nucleus.xml b/mcp_devices/nucleus.xml index c30fb3a1de..08886d38b6 100644 --- a/mcp_devices/nucleus.xml +++ b/mcp_devices/nucleus.xml @@ -8,4 +8,5 @@ + -- 2.30.2