summaryrefslogtreecommitdiff
path: root/lv2/input_lv2.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2011-08-09 11:39:30 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2011-08-09 11:39:30 +0200
commit6611e83df0ed5b9bed42ff8cd549da0b5df11df2 (patch)
tree89a82a599d5135236f4111eba05a6967f6087c36 /lv2/input_lv2.cc
parent4920ff67f81b9f0c92ec8330136e6f1e949b040f (diff)
Use midimapper in LV2 plugin.
Diffstat (limited to 'lv2/input_lv2.cc')
-rw-r--r--lv2/input_lv2.cc15
1 files changed, 13 insertions, 2 deletions
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++;