From de5265e282645c5bda74f3874d96b51c5c3702a8 Mon Sep 17 00:00:00 2001 From: Hanspeter Portner Date: Tue, 10 Aug 2021 22:38:28 +0200 Subject: [PATCH] dsp: properly parse 14bit MIDI messages. --- VERSION | 2 +- jit_dsp.c | 32 ++++++++++++++++++++++++-------- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/VERSION b/VERSION index 9b1f169..bbfeb7c 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.1.417 +0.1.419 diff --git a/jit_dsp.c b/jit_dsp.c index f8f69b4..eb26ee4 100644 --- a/jit_dsp.c +++ b/jit_dsp.c @@ -138,6 +138,7 @@ struct _plughandle_t { uint16_t rpn_lsb [0x10]; uint16_t rpn_msb [0x10]; uint16_t data_lsb [0x10]; + uint16_t data_msb [0x10]; uint16_t gain [0x10]; uint16_t pressure [0x10]; uint16_t timbre [0x10]; @@ -697,6 +698,19 @@ _update_frequency(plughandle_t *handle, dsp_t *dsp, uint8_t chn) } } +static inline void +_update_bend_range(plughandle_t *handle, dsp_t *dsp, uint8_t chn) +{ + if( (handle->rpn_msb[chn] == 0x0) && (handle->rpn_lsb[chn] == 0x0) ) + { + const uint8_t semi = handle->data_msb[chn]; + const uint8_t cent = handle->data_lsb[chn]; + + handle->range[chn] = (float)semi + cent*0.01f; + _update_frequency(handle, dsp, chn); + } +} + static inline void _update_gain(plughandle_t *handle, dsp_t *dsp, uint8_t chn) { @@ -969,24 +983,22 @@ _handle_midi(plughandle_t *handle, dsp_t *dsp, case LV2_MIDI_CTL_LSB_DATA_ENTRY: { handle->data_lsb[chn] = val; + + _update_bend_range(handle, dsp, chn); } break; case LV2_MIDI_CTL_MSB_DATA_ENTRY: { - // pitch-bend range - if( (handle->rpn_msb[chn] == 0x0) && (handle->rpn_lsb[chn] == 0x0) ) - { - const uint8_t semi = val; - const uint8_t cent = handle->data_lsb[chn]; + handle->data_msb[chn] = val; - handle->range[chn] = (float)semi + cent*0.01f; - _update_frequency(handle, dsp, chn); - } + _update_bend_range(handle, dsp, chn); } break; case LV2_MIDI_CTL_LSB_MAIN_VOLUME: { handle->gain[chn] &= 0x7f; handle->gain[chn] |= val; + + _update_gain(handle, dsp, chn); } break; case LV2_MIDI_CTL_MSB_MAIN_VOLUME: { @@ -999,6 +1011,8 @@ _handle_midi(plughandle_t *handle, dsp_t *dsp, { handle->pressure[chn] &= 0x7f; handle->pressure[chn] |= val; + + _update_pressure(handle, dsp, chn); } break; case LV2_MIDI_CTL_SC1_SOUND_VARIATION: { @@ -1011,6 +1025,8 @@ _handle_midi(plughandle_t *handle, dsp_t *dsp, { handle->timbre[chn] &= 0x7f; handle->timbre[chn] |= val; + + _update_timbre(handle, dsp, chn); } break; case LV2_MIDI_CTL_SC5_BRIGHTNESS: { -- 2.38.5