@@ 142,6 142,7 @@ struct _plughandle_t {
uint16_t gain [0x10];
uint16_t pressure [0x10];
uint16_t timbre [0x10];
+ uint8_t mpe_plus_lsb [0x10];
float bend [0x10];
float range [0x10];
bool sustain [0x10];
@@ 846,15 847,49 @@ _voice_send_event(plughandle_t *handle, dsp_t *dsp, jit_ev_type_t etype,
}
}
+static inline void
+_mpe_plus_lsb(plughandle_t *handle, uint8_t chn, uint16_t *tar)
+{
+ const uint8_t lsb = handle->mpe_plus_lsb[chn];
+
+ if(lsb)
+ {
+ *tar &= ~0x7f;
+ *tar |= lsb;
+ }
+
+ handle->mpe_plus_lsb[chn] = 0x0; // always clear register after usage
+}
+
static void
-_handle_midi(plughandle_t *handle, dsp_t *dsp,
- int64_t frames __attribute__((unused)), const uint8_t *msg, uint32_t len)
+_handle_midi_2(plughandle_t *handle, dsp_t *dsp,
+ int64_t frames __attribute__((unused)), const uint8_t *msg)
{
- if(len < 3)
+ const uint8_t cmd = msg[0] & 0xf0;
+ const uint8_t chn = msg[0] & 0x0f;
+
+ if(!dsp)
{
return;
}
+ switch(cmd)
+ {
+ case LV2_MIDI_MSG_CHANNEL_PRESSURE:
+ {
+ handle->pressure[chn] = msg[1] << 7;
+
+ _mpe_plus_lsb(handle, chn, &handle->pressure[chn]);
+
+ _update_pressure(handle, dsp, chn);
+ } break;
+ }
+}
+
+static void
+_handle_midi_3(plughandle_t *handle, dsp_t *dsp,
+ int64_t frames __attribute__((unused)), const uint8_t *msg)
+{
const uint8_t cmd = msg[0] & 0xf0;
const uint8_t chn = msg[0] & 0x0f;
@@ 1019,6 1054,8 @@ _handle_midi(plughandle_t *handle, dsp_t *dsp,
handle->pressure[chn] &= ~0x3f80;
handle->pressure[chn] |= val << 7;
+ _mpe_plus_lsb(handle, chn, &handle->pressure[chn]);
+
_update_pressure(handle, dsp, chn);
} break;
case LV2_MIDI_CTL_SC5_BRIGHTNESS | 0x20:
@@ 1033,14 1070,37 @@ _handle_midi(plughandle_t *handle, dsp_t *dsp,
handle->timbre[chn] &= ~0x3f80;
handle->timbre[chn] |= val << 7;
+ _mpe_plus_lsb(handle, chn, &handle->timbre[chn]);
+
_update_timbre(handle, dsp, chn);
} break;
+ case 0x57: // MPE+ LSB according to Haken Audio
+ {
+ handle->mpe_plus_lsb[chn] = val;
+ } break;
}
} break;
}
}
static void
+_handle_midi(plughandle_t *handle, dsp_t *dsp,
+ int64_t frames, const uint8_t *msg, uint32_t len)
+{
+ switch(len)
+ {
+ case 2:
+ {
+ _handle_midi_2(handle, dsp, frames, msg);
+ } break;
+ case 3:
+ {
+ _handle_midi_3(handle, dsp, frames, msg);
+ } break;
+ }
+}
+
+static void
run(LV2_Handle instance, uint32_t nsamples)
{
plughandle_t *handle = instance;