diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2012-04-26 16:18:03 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2012-04-26 16:18:03 +0000 |
commit | 834f94c60a7f6ff2b0695096e9dbcd340dbca3af (patch) | |
tree | dece708d97110d03dad26e5bab686f3c1b32f7ee | |
parent | 3b7e2f7d67ad87bfb0ce183c10e9d00e71b6b085 (diff) |
fix initialization of control protocols so that brand new sessions get working control protocols if the user's ardour.rc file indicates to do so; fix MCP bank scrolling
git-svn-id: svn://localhost/ardour2/branches/3.0@12096 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r-- | libs/ardour/control_protocol_manager.cc | 11 | ||||
-rw-r--r-- | libs/surfaces/mackie/device_profile.cc | 2 | ||||
-rw-r--r-- | libs/surfaces/mackie/gui.cc | 1 | ||||
-rw-r--r-- | libs/surfaces/mackie/mackie_control_protocol.cc | 21 | ||||
-rw-r--r-- | libs/surfaces/mackie/mackie_control_protocol.h | 2 | ||||
-rw-r--r-- | libs/surfaces/mackie/mcp_buttons.cc | 41 | ||||
-rw-r--r-- | libs/surfaces/mackie/strip.cc | 3 | ||||
-rw-r--r-- | libs/surfaces/mackie/surface.cc | 4 |
8 files changed, 36 insertions, 49 deletions
diff --git a/libs/ardour/control_protocol_manager.cc b/libs/ardour/control_protocol_manager.cc index c72d3f31d0..6aa0c51da2 100644 --- a/libs/ardour/control_protocol_manager.cc +++ b/libs/ardour/control_protocol_manager.cc @@ -41,7 +41,6 @@ const string ControlProtocolManager::state_node_name = X_("ControlProtocols"); ControlProtocolManager::ControlProtocolManager () { - } ControlProtocolManager::~ControlProtocolManager() @@ -320,13 +319,15 @@ ControlProtocolManager::set_state (const XMLNode& node, int /*version*/) if (prop && string_is_affirmative (prop->value())) { if ((prop = (*citer)->property (X_("name"))) != 0) { ControlProtocolInfo* cpi = cpi_by_name (prop->value()); + if (cpi) { - if (!(*citer)->children().empty()) { - cpi->state = (*citer)->children().front (); - } else { - cpi->state = 0; + + if (cpi->state) { + delete cpi->state; } + cpi->state = new XMLNode (**citer); + if (_session) { instantiate (*cpi); } else { diff --git a/libs/surfaces/mackie/device_profile.cc b/libs/surfaces/mackie/device_profile.cc index 04975270ab..110038ca2b 100644 --- a/libs/surfaces/mackie/device_profile.cc +++ b/libs/surfaces/mackie/device_profile.cc @@ -120,8 +120,6 @@ DeviceProfile::reload_device_profiles () XMLTree tree; - std::cerr << "Loading " << fullpath << std::endl; - if (!tree.read (fullpath.c_str())) { continue; } diff --git a/libs/surfaces/mackie/gui.cc b/libs/surfaces/mackie/gui.cc index adaf2df945..8728b4a88c 100644 --- a/libs/surfaces/mackie/gui.cc +++ b/libs/surfaces/mackie/gui.cc @@ -84,6 +84,7 @@ MackieControlProtocolGUI::MackieControlProtocolGUI (MackieControlProtocol& p) table->set_row_spacings (4); table->set_col_spacings (6); l = manage (new Gtk::Label (_("Device Type:"))); + l->set_alignment (1.0, 0.5); table->attach (*l, 0, 1, 0, 1, AttachOptions(FILL|EXPAND), AttachOptions(0)); table->attach (_surface_combo, 1, 2, 0, 1, AttachOptions(FILL|EXPAND), AttachOptions(0), 0, 20); diff --git a/libs/surfaces/mackie/mackie_control_protocol.cc b/libs/surfaces/mackie/mackie_control_protocol.cc index 78fed5cb82..c1f5317976 100644 --- a/libs/surfaces/mackie/mackie_control_protocol.cc +++ b/libs/surfaces/mackie/mackie_control_protocol.cc @@ -321,13 +321,6 @@ MackieControlProtocol::switch_banks (uint32_t initial, bool force) return; } - uint32_t delta = sorted.size() - strip_cnt; - - if (delta > 0 && initial > delta) { - DEBUG_TRACE (DEBUG::MackieControl, string_compose ("not switching to %1\n", initial)); - return; - } - _current_initial_bank = initial; _current_selected_track = -1; @@ -548,7 +541,7 @@ MackieControlProtocol::set_profile (const string& profile_name) } void -MackieControlProtocol::set_device (const string& device_name) +MackieControlProtocol::set_device (const string& device_name, bool allow_activation) { map<string,DeviceInfo>::iterator d = DeviceInfo::device_info.find (device_name); @@ -563,9 +556,13 @@ MackieControlProtocol::set_device (const string& device_name) _device_info = d->second; - if (_active) { - create_surfaces (); - switch_banks (0, true); + if (allow_activation) { + set_active (true); + } else { + if (_active) { + create_surfaces (); + switch_banks (0, true); + } } } @@ -691,7 +688,7 @@ MackieControlProtocol::set_state (const XMLNode & node, int /*version*/) } if ((prop = node.property (X_("device-name"))) != 0) { - set_device (prop->value()); + set_device (prop->value(), false); } if ((prop = node.property (X_("device-profile"))) != 0) { diff --git a/libs/surfaces/mackie/mackie_control_protocol.h b/libs/surfaces/mackie/mackie_control_protocol.h index 801434c30c..0df770b36e 100644 --- a/libs/surfaces/mackie/mackie_control_protocol.h +++ b/libs/surfaces/mackie/mackie_control_protocol.h @@ -122,7 +122,7 @@ class MackieControlProtocol Mackie::DeviceProfile& device_profile() { return _device_profile; } int set_active (bool yn); - void set_device (const std::string&); + void set_device (const std::string&, bool allow_activation = true); void set_profile (const std::string&); bool flip_mode () const { return _flip_mode; } diff --git a/libs/surfaces/mackie/mcp_buttons.cc b/libs/surfaces/mackie/mcp_buttons.cc index f8ebedb7b9..6ded9a9d20 100644 --- a/libs/surfaces/mackie/mcp_buttons.cc +++ b/libs/surfaces/mackie/mcp_buttons.cc @@ -17,6 +17,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include <algorithm> + #include "pbd/memento_command.h" #include "ardour/debug.h" @@ -94,25 +96,22 @@ LedState MackieControlProtocol::left_press (Button &) { Sorted sorted = get_sorted_routes(); - uint32_t strip_cnt = n_strips (); + uint32_t strip_cnt = n_strips (); + uint32_t route_cnt = sorted.size(); DEBUG_TRACE (DEBUG::MackieControl, string_compose ("bank left with current initial = %1 nstrips = %2 tracks/busses = %3\n", - _current_initial_bank, strip_cnt, sorted.size())); + _current_initial_bank, strip_cnt, route_cnt)); - if (sorted.size() > strip_cnt) { - int new_initial = _current_initial_bank - strip_cnt; - if (new_initial < 0) { - new_initial = 0; - } - - if (new_initial != int (_current_initial_bank)) { - switch_banks (new_initial); + if (route_cnt && route_cnt > strip_cnt) { + if (_current_initial_bank > strip_cnt) { + switch_banks (_current_initial_bank - strip_cnt); + } else { + switch_banks (0); } return on; - } else { - return flashing; } + return off; } LedState @@ -126,25 +125,17 @@ MackieControlProtocol::right_press (Button &) { Sorted sorted = get_sorted_routes(); uint32_t strip_cnt = n_strips(); + uint32_t route_cnt = sorted.size(); DEBUG_TRACE (DEBUG::MackieControl, string_compose ("bank right with current initial = %1 nstrips = %2 tracks/busses = %3\n", _current_initial_bank, strip_cnt, sorted.size())); - if (sorted.size() > strip_cnt) { - uint32_t delta = sorted.size() - (strip_cnt + _current_initial_bank); - - if (delta > strip_cnt) { - delta = strip_cnt; - } - - if (delta > 0) { - switch_banks (_current_initial_bank + delta); - } - + if (route_cnt && route_cnt > strip_cnt) { + uint32_t new_initial = std::min (_current_initial_bank + strip_cnt, route_cnt - 1); + switch_banks (new_initial); return on; - } else { - return flashing; } + return off; } diff --git a/libs/surfaces/mackie/strip.cc b/libs/surfaces/mackie/strip.cc index 76fcc25a6c..af859ab41d 100644 --- a/libs/surfaces/mackie/strip.cc +++ b/libs/surfaces/mackie/strip.cc @@ -151,6 +151,7 @@ Strip::set_route (boost::shared_ptr<Route> r, bool with_messages) reset_saved_values (); if (!r) { + zero (); return; } @@ -213,8 +214,6 @@ Strip::set_route (boost::shared_ptr<Route> r, bool with_messages) if ((a = automatable.find (PanWidthAutomation)) != automatable.end()) { possible_pot_parameters.push_back (PanWidthAutomation); } - } else { - std::cerr << "connected to route without a panner\n"; } } } diff --git a/libs/surfaces/mackie/surface.cc b/libs/surfaces/mackie/surface.cc index f27ac3893e..fecc4d5a33 100644 --- a/libs/surfaces/mackie/surface.cc +++ b/libs/surfaces/mackie/surface.cc @@ -606,9 +606,9 @@ void Surface::map_routes (const vector<boost::shared_ptr<Route> >& routes) { vector<boost::shared_ptr<Route> >::const_iterator r; - Strips::iterator s; + Strips::iterator s = strips.begin(); - for (r = routes.begin(), s = strips.begin(); r != routes.end() && s != strips.end(); ++s) { + for (r = routes.begin(); r != routes.end() && s != strips.end(); ++s) { /* don't try to assign routes to a locked strip. it won't use it anyway, but if we do, then we get out of sync |