From a856825e97712efc7eae4fcb47050160fb2ed165 Mon Sep 17 00:00:00 2001 From: John Anderson Date: Sat, 21 Jul 2007 17:50:48 +0000 Subject: fix fader position calculation. Some indenting. git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@2171 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/surfaces/mackie/mackie_port.cc | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) (limited to 'libs') diff --git a/libs/surfaces/mackie/mackie_port.cc b/libs/surfaces/mackie/mackie_port.cc index 0d81bd7c6f..f6a9837ea8 100644 --- a/libs/surfaces/mackie/mackie_port.cc +++ b/libs/surfaces/mackie/mackie_port.cc @@ -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; } -- cgit v1.2.3