summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2012-08-14 06:25:33 +0000
committerDavid Robillard <d@drobilla.net>2012-08-14 06:25:33 +0000
commit50f85edbd0f07135eb73201367bbd256792ee999 (patch)
treefe7b0a459063fb0319fdc82b4b914da09978ae7c
parent80fee5c311fdbdeda573ec81f59158a5fc87d0a1 (diff)
downloadingen-50f85edbd0f07135eb73201367bbd256792ee999.tar.gz
ingen-50f85edbd0f07135eb73201367bbd256792ee999.tar.bz2
ingen-50f85edbd0f07135eb73201367bbd256792ee999.zip
Use new LV2 MIDI API.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4690 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r--src/server/ControlBindings.cpp27
-rw-r--r--src/server/internals/Controller.cpp5
-rw-r--r--src/server/internals/Delay.cpp1
-rw-r--r--src/server/internals/Note.cpp28
-rw-r--r--src/server/internals/Trigger.cpp15
-rw-r--r--wscript2
6 files changed, 35 insertions, 43 deletions
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<const int8_t>(buf[2]);
return Key(MIDI_CC, static_cast<const int8_t>(buf[1]));
- case MIDI_CMD_BENDER:
+ case LV2_MIDI_MSG_BENDER:
value = (static_cast<int8_t>(buf[2]) << 7) + static_cast<int8_t>(buf[1]);
return Key(MIDI_BENDER);
- case MIDI_CMD_CHANNEL_PRESSURE:
+ case LV2_MIDI_MSG_CHANNEL_PRESSURE:
value = static_cast<const int8_t>(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<const int8_t>(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<int8_t>(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<int8_t>(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;
diff --git a/src/server/internals/Controller.cpp b/src/server/internals/Controller.cpp
index 62fe0520..7b18366d 100644
--- a/src/server/internals/Controller.cpp
+++ b/src/server/internals/Controller.cpp
@@ -21,7 +21,7 @@
#include "ingen/URIs.hpp"
#include "internals/Controller.hpp"
#include "lv2/lv2plug.in/ns/ext/atom/util.h"
-#include "raul/midi_events.h"
+#include "lv2/lv2plug.in/ns/ext/midi/midi.h"
#include "Buffer.hpp"
#include "Engine.hpp"
@@ -100,7 +100,8 @@ ControllerNode::process(ProcessContext& context)
LV2_ATOM_SEQUENCE_FOREACH(seq, ev) {
const uint8_t* buf = (const uint8_t*)LV2_ATOM_BODY(&ev->body);
if (ev->body.type == _midi_in_port->bufs().uris().midi_MidiEvent &&
- ev->body.size >= 3 && (buf[0] & 0xF0) == MIDI_CMD_CONTROL) {
+ ev->body.size >= 3 &&
+ lv2_midi_message_type(buf) == LV2_MIDI_MSG_CONTROLLER) {
control(context, buf[1], buf[2], ev->time.frames + context.start());
}
}
diff --git a/src/server/internals/Delay.cpp b/src/server/internals/Delay.cpp
index b6d05f68..0ee0e56d 100644
--- a/src/server/internals/Delay.cpp
+++ b/src/server/internals/Delay.cpp
@@ -23,7 +23,6 @@
#include "raul/Array.hpp"
#include "raul/Maid.hpp"
#include "raul/log.hpp"
-#include "raul/midi_events.h"
#include "Buffer.hpp"
#include "Driver.hpp"
diff --git a/src/server/internals/Note.cpp b/src/server/internals/Note.cpp
index 899e01df..c8d1be23 100644
--- a/src/server/internals/Note.cpp
+++ b/src/server/internals/Note.cpp
@@ -19,10 +19,10 @@
#include "ingen/URIs.hpp"
#include "lv2/lv2plug.in/ns/ext/atom/util.h"
+#include "lv2/lv2plug.in/ns/ext/midi/midi.h"
#include "raul/Array.hpp"
#include "raul/Maid.hpp"
#include "raul/log.hpp"
-#include "raul/midi_events.h"
#include "Buffer.hpp"
#include "Driver.hpp"
@@ -142,48 +142,38 @@ NoteNode::process(ProcessContext& context)
Buffer* const midi_in = _midi_in_port->buffer(0).get();
LV2_Atom_Sequence* seq = (LV2_Atom_Sequence*)midi_in->atom();
LV2_ATOM_SEQUENCE_FOREACH(seq, ev) {
- const uint8_t* buf = (const uint8_t*)LV2_ATOM_BODY(&ev->body);
+ const uint8_t* buf = (const uint8_t*)LV2_ATOM_BODY_CONST(&ev->body);
const FrameTime time = context.start() + (FrameTime)ev->time.frames;
if (ev->body.type == _midi_in_port->bufs().uris().midi_MidiEvent &&
ev->body.size >= 3) {
- switch (buf[0] & 0xF0) {
- case MIDI_CMD_NOTE_ON:
+ switch (lv2_midi_message_type(buf)) {
+ case LV2_MIDI_MSG_NOTE_ON:
if (buf[2] == 0) {
note_off(context, buf[1], time);
} else {
note_on(context, buf[1], buf[2], time);
}
break;
- case MIDI_CMD_NOTE_OFF:
+ case LV2_MIDI_MSG_NOTE_OFF:
note_off(context, buf[1], time);
break;
- case MIDI_CMD_CONTROL:
+ case LV2_MIDI_MSG_CONTROLLER:
switch (buf[1]) {
- case MIDI_CTL_ALL_NOTES_OFF:
- case MIDI_CTL_ALL_SOUNDS_OFF:
+ case LV2_MIDI_CTL_ALL_NOTES_OFF:
+ case LV2_MIDI_CTL_ALL_SOUNDS_OFF:
all_notes_off(context, time);
break;
- case MIDI_CTL_SUSTAIN:
+ case LV2_MIDI_CTL_SUSTAIN:
if (buf[2] > 63) {
sustain_on(context, time);
} else {
sustain_off(context, time);
}
break;
- case MIDI_CMD_BENDER:
- // ?
- break;
- default:
- //warn << "Ignored controller " << buf[1] << endl;
- break;
}
- break;
default:
- //fprintf(stderr, "Unknown (size %d) MIDI event %X\n", size, buf[0]);
break;
}
- } else {
- //fprintf(stderr, "Unknown (size %d) MIDI event %X\n", size, buf[0]);
}
}
diff --git a/src/server/internals/Trigger.cpp b/src/server/internals/Trigger.cpp
index 4745ffbb..f938718f 100644
--- a/src/server/internals/Trigger.cpp
+++ b/src/server/internals/Trigger.cpp
@@ -19,8 +19,8 @@
#include "ingen/URIs.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 "Engine.hpp"
@@ -102,20 +102,21 @@ TriggerNode::process(ProcessContext& context)
if (ev->body.type == _midi_in_port->bufs().uris().midi_MidiEvent &&
ev->body.size >= 3) {
const FrameTime time = context.start() + ev->time.frames;
- switch (buf[0] & 0xF0) {
- case MIDI_CMD_NOTE_ON:
+ switch (lv2_midi_message_type(buf)) {
+ case LV2_MIDI_MSG_NOTE_ON:
if (buf[2] == 0) {
note_off(context, buf[1], time);
} else {
note_on(context, buf[1], buf[2], time);
}
break;
- case MIDI_CMD_NOTE_OFF:
+ case LV2_MIDI_MSG_NOTE_OFF:
note_off(context, buf[1], time);
break;
- case MIDI_CMD_CONTROL:
- if (buf[1] == MIDI_CTL_ALL_NOTES_OFF ||
- buf[1] == MIDI_CTL_ALL_SOUNDS_OFF) {
+ case LV2_MIDI_MSG_CONTROLLER:
+ switch (buf[1]) {
+ case LV2_MIDI_CTL_ALL_NOTES_OFF:
+ case LV2_MIDI_CTL_ALL_SOUNDS_OFF:
_gate_port->set_control_value(context, time, 0.0f);
}
default:
diff --git a/wscript b/wscript
index c70170ac..6fcaa628 100644
--- a/wscript
+++ b/wscript
@@ -99,7 +99,7 @@ def configure(conf):
define_name='HAVE_POSIX_MEMALIGN',
mandatory=False)
- autowaf.check_pkg(conf, 'lv2', atleast_version='1.0.9', uselib_store='LV2')
+ autowaf.check_pkg(conf, 'lv2', atleast_version='1.0.11', uselib_store='LV2')
autowaf.define(conf, 'INGEN_VERSION', INGEN_VERSION)