From 6611e83df0ed5b9bed42ff8cd549da0b5df11df2 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Tue, 9 Aug 2011 11:39:30 +0200 Subject: Use midimapper in LV2 plugin. --- lv2/Makefile.am | 1 + lv2/input_lv2.cc | 15 +++++++++++++-- lv2/input_lv2.h | 3 +++ 3 files changed, 17 insertions(+), 2 deletions(-) (limited to 'lv2') 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 + 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 +#include #include @@ -48,6 +49,8 @@ public: void post(); LV2_Event_Buffer *eventPort; + + MidiMapper mmap; }; #endif/*__DRUMGIZMO_INPUT_LV2_H__*/ -- cgit v1.2.3