~hp/mystery.lv2

6740c8f3cb24ce6b00f33ba0fafddaf50317f825 — Hanspeter Portner 2 years ago 8013e04
dsp: properly parse 14bit MIDI messages.
2 files changed, 19 insertions(+), 9 deletions(-)

M VERSION
M mystery_curve.c
M VERSION => VERSION +1 -1
@@ 1,1 1,1 @@
0.1.127
0.1.141

M mystery_curve.c => mystery_curve.c +18 -8
@@ 148,6 148,7 @@ struct _plughandle_t {
	uint16_t rpn_lsb [0x10];
	uint16_t rpn_msb [0x10];
	uint16_t data_lsb [0x10];
	uint16_t data_msb [0x10];
	float bend [0x10];
	float range [0x10];
	bool sustain [0x10];


@@ 613,6 614,19 @@ _update_frequency(plughandle_t *handle, uint8_t chn)
	}
}

static inline void
_update_bend_range(plughandle_t *handle, 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, chn);
	}
}

static void
_midi(plughandle_t *handle, uint32_t size, const uint8_t *msg)
{


@@ 721,18 735,14 @@ _midi(plughandle_t *handle, uint32_t size, const uint8_t *msg)
				case LV2_MIDI_CTL_LSB_DATA_ENTRY:
				{
					handle->data_lsb[chn] = val;

					_update_bend_range(handle, 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, chn);
					}
					_update_bend_range(handle, chn);
				} break;
			}
		} break;