fix fader position calculation. Some indenting.
authorJohn Anderson <ardour@semiosix.com>
Sat, 21 Jul 2007 17:50:48 +0000 (17:50 +0000)
committerJohn Anderson <ardour@semiosix.com>
Sat, 21 Jul 2007 17:50:48 +0000 (17:50 +0000)
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@2171 d708f5d6-7413-0410-9779-e7cbd77b26cf

libs/surfaces/mackie/mackie_port.cc

index 0d81bd7c6fcf2064e4642a5965ed7b35cff97a14..f6a9837ea8596176720aa45489e534345a37e880 100644 (file)
@@ -399,15 +399,12 @@ void MackiePort::handle_midi_any (MIDI::Parser & parser, MIDI::byte * raw_bytes,
                {
                        // fader
                        case Control::type_fader:
-                               {
-                                       // for a BCF2000, max is 7f for high-order byte and 0x70 for low-order byte
-                                       // According to the Logic docs, these should both be 0x7f.
-                                       // Although it does mention something about only the top-order
-                                       // 10 bits out of 14 being used
-                                       int midi_pos = ( raw_bytes[2] << 7 ) + raw_bytes[1];
-                                       control_event( *this, control, float(midi_pos) / float(0x3fff) );
-                               }
-                               break;
+                       {
+                               // only the top-order 10 bits out of 14 are used
+                               int midi_pos = ( ( raw_bytes[2] << 7 ) + raw_bytes[1] ) >> 4;
+                               control_event( *this, control, float(midi_pos) / float(0x3ff) );
+                       }
+                       break;
                                
                        // button
                        case Control::type_button:
@@ -416,18 +413,18 @@ void MackiePort::handle_midi_any (MIDI::Parser & parser, MIDI::byte * raw_bytes,
                                
                        // pot (jog wheel, external control)
                        case Control::type_pot:
-                               {
-                                       ControlState state;
-                                       
-                                       // bytes[2] & 0b01000000 (0x40) give sign
-                                       state.sign = ( raw_bytes[2] & 0x40 ) == 0 ? 1 : -1; 
-                                       // bytes[2] & 0b00111111 (0x3f) gives delta
-                                       state.ticks = ( raw_bytes[2] & 0x3f);
-                                       state.delta = float( state.ticks ) / float( 0x3f );
-                                       
-                                       control_event( *this, control, state );
-                               }
+                       {
+                               ControlState state;
+                               
+                               // bytes[2] & 0b01000000 (0x40) give sign
+                               state.sign = ( raw_bytes[2] & 0x40 ) == 0 ? 1 : -1; 
+                               // bytes[2] & 0b00111111 (0x3f) gives delta
+                               state.ticks = ( raw_bytes[2] & 0x3f);
+                               state.delta = float( state.ticks ) / float( 0x3f );
+                               
+                               control_event( *this, control, state );
                                break;
+                       }
                        default:
                                cerr << "Do not understand control type " << control;
                }