MCP: lots of good stuff - recenable bug fixed, cursor keys for vertical scroll work...
authorPaul Davis <paul@linuxaudiosystems.com>
Thu, 26 Apr 2012 03:46:18 +0000 (03:46 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Thu, 26 Apr 2012 03:46:18 +0000 (03:46 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@12093 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/editor.cc
gtk2_ardour/editor.h
libs/surfaces/control_protocol/control_protocol.cc
libs/surfaces/control_protocol/control_protocol/control_protocol.h
libs/surfaces/mackie/mackie_control_protocol.cc
libs/surfaces/mackie/mcp_buttons.cc
libs/surfaces/mackie/pot.cc
libs/surfaces/mackie/strip.cc
libs/surfaces/mackie/strip.h
libs/surfaces/mackie/surface.cc

index dbc57ea0778bed51b9e41590fc58054988b949b4..b7f768adcae366523ac062d2868e9e72d1432464 100644 (file)
@@ -709,6 +709,8 @@ Editor::Editor ()
        ControlProtocol::Undo.connect (*this, invalidator (*this), boost::bind (&Editor::undo, this, true), gui_context());
        ControlProtocol::Redo.connect (*this, invalidator (*this), boost::bind (&Editor::redo, this, true), gui_context());
        ControlProtocol::ScrollTimeline.connect (*this, invalidator (*this), boost::bind (&Editor::control_scroll, this, _1), gui_context());
+       ControlProtocol::StepTracksUp.connect (*this, invalidator (*this), boost::bind (&Editor::control_step_tracks_up, this), gui_context());
+       ControlProtocol::StepTracksDown.connect (*this, invalidator (*this), boost::bind (&Editor::control_step_tracks_down, this), gui_context());
        ControlProtocol::GotoView.connect (*this, invalidator (*this), boost::bind (&Editor::control_view, this, _1), gui_context());
        ControlProtocol::CloseDialog.connect (*this, invalidator (*this), Keyboard::close_current_dialog, gui_context());
        ControlProtocol::VerticalZoomInAll.connect (*this, invalidator (*this), boost::bind (&Editor::control_vertical_zoom_in_all, this), gui_context());
@@ -1003,6 +1005,18 @@ Editor::control_select (uint32_t rid, Selection::Operation op)
        }
 }
 
+void
+Editor::control_step_tracks_up ()
+{
+       scroll_tracks_up_line ();
+}
+
+void
+Editor::control_step_tracks_down ()
+{
+       scroll_tracks_down_line ();
+}
+
 void
 Editor::control_scroll (float fraction)
 {
index 587c2c5b7c75df0f4ea2c08dc9000bc149c5325f..589b0ead6c09d54b5bd86bb922a4099d580b9771 100644 (file)
@@ -978,6 +978,8 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        void control_vertical_zoom_out_all ();
        void control_vertical_zoom_in_selected ();
        void control_vertical_zoom_out_selected ();
+       void control_step_tracks_up ();
+       void control_step_tracks_down ();
        void control_view (uint32_t);
        void control_scroll (float);
        void control_select (uint32_t rid, Selection::Operation);
index 1868957d3fea8393d7593688302b7b2d8687156c..ec58dc2f2115e4f3968874f071750d9cdaffb0a2 100644 (file)
@@ -49,6 +49,8 @@ PBD::Signal1<void,uint32_t> ControlProtocol::AddRouteToSelection;
 PBD::Signal1<void,uint32_t> ControlProtocol::SetRouteSelection;
 PBD::Signal1<void,uint32_t> ControlProtocol::RemoveRouteFromSelection;
 PBD::Signal0<void>          ControlProtocol::ClearRouteSelection;
+PBD::Signal0<void>          ControlProtocol::StepTracksDown;
+PBD::Signal0<void>          ControlProtocol::StepTracksUp;
 
 ControlProtocol::ControlProtocol (Session& s, string str)
        : BasicUI (s)
index fc45f1e92a4e58237f4ea42903fdf244bc0d0bcd..b75a04db2a6d4817fa7540b9f2d99b56dddfcafe 100644 (file)
@@ -73,6 +73,8 @@ class ControlProtocol : public PBD::Stateful, public PBD::ScopedConnectionList,
        static PBD::Signal0<void> VerticalZoomOutAll;
        static PBD::Signal0<void> VerticalZoomInSelected;
        static PBD::Signal0<void> VerticalZoomOutSelected;
+       static PBD::Signal0<void> StepTracksDown;
+       static PBD::Signal0<void> StepTracksUp;
 
        static PBD::Signal1<void,uint32_t> AddRouteToSelection;
        static PBD::Signal1<void,uint32_t> SetRouteSelection;
index 93202f607b198d6bb60b0482f838c17acee7c9db..82e9ea6df22cd753f5ebe43fdd2781b248d79d96 100644 (file)
@@ -863,6 +863,7 @@ void
 MackieControlProtocol::notify_transport_state_changed()
 {
        // switch various play and stop buttons on / off
+       update_global_button (Button::Loop, session->get_play_loop());
        update_global_button (Button::Play, session->transport_speed() == 1.0);
        update_global_button (Button::Stop, !session->transport_rolling());
        update_global_button (Button::Rewind, session->transport_speed() < 0.0);
index 576267d09de35cef31f9b135085b3cc5a663428a..f8ebedb7b923b133048ab0dcb6b8e10b320ca93d 100644 (file)
@@ -236,6 +236,8 @@ MackieControlProtocol::cursor_up_press (Button&)
                } else {
                        VerticalZoomInAll (); /* EMIT SIGNAL */
                }
+       } else {
+               StepTracksUp (); /* EMIT SIGNAL */
        }
        return off;
 }
