From 50f85edbd0f07135eb73201367bbd256792ee999 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Tue, 14 Aug 2012 06:25:33 +0000 Subject: Use new LV2 MIDI API. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4690 a436a847-0d15-0410-975c-d299462d15a1 --- src/server/ControlBindings.cpp | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'src/server/ControlBindings.cpp') diff --git a/src/server/ControlBindings.cpp b/src/server/ControlBindings.cpp index 1cc1518c..c5e20853 100644 --- a/src/server/ControlBindings.cpp +++ b/src/server/ControlBindings.cpp @@ -20,8 +20,8 @@ #include "ingen/URIs.hpp" #include "ingen/World.hpp" #include "lv2/lv2plug.in/ns/ext/atom/util.h" +#include "lv2/lv2plug.in/ns/ext/midi/midi.h" #include "raul/log.hpp" -#include "raul/midi_events.h" #include "Buffer.hpp" #include "ControlBindings.hpp" @@ -107,17 +107,17 @@ ControlBindings::binding_key(const Raul::Atom& binding) const ControlBindings::Key ControlBindings::midi_event_key(uint16_t size, const uint8_t* buf, uint16_t& value) { - switch (buf[0] & 0xF0) { - case MIDI_CMD_CONTROL: + switch (lv2_midi_message_type(buf)) { + case LV2_MIDI_MSG_CONTROLLER: value = static_cast(buf[2]); return Key(MIDI_CC, static_cast(buf[1])); - case MIDI_CMD_BENDER: + case LV2_MIDI_MSG_BENDER: value = (static_cast(buf[2]) << 7) + static_cast(buf[1]); return Key(MIDI_BENDER); - case MIDI_CMD_CHANNEL_PRESSURE: + case LV2_MIDI_MSG_CHANNEL_PRESSURE: value = static_cast(buf[1]); return Key(MIDI_CHANNEL_PRESSURE); - case MIDI_CMD_NOTE_ON: + case LV2_MIDI_MSG_NOTE_ON: value = 1.0f; return Key(MIDI_NOTE, static_cast(buf[1])); default: @@ -152,27 +152,28 @@ ControlBindings::port_value_changed(ProcessContext& context, switch (key.type) { case MIDI_CC: size = 3; - buf[0] = MIDI_CMD_CONTROL; + buf[0] = LV2_MIDI_MSG_CONTROLLER; buf[1] = key.num; buf[2] = static_cast(value); break; case MIDI_CHANNEL_PRESSURE: size = 2; - buf[0] = MIDI_CMD_CHANNEL_PRESSURE; + buf[0] = LV2_MIDI_MSG_CHANNEL_PRESSURE; buf[1] = static_cast(value); break; case MIDI_BENDER: size = 3; - buf[0] = MIDI_CMD_BENDER; + buf[0] = LV2_MIDI_MSG_BENDER; buf[1] = (value & 0x007F); buf[2] = (value & 0x7F00) >> 7; break; case MIDI_NOTE: size = 3; - if (value == 1) - buf[0] = MIDI_CMD_NOTE_ON; - else if (value == 0) - buf[0] = MIDI_CMD_NOTE_OFF; + if (value == 1) { + buf[0] = LV2_MIDI_MSG_NOTE_ON; + } else if (value == 0) { + buf[0] = LV2_MIDI_MSG_NOTE_OFF; + } buf[1] = key.num; buf[2] = 0x64; // MIDI spec default break; -- cgit v1.2.1