MCP: remove misleading and confusing and out of date comment
[ardour.git] / libs / surfaces / mackie / mcp_buttons.cc
index f8ebedb7b923b133048ab0dcb6b8e10b320ca93d..c864b5b87126ca2d6f19b80a03a1ba7b642fef79 100644 (file)
@@ -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,19 @@ 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()));
-
-       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);
-               }
+                                                          _current_initial_bank, strip_cnt, route_cnt));
 
-               return on;
+       if (_current_initial_bank > strip_cnt) {
+               switch_banks (_current_initial_bank - strip_cnt);
        } else {
-               return flashing;
+               switch_banks (0);
        }
+
+       return on;
 }
 
 LedState 
@@ -126,26 +122,15 @@ 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);
+                                                          _current_initial_bank, strip_cnt, route_cnt));
 
-               if (delta > strip_cnt) {
-                       delta = strip_cnt;
-               }
-               
-               if (delta > 0) {
-                       switch_banks (_current_initial_bank + delta);
-               }
+       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;
+       return on;
 }
 
 LedState 
@@ -512,7 +497,7 @@ MackieControlProtocol::play_press (Button &)
           again, jump back to where we started last time
        */
 
-       transport_play (session->transport_rolling() == 1.0);
+       transport_play (session->transport_speed() == 1.0);
        return none;
 }