@@ -255,6 +257,8 @@ MackieControlProtocol::cursor_down_press (Button&)
                } else {
                        VerticalZoomOutAll (); /* EMIT SIGNAL */
                }
+       } else {
+               StepTracksDown (); /* EMIT SIGNAL */
        }
        return off;
 }
index 78973b40df6bd7bb88c697552297425ba35943e3..838753bf31a0ef35eb101454105771f63c6aac66 100644 (file)
@@ -42,19 +42,18 @@ Pot::set (float val, bool onoff, Mode mode)
 {
        // TODO do an exact calc for 0.50? To allow manually re-centering the port.
 
-       // center on or off
-       MIDI::byte msg =  (val > 0.45 && val < 0.55 ? 1 : 0) << 6;
+       // center on if val is "very close" to 0.50
+       MIDI::byte msg =  (val > 0.48 && val < 0.58 ? 1 : 0) << 6;
        
-       // mode
+       // Pot/LED mode
        msg |=  (mode << 4);
        
        // val, but only if off hasn't explicitly been set
-
-       if  (onoff) {
+       if (onoff) {
                if (mode == spread) {
-                       msg +=  (lrintf (val * 6) + 1) & 0x0f; // 0b00001111
+                       msg |=  (lrintf (val * 6) + 1) & 0x0f; // 0b00001111
                } else {
-                       msg +=  (lrintf (val * 10.0) + 1) & 0x0f; // 0b00001111
+                       msg |=  (lrintf (val * 10.0) + 1) & 0x0f; // 0b00001111
                }
        }
 
index 6f3ed10bad3ea970eca2be1f782997bccfa4fe9f..76fcc25a6c768e8bedcc2df0e78f2217c42857ff 100644 (file)
@@ -167,7 +167,7 @@ Strip::set_route (boost::shared_ptr<Route> r, bool with_messages)
 
        boost::shared_ptr<Pannable> pannable = _route->pannable();
 
-       if (pannable) {
+       if (pannable && pannable->panner()) {
                pannable->pan_azimuth_control->Changed.connect(route_connections, MISSING_INVALIDATOR, boost::bind (&Strip::notify_panner_azi_changed, this, false), ui_context());
                pannable->pan_width_control->Changed.connect(route_connections, MISSING_INVALIDATOR, boost::bind (&Strip::notify_panner_width_changed, this, false), ui_context());
        }
@@ -198,7 +198,7 @@ Strip::set_route (boost::shared_ptr<Route> r, bool with_messages)
        build_input_list (_route->input()->n_ports());
        build_output_list (_route->output()->n_ports());
 
-       current_pot_modes.clear();
+       possible_pot_parameters.clear();
 
        if (pannable) {
                boost::shared_ptr<Panner> panner = pannable->panner();
@@ -207,11 +207,11 @@ Strip::set_route (boost::shared_ptr<Route> r, bool with_messages)
                        set<Evoral::Parameter>::iterator a;
                        
                        if ((a = automatable.find (PanAzimuthAutomation)) != automatable.end()) {
-                               current_pot_modes.push_back (PanAzimuthAutomation);
+                               possible_pot_parameters.push_back (PanAzimuthAutomation);
                        }
                        
                        if ((a = automatable.find (PanWidthAutomation)) != automatable.end()) {
-                               current_pot_modes.push_back (PanWidthAutomation);
+                               possible_pot_parameters.push_back (PanWidthAutomation);
                        }
                } else {
                        std::cerr << "connected to route without a panner\n";
@@ -345,7 +345,7 @@ Strip::notify_panner_azi_changed (bool force_update)
 
                boost::shared_ptr<Pannable> pannable = _route->pannable();
 
-               if (!pannable) {
+               if (!pannable || !pannable->panner()) {
                        _surface->write (_vpot->zero());
                        return;
                }
@@ -384,7 +384,7 @@ Strip::notify_panner_width_changed (bool force_update)
 
                boost::shared_ptr<Pannable> pannable = _route->pannable();
 
-               if (!pannable) {
+               if (!pannable || !pannable->panner()) {
                        _surface->write (_vpot->zero());
                        return;
                }
@@ -459,7 +459,6 @@ Strip::vselect_event (Button& button, ButtonState bs)
 {
        if (bs == press) {
 
-
                int ms = _surface->mcp().modifier_state();
                                
                if (ms & MackieControlProtocol::MODIFIER_SHIFT) {
@@ -944,13 +943,18 @@ Strip::next_pot_mode ()
                return;
        }
 
+
        boost::shared_ptr<AutomationControl> ac = _vpot->control();
 
        if (!ac) {
                return;
        }
 
-       for (i = current_pot_modes.begin(); i != current_pot_modes.end(); ++i) {
+       if (possible_pot_parameters.empty() || (possible_pot_parameters.size() == 1 && possible_pot_parameters.front() == ac->parameter())) {
+               return;
+       }
+
+       for (i = possible_pot_parameters.begin(); i != possible_pot_parameters.end(); ++i) {
                if ((*i) == ac->parameter()) {
                        break;
                }
@@ -960,12 +964,12 @@ Strip::next_pot_mode ()
           also happen if the current mode is not in the current pot mode list)
        */
 
-       if (i != current_pot_modes.end()) {
+       if (i != possible_pot_parameters.end()) {
                ++i;
        }
 
-       if (i == current_pot_modes.end()) {
-               i = current_pot_modes.begin();
+       if (i == possible_pot_parameters.end()) {
+               i = possible_pot_parameters.begin();
        }
 
        set_vpot_parameter (*i);
index 9123ef6b70b1ed680d6da29e23f87bd1504dccf1..684d3a210898b0671927f0962be861d8f4037f2f 100644 (file)
@@ -136,7 +136,7 @@ private:
        void vselect_event (Button&, ButtonState);
        void fader_touch_event (Button&, ButtonState);
 
-       std::vector<Evoral::Parameter> current_pot_modes;
+       std::vector<Evoral::Parameter> possible_pot_parameters;
        void next_pot_mode ();
        void set_vpot_parameter (Evoral::Parameter);
 
index 7c604138c389a9805448ce15ff1d08171c798783..71198a746429b6e214c28df9ceb04a389664e5f3 100644 (file)
@@ -350,50 +350,34 @@ Surface::handle_midi_controller_message (MIDI::Parser &, MIDI::EventTwoBytes* ev
 
        Pot* pot = pots[ev->controller_number];
 
+       // bit 6 gives the sign
+       float sign = (ev->value & 0x40) == 0 ? 1.0 : -1.0; 
+       // bits 0..5 give the velocity. we interpret this as "ticks
+       // moved before this message was sent"
+       float ticks = (ev->value & 0x3f);
+       if (ticks == 0) {
+               /* euphonix and perhaps other devices send zero
+                  when they mean 1, we think.
+               */
+               ticks = 1;
+       }
+       float delta = sign * (ticks / (float) 0x3f);
+       
        if (!pot) {
                if (ev->controller_number == Jog::ID && _jog_wheel) {
 
-                       // bit 6 gives the sign
-                       float sign = (ev->value & 0x40) == 0 ? 1.0 : -1.0; 
-                       // bits 0..5 give the velocity. we interpret this as "ticks
-                       // moved before this message was sent"
-                       float ticks = (ev->value & 0x3f);
-                       if (ticks == 0) {
-                               /* euphonix and perhaps other devices send zero
-                                  when they mean 1, we think.
-                               */
-                               ticks = 1;
-                       }
-                       float delta = sign * (ticks / (float) 0x3f);
-
                        DEBUG_TRACE (DEBUG::MackieControl, string_compose ("Jog wheel moved %1\n", ticks));
                        _jog_wheel->jog_event (delta);
                        return;
                }
-       }
-
-       if (pot) {
-               // bit 6 gives the sign
-               float sign = (ev->value & 0x40) == 0 ? 1.0 : -1.0; 
-               // bits 0..5 give the velocity. we interpret this as "ticks
-               // moved before this message was sent"
-               float ticks = (ev->value & 0x3f);
-               if (ticks == 0) {
-                       /* euphonix and perhaps other devices send zero
-                          when they mean 1, we think.
-                       */
-                       ticks = 1;
-               }
-               float delta = sign * (ticks / (float) 0x3f);
 
-               Strip* strip = dynamic_cast<Strip*> (&pot->group());
-
-               if (strip) {
-                       strip->handle_pot (*pot, delta);
-               } 
-       } else {
-               DEBUG_TRACE (DEBUG::MackieControl, "pot not found\n");
+               return;
        }
+
+       Strip* strip = dynamic_cast<Strip*> (&pot->group());
+       if (strip) {
+               strip->handle_pot (*pot, delta);
+       } 
 }
 
 void 
@@ -726,7 +710,7 @@ void
 Surface::update_view_mode_display ()
 {
        string text;
-       Button* button = 0;
+       int id = -1;
 
        if (!_active) {
                return;
@@ -735,19 +719,19 @@ Surface::update_view_mode_display ()
        switch (_mcp.view_mode()) {
        case MackieControlProtocol::Mixer:
                show_two_char_display ("Mx");
-               button = buttons[Button::Pan];
+               id = Button::Pan;
                break;
        case MackieControlProtocol::Dynamics:
                show_two_char_display ("Dy");
-               button = buttons[Button::Dyn];
+               id = Button::Dyn;
                break;
        case MackieControlProtocol::EQ:
                show_two_char_display ("EQ");
-               button = buttons[Button::Eq];
+               id = Button::Eq;
                break;
        case MackieControlProtocol::Loop:
                show_two_char_display ("LP");
-               button = buttons[Button::Loop];
+               id = Button::Loop;
                break;
        case MackieControlProtocol::AudioTracks:
                show_two_char_display ("AT");
@@ -757,18 +741,28 @@ Surface::update_view_mode_display ()
                break;
        case MackieControlProtocol::Sends:
                show_two_char_display ("Sn");
-               button = buttons[Button::Sends];
+               id = Button::Sends;
                break;
        case MackieControlProtocol::Plugins:
                show_two_char_display ("Pl");
-               button = buttons[Button::Plugin];
+               id = Button::Plugin;
                break;
        default:
                break;
        }
 
-       if (button) {
-               _port->write (button->set_state (on));
+       if (id >= 0) {
+               
+               /* we are attempting to turn a global button/LED on */
+
+               map<int,Control*>::iterator x = controls_by_device_independent_id.find (id);
+
+               if (x != controls_by_device_independent_id.end()) {
+                       Button* button = dynamic_cast<Button*> (x->second);
+                       if (button) {
+                               _port->write (button->set_state (on));
+                       }
+               }
        }
 
        if (!text.empty()) {