~hp/jit.lv2

de5265e282645c5bda74f3874d96b51c5c3702a8 — Hanspeter Portner 2 years ago 0f67241
dsp: properly parse 14bit MIDI messages.
2 files changed, 25 insertions(+), 9 deletions(-)

M VERSION
M jit_dsp.c
M VERSION => VERSION +1 -1
@@ 1,1 1,1 @@
0.1.417
0.1.419

M jit_dsp.c => jit_dsp.c +24 -8
@@ 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];


@@ 698,6 699,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)
{
	VOICE_FOREACH(dsp, voice)


@@ 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:
				{