From: c vw Date: Tue, 21 Sep 2021 18:08:43 +0000 (+0200) Subject: smoother rounding for MIDI controller values X-Git-Url: https://git.rkrishnan.org/listings/vdrive/index.php?a=commitdiff_plain;h=4d162fc4d97247e99de548b310bf4403ed6e7f70;p=pihpsdr.git smoother rounding for MIDI controller values --- diff --git a/midi2.c b/midi2.c index be8ca9e..d052f7f 100644 --- a/midi2.c +++ b/midi2.c @@ -61,8 +61,8 @@ void NewMidiEvent(enum MIDIevent event, int channel, int note, int val) { break; case MIDI_CTRL: if (desc->type == MIDI_KNOB) { - // normalize value to range 0 - 100 - new = (val*100)/127; + // normalize value to range 0 - 100, round to nearest + new = (val*100+63)/127; DoTheMidi(desc->action, desc->type, new); } else if (desc->type == MIDI_WHEEL) { if (desc->delay > 0 && last_wheel_action == desc->action) { @@ -90,8 +90,8 @@ void NewMidiEvent(enum MIDIevent event, int channel, int note, int val) { break; case MIDI_PITCH: if (desc->type == MIDI_KNOB) { - // normalize value to 0 - 100 - new = (val*100)/16383; + // normalize value to 0 - 100, round to nearest + new = (val*100+8191)/16383; DoTheMidi(desc->action, desc->type, new); } break;