use correct per-MCU index when building fader, pot, ledring messages
authorPaul Davis <paul@linuxaudiosystems.com>
Mon, 9 Apr 2012 19:10:24 +0000 (19:10 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Mon, 9 Apr 2012 19:10:24 +0000 (19:10 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@11859 d708f5d6-7413-0410-9779-e7cbd77b26cf

libs/surfaces/mackie/controls.h
libs/surfaces/mackie/mackie_midi_builder.cc

index 7d0192e757f77df4536e1794fadeb054def217b3..81923f23c37d78dfc74dbaa902575fcc5db1c21c 100644 (file)
@@ -75,6 +75,10 @@ public:
        /// the id of the control, but only guaranteed to be
        /// unique within the control type.
        int raw_id() const { return _id; }
+
+       /* this identifies a given control within its MCU "bank of 8"
+        */
+       int control_id() const { return _id % 8; }
        
        /// The 1-based number of the control
        int ordinal() const { return _ordinal; }
index 0d9721f1337dfa841bf12f5e111792286b91a0ff..714180112d9fa664402a887e02eefb51107c40e2 100644 (file)
@@ -74,13 +74,13 @@ MidiByteArray MackieMidiBuilder::build_led_ring (const LedRing & led_ring, const
        // 0x30 + pot/ring number (0-7)
        //, 0x30 + led_ring.ordinal() - 1
        return MidiByteArray  (3
-               // the control type
-               , midi_pot_id
-               // the id
-               , 0x20 + led_ring.raw_id()
-               // the value
-               , calculate_pot_value (mode, state)
-       );
+                              // the control type
+                              , midi_pot_id
+                              // the id
+                              , 0x20 + led_ring.control_id()
+                              // the value
+                              , calculate_pot_value (mode, state)
+               );
 }
 
 MidiByteArray MackieMidiBuilder::build_led (const Button & button, LedState ls)
@@ -101,7 +101,7 @@ MidiByteArray MackieMidiBuilder::build_led (const Led & led, LedState ls)
        
        return MidiByteArray  (3
                , midi_button_id
-               , led.raw_id()
+               , led.control_id()
                , state
        );
 }
@@ -111,12 +111,12 @@ MidiByteArray MackieMidiBuilder::build_fader (const Fader & fader, float pos)
        int posi = int (0x3fff * pos);
        
        return MidiByteArray  (3
-               , midi_fader_id | fader.raw_id()
-               // lower-order bits
-               , posi & 0x7f
-               // higher-order bits
-               ,  (posi >> 7)
-       );
+                              , midi_fader_id | fader.control_id()
+                              // lower-order bits
+                              , posi & 0x7f
+                              // higher-order bits
+                              ,  (posi >> 7)
+               );
 }
 
 MidiByteArray MackieMidiBuilder::zero_strip (SurfacePort & port, const Strip & strip)