From 69830c477e0c51f775b3c6e7923012dcdd2f6693 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Fri, 13 Apr 2012 21:46:26 +0000 Subject: MCP: catch noteOff to see note-on+velocity=zero messages; more GUI tweaks git-svn-id: svn://localhost/ardour2/branches/3.0@11966 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/surfaces/mackie/gui.cc | 93 +++++++++++++------------ libs/surfaces/mackie/gui.h | 8 ++- libs/surfaces/mackie/mackie_control_protocol.cc | 36 +++++++--- libs/surfaces/mackie/mackie_control_protocol.h | 3 +- libs/surfaces/mackie/strip.cc | 13 ++-- libs/surfaces/mackie/surface.cc | 2 + 6 files changed, 96 insertions(+), 59 deletions(-) (limited to 'libs') diff --git a/libs/surfaces/mackie/gui.cc b/libs/surfaces/mackie/gui.cc index 5cb3bf622e..1c62cf2d45 100644 --- a/libs/surfaces/mackie/gui.cc +++ b/libs/surfaces/mackie/gui.cc @@ -96,6 +96,19 @@ MackieControlProtocolGUI::MackieControlProtocolGUI (MackieControlProtocol& p) function_key_scroller.show_all(); } +CellRendererCombo* +MackieControlProtocolGUI::make_action_renderer (Glib::RefPtr model, Gtk::TreeModelColumnBase column) +{ + CellRendererCombo* renderer = manage (new CellRendererCombo); + renderer->property_model() = model; + renderer->property_editable() = true; + renderer->property_text_column() = 0; + renderer->property_has_entry() = false; + renderer->signal_edited().connect (sigc::bind (sigc::mem_fun(*this, &MackieControlProtocolGUI::action_changed), column)); + + return renderer; +} + void MackieControlProtocolGUI::rebuild_function_key_editor () { @@ -182,37 +195,38 @@ MackieControlProtocolGUI::rebuild_function_key_editor () function_key_editor.append_column (_("Key"), function_key_columns.name); - CellRendererCombo* action_renderer = manage (new CellRendererCombo); - action_renderer->property_model() = available_action_model; - action_renderer->property_editable() = true; - action_renderer->property_text_column() = 0; - action_renderer->property_has_entry() = false; - action_renderer->signal_edited().connect (sigc::mem_fun(*this, &MackieControlProtocolGUI::action_changed)); TreeViewColumn* col; + CellRendererCombo* renderer; - col = manage (new TreeViewColumn (_("Plain"), *action_renderer)); - col->add_attribute (action_renderer->property_text(), function_key_columns.plain); + renderer = make_action_renderer (available_action_model, function_key_columns.plain); + col = manage (new TreeViewColumn (_("Plain"), *renderer)); + col->add_attribute (renderer->property_text(), function_key_columns.plain); function_key_editor.append_column (*col); - col = manage (new TreeViewColumn (_("Shift"), *action_renderer)); - col->add_attribute (action_renderer->property_text(), function_key_columns.shift); + renderer = make_action_renderer (available_action_model, function_key_columns.shift); + col = manage (new TreeViewColumn (_("Shift"), *renderer)); + col->add_attribute (renderer->property_text(), function_key_columns.shift); function_key_editor.append_column (*col); - col = manage (new TreeViewColumn (_("Control"), *action_renderer)); - col->add_attribute (action_renderer->property_text(), function_key_columns.control); + renderer = make_action_renderer (available_action_model, function_key_columns.control); + col = manage (new TreeViewColumn (_("Control"), *renderer)); + col->add_attribute (renderer->property_text(), function_key_columns.control); function_key_editor.append_column (*col); - col = manage (new TreeViewColumn (_("Option"), *action_renderer)); - col->add_attribute (action_renderer->property_text(), function_key_columns.option); + renderer = make_action_renderer (available_action_model, function_key_columns.option); + col = manage (new TreeViewColumn (_("Option"), *renderer)); + col->add_attribute (renderer->property_text(), function_key_columns.option); function_key_editor.append_column (*col); - col = manage (new TreeViewColumn (_("Cmd/Alt"), *action_renderer)); - col->add_attribute (action_renderer->property_text(), function_key_columns.cmdalt); + renderer = make_action_renderer (available_action_model, function_key_columns.cmdalt); + col = manage (new TreeViewColumn (_("Cmd/Alt"), *renderer)); + col->add_attribute (renderer->property_text(), function_key_columns.cmdalt); function_key_editor.append_column (*col); - col = manage (new TreeViewColumn (_("Shift+Control"), *action_renderer)); - col->add_attribute (action_renderer->property_text(), function_key_columns.shiftcontrol); + renderer = make_action_renderer (available_action_model, function_key_columns.shiftcontrol); + col = manage (new TreeViewColumn (_("Shift+Control"), *renderer)); + col->add_attribute (renderer->property_text(), function_key_columns.shiftcontrol); function_key_editor.append_column (*col); /* now fill with data */ @@ -221,41 +235,32 @@ MackieControlProtocolGUI::rebuild_function_key_editor () TreeModel::Row row; - row = *(function_key_model->append()); - row[function_key_columns.name] = "F1"; - row[function_key_columns.number] = 0; - row = *(function_key_model->append()); - row[function_key_columns.name] = "F2"; - row[function_key_columns.number] = 1; - row = *(function_key_model->append()); - row[function_key_columns.name] = "F3"; - row[function_key_columns.number] = 2; - row = *(function_key_model->append()); - row[function_key_columns.name] = "F4"; - row[function_key_columns.number] = 3; - row = *(function_key_model->append()); - row[function_key_columns.name] = "F5"; - row[function_key_columns.number] = 4; - row = *(function_key_model->append()); - row[function_key_columns.name] = "F6"; - row[function_key_columns.number] = 5; - row = *(function_key_model->append()); - row[function_key_columns.name] = "F7"; - row[function_key_columns.number] = 6; - row = *(function_key_model->append()); - row[function_key_columns.name] = "F8"; - row[function_key_columns.number] = 7; + for (uint32_t n = 0; n < 16; ++n) { + + row = *(function_key_model->append()); + row[function_key_columns.name] = string_compose ("F%1", n+1); + row[function_key_columns.number] = n; + row[function_key_columns.control] = "c"; + row[function_key_columns.option] = "o"; + row[function_key_columns.shift] = "s"; + row[function_key_columns.cmdalt] = "ca"; + row[function_key_columns.shiftcontrol] = "sc"; + } function_key_editor.set_model (function_key_model); } void -MackieControlProtocolGUI::action_changed (const Glib::ustring &sPath, const Glib::ustring &text) +MackieControlProtocolGUI::action_changed (const Glib::ustring &sPath, const Glib::ustring &text, TreeModelColumnBase col) { Gtk::TreePath path(sPath); Gtk::TreeModel::iterator row = function_key_model->get_iter(path); - cerr << sPath << " changed to " << text << endl; + cerr << sPath << '-' << col.index() << " changed to " << text << endl; + + if (row) { + (*row).set_value (col.index(), text); + } } void diff --git a/libs/surfaces/mackie/gui.h b/libs/surfaces/mackie/gui.h index b828253483..16a4c426ff 100644 --- a/libs/surfaces/mackie/gui.h +++ b/libs/surfaces/mackie/gui.h @@ -16,6 +16,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + #include #include #include @@ -25,6 +26,10 @@ #include #include +namespace Gtk { + class CellRendererCombo; +} + class MackieControlProtocol; #include "i18n.h" @@ -79,6 +84,7 @@ class MackieControlProtocolGUI : public Gtk::Notebook Glib::RefPtr available_action_model; void rebuild_function_key_editor (); - void action_changed (const Glib::ustring &sPath, const Glib::ustring &text); + void action_changed (const Glib::ustring &sPath, const Glib::ustring &text, Gtk::TreeModelColumnBase); + Gtk::CellRendererCombo* make_action_renderer (Glib::RefPtr model, Gtk::TreeModelColumnBase); }; diff --git a/libs/surfaces/mackie/mackie_control_protocol.cc b/libs/surfaces/mackie/mackie_control_protocol.cc index bde43b6c50..7da976cab8 100644 --- a/libs/surfaces/mackie/mackie_control_protocol.cc +++ b/libs/surfaces/mackie/mackie_control_protocol.cc @@ -49,6 +49,7 @@ #include "ardour/route.h" #include "ardour/session.h" #include "ardour/tempo.h" +#include "ardour/track.h" #include "ardour/types.h" #include "ardour/audioengine.h" @@ -1189,15 +1190,19 @@ MackieControlProtocol::transport_frame() const void MackieControlProtocol::add_down_select_button (int surface, int strip) { - _down_select_buttons.push_back ((surface<<8)|(strip&0xf)); + _down_select_buttons.insert ((surface<<8)|(strip&0xf)); } void MackieControlProtocol::remove_down_select_button (int surface, int strip) { - list::iterator x = find (_down_select_buttons.begin(), _down_select_buttons.end(), (surface<<8)|(strip&0xf)); + DownButtonList::iterator x = find (_down_select_buttons.begin(), _down_select_buttons.end(), (surface<<8)|(strip&0xf)); + DEBUG_TRACE (DEBUG::MackieControl, string_compose ("removing surface %1 strip %2 from down select buttons\n", surface, strip)); if (x != _down_select_buttons.end()) { _down_select_buttons.erase (x); + } else { + DEBUG_TRACE (DEBUG::MackieControl, string_compose ("surface %1 strip %2 not found in down select buttons\n", + surface, strip)); } } @@ -1230,7 +1235,7 @@ MackieControlProtocol::add_down_button (AutomationType a, int surface, int strip _down_buttons[a] = DownButtonList(); } - _down_buttons[a].push_back ((surface<<8)|(strip&0xf)); + _down_buttons[a].insert ((surface<<8)|(strip&0xf)); } void @@ -1238,15 +1243,20 @@ MackieControlProtocol::remove_down_button (AutomationType a, int surface, int st { DownButtonMap::iterator m = _down_buttons.find (a); + DEBUG_TRACE (DEBUG::MackieControl, string_compose ("removing surface %1 strip %2 from down buttons for %3\n", surface, strip, (int) a)); + if (m == _down_buttons.end()) { return; } DownButtonList& l (m->second); - list::iterator x = find (l.begin(), l.end(), (surface<<8)|(strip&0xf)); + DownButtonList::iterator x = find (l.begin(), l.end(), (surface<<8)|(strip&0xf)); if (x != l.end()) { l.erase (x); + } else { + DEBUG_TRACE (DEBUG::MackieControl, string_compose ("surface %1 strip %2 not found in down buttons for %3\n", + surface, strip, (int) a)); } } @@ -1283,6 +1293,14 @@ MackieControlProtocol::down_controls (AutomationType p) controls.push_back ((*r)->mute_control()); } break; + case RecEnableAutomation: + for (RouteList::iterator r = routes.begin(); r != routes.end(); ++r) { + boost::shared_ptr trk = boost::dynamic_pointer_cast (*r); + if (trk) { + controls.push_back (trk->rec_enable_control()); + } + } + break; default: break; } @@ -1300,7 +1318,7 @@ struct ButtonRangeSorter { }; void -MackieControlProtocol::pull_route_range (list& down, RouteList& selected) +MackieControlProtocol::pull_route_range (DownButtonList& down, RouteList& selected) { ButtonRangeSorter cmp; @@ -1308,10 +1326,12 @@ MackieControlProtocol::pull_route_range (list& down, RouteList& select return; } - down.sort (cmp); + list ldown; + ldown.insert (ldown.end(), down.begin(), down.end()); + ldown.sort (cmp); - uint32_t first = down.front(); - uint32_t last = down.back (); + uint32_t first = ldown.front(); + uint32_t last = ldown.back (); uint32_t first_surface = first>>8; uint32_t first_strip = first&0xf; diff --git a/libs/surfaces/mackie/mackie_control_protocol.h b/libs/surfaces/mackie/mackie_control_protocol.h index 18919954c4..45c16cc50d 100644 --- a/libs/surfaces/mackie/mackie_control_protocol.h +++ b/libs/surfaces/mackie/mackie_control_protocol.h @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -295,7 +296,7 @@ class MackieControlProtocol /* BUTTON HANDLING */ - typedef std::list DownButtonList; + typedef std::set DownButtonList; typedef std::map DownButtonMap; DownButtonMap _down_buttons; DownButtonList _down_select_buttons; diff --git a/libs/surfaces/mackie/strip.cc b/libs/surfaces/mackie/strip.cc index 0f930c17e7..43d5c63e87 100644 --- a/libs/surfaces/mackie/strip.cc +++ b/libs/surfaces/mackie/strip.cc @@ -297,7 +297,7 @@ Strip::notify_gain_changed (bool force_update) do_parameter_display (GainAutomation, pos); } - queue_display_reset (3000); + queue_display_reset (2000); _last_gain_position_written = pos; } else { @@ -369,7 +369,7 @@ Strip::notify_panner_changed (bool force_update) do_parameter_display (PanAzimuthAutomation, pos); } - queue_display_reset (3000); + queue_display_reset (2000); _last_pan_position_written = pos; } } @@ -385,7 +385,7 @@ Strip::handle_button (Button& button, ButtonState bs) button.set_in_use (false); } - DEBUG_TRACE (DEBUG::MackieControl, string_compose ("strip %1 handling button %2\n", _index, button.id())); + DEBUG_TRACE (DEBUG::MackieControl, string_compose ("strip %1 handling button %2 press ? %3\n", _index, button.id(), (bs == press))); int lock_mod = (MackieControlProtocol::MODIFIER_CONTROL|MackieControlProtocol::MODIFIER_SHIFT); int ms = _surface->mcp().modifier_state(); @@ -430,11 +430,14 @@ Strip::handle_button (Button& button, ButtonState bs) boost::shared_ptr ac = _fader->control (false); if (ac) { do_parameter_display ((AutomationType) ac->parameter().type(), ac->internal_to_interface (ac->get_value())); - queue_display_reset (3000); + queue_display_reset (2000); } + } else { + _fader->set_in_use (false); _fader->stop_touch (_surface->mcp().transport_frame(), true, false); + } return; @@ -524,7 +527,7 @@ Strip::handle_fader (Fader& fader, float position) fader.set_value (position, modified); fader.start_touch (_surface->mcp().transport_frame(), modified); - queue_display_reset (3000); + queue_display_reset (2000); // must echo bytes back to slider now, because // the notifier only works if the fader is not being diff --git a/libs/surfaces/mackie/surface.cc b/libs/surfaces/mackie/surface.cc index 4374ae2d30..171ac92d8d 100644 --- a/libs/surfaces/mackie/surface.cc +++ b/libs/surfaces/mackie/surface.cc @@ -319,6 +319,8 @@ Surface::connect_to_signals () p->controller.connect_same_thread (*this, boost::bind (&Surface::handle_midi_controller_message, this, _1, _2)); /* Button messages are NoteOn */ p->note_on.connect_same_thread (*this, boost::bind (&Surface::handle_midi_note_on_message, this, _1, _2)); + /* Button messages are NoteOn. libmidi++ sends note-on w/velocity = 0 as note-off so catch them too */ + p->note_off.connect_same_thread (*this, boost::bind (&Surface::handle_midi_note_on_message, this, _1, _2)); /* Fader messages are Pitchbend */ p->channel_pitchbend[0].connect_same_thread (*this, boost::bind (&Surface::handle_midi_pitchbend_message, this, _1, _2, 0U)); p->channel_pitchbend[1].connect_same_thread (*this, boost::bind (&Surface::handle_midi_pitchbend_message, this, _1, _2, 1U)); -- cgit v1.2.3