diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2011-08-09 11:39:30 +0200 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2011-08-09 11:39:30 +0200 |
commit | 6611e83df0ed5b9bed42ff8cd549da0b5df11df2 (patch) | |
tree | 89a82a599d5135236f4111eba05a6967f6087c36 | |
parent | 4920ff67f81b9f0c92ec8330136e6f1e949b040f (diff) |
Use midimapper in LV2 plugin.
-rw-r--r-- | lv2/Makefile.am | 1 | ||||
-rw-r--r-- | lv2/input_lv2.cc | 15 | ||||
-rw-r--r-- | lv2/input_lv2.h | 3 |
3 files changed, 17 insertions, 2 deletions
diff --git a/lv2/Makefile.am b/lv2/Makefile.am index 16cbbe4..96d39a2 100644 --- a/lv2/Makefile.am +++ b/lv2/Makefile.am @@ -11,6 +11,7 @@ lv2sources = \ $(top_srcdir)/src/events.cc \ $(top_srcdir)/src/instrument.cc \ $(top_srcdir)/src/instrumentparser.cc \ + $(top_srcdir)/src/midimapparser.cc \ $(top_srcdir)/src/midimapper.cc \ $(top_srcdir)/src/mutex.cc \ $(top_srcdir)/src/path.cc \ diff --git a/lv2/input_lv2.cc b/lv2/input_lv2.cc index d670505..3092347 100644 --- a/lv2/input_lv2.cc +++ b/lv2/input_lv2.cc @@ -26,6 +26,8 @@ */ #include "input_lv2.h" +#include <midimapparser.h> + InputLV2::InputLV2() { eventPort = NULL; @@ -37,6 +39,14 @@ InputLV2::~InputLV2() bool InputLV2::init(Instruments &instruments) { + MidiMapParser p("/home/deva/docs/c/drumgizmo/kits/test/midimap.xml"); + if(p.parse()) {/*return false;*/} + mmap.midimap = p.midimap; + + for(size_t i = 0; i < instruments.size(); i++) { + mmap.instrmap[instruments[i].name()] = i; + } + return true; } @@ -80,9 +90,10 @@ event_t *InputLV2::run(size_t pos, size_t len, size_t *nevents) //printf("Event key:%d vel:%d\n", key, velocity); - if(velocity) { + int i = mmap.lookup(key); + if(velocity && i != -1) { list[listsize].type = TYPE_ONSET; - list[listsize].instrument = key; + list[listsize].instrument = i; list[listsize].velocity = velocity / 127.0; list[listsize].offset = ev->frames; listsize++; diff --git a/lv2/input_lv2.h b/lv2/input_lv2.h index 9e1fcac..f904237 100644 --- a/lv2/input_lv2.h +++ b/lv2/input_lv2.h @@ -28,6 +28,7 @@ #define __DRUMGIZMO_INPUT_LV2_H__ #include <audioinputengine.h> +#include <midimapper.h> #include <lv2/lv2plug.in/ns/ext/event/event-helpers.h> @@ -48,6 +49,8 @@ public: void post(); LV2_Event_Buffer *eventPort; + + MidiMapper mmap; }; #endif/*__DRUMGIZMO_INPUT_LV2_H__*/ |