Various Control Surfaces: Fix one off in calculation of fader position

MIDI pitch bend holds 14 bits (16384) which gives values of 0 to 16383.
This commit is contained in:
Todd Naugle
2021-05-07 18:02:24 -05:00
parent 67cce59f4e
commit 4d815554dd
6 changed files with 9 additions and 9 deletions

View File

@@ -482,7 +482,7 @@ FaderPort::fader_handler (MIDI::Parser &, MIDI::EventTwoBytes* tb)
boost::shared_ptr<AutomationControl> gain = _current_stripable->gain_control ();
if (gain) {
int ival = (fader_msb << 7) | fader_lsb;
float val = gain->interface_to_internal (ival/16384.0);
float val = gain->interface_to_internal (ival/16383.0);
/* even though the faderport only controls a
single stripable at a time, allow the fader to
modify the group, if appropriate.

View File

@@ -689,7 +689,7 @@ MIDIControllable::write_feedback (MIDI::byte* buf, int32_t& bufsize, bool /*forc
if (bufsize < 13) {
return buf;
}
int rpn_val = (int) lrintf (val * 16384.0);
int rpn_val = (int) lrintf (val * 16383.0);
if (last_value == rpn_val) {
return buf;
}
@@ -713,7 +713,7 @@ MIDIControllable::write_feedback (MIDI::byte* buf, int32_t& bufsize, bool /*forc
}
if (control_nrpn >= 0) {
int rpn_val = (int) lrintf (val * 16384.0);
int rpn_val = (int) lrintf (val * 16383.0);
if (last_value == rpn_val) {
return buf;
}

View File

@@ -59,7 +59,7 @@ Fader::update_message ()
return MidiByteArray();
}
int posi = lrintf (16384.0 * position);
int posi = lrintf (16383.0 * position);
if (posi == last_update_position) {
return MidiByteArray();

View File

@@ -560,7 +560,7 @@ Surface::handle_midi_pitchbend_message (MIDI::Parser&, MIDI::pitchbend_t pb, uin
*/
DEBUG_TRACE (DEBUG::MackieControl, string_compose ("Surface::handle_midi_pitchbend_message on port %3, fader = %1 value = %2 (%4)\n",
fader_id, pb, _number, pb/16384.0));
fader_id, pb, _number, pb/16383.0));
if (_mcp.device_info().no_handshake()) {
turn_it_on ();
@@ -570,7 +570,7 @@ Surface::handle_midi_pitchbend_message (MIDI::Parser&, MIDI::pitchbend_t pb, uin
if (fader) {
Strip* strip = dynamic_cast<Strip*> (&fader->group());
float pos = pb / 16384.0;
float pos = pb / 16383.0;
if (strip) {
strip->handle_fader (*fader, pos);
} else {

View File

@@ -52,7 +52,7 @@ Fader::set_position (float normalized)
MidiByteArray
Fader::update_message ()
{
int posi = lrintf (16384.0 * position);
int posi = lrintf (16383.0 * position);
if (posi == last_update_position) {
if (posi == llast_update_position) {

View File

@@ -504,7 +504,7 @@ Surface::handle_midi_pitchbend_message (MIDI::Parser&, MIDI::pitchbend_t pb, uin
*/
DEBUG_TRACE (DEBUG::US2400, string_compose ("Surface::handle_midi_pitchbend_message on port %3, fader = %1 value = %2 (%4)\n",
fader_id, pb, _number, pb/16384.0));
fader_id, pb, _number, pb/16383.0));
turn_it_on ();
@@ -512,7 +512,7 @@ Surface::handle_midi_pitchbend_message (MIDI::Parser&, MIDI::pitchbend_t pb, uin
if (fader) {
Strip* strip = dynamic_cast<Strip*> (&fader->group());
float pos = pb / 16384.0;
float pos = pb / 16383.0;
if (strip) {
strip->handle_fader (*fader, pos);
} else {