From 74b8a63270c1c0b01b33e861c26b1e2a59eeb82b Mon Sep 17 00:00:00 2001 From: Jonas Suhr Christensen Date: Fri, 7 Mar 2014 04:25:52 +0100 Subject: Changed midi handling from event extension to atom extension. --- lv2/drumgizmo.ttl | 11 ++++++----- lv2/input_lv2.cc | 17 +++++++++-------- lv2/input_lv2.h | 4 ++-- lv2/lv2.cc | 5 +++-- 4 files changed, 20 insertions(+), 17 deletions(-) diff --git a/lv2/drumgizmo.ttl b/lv2/drumgizmo.ttl index c72b34a..23345f3 100644 --- a/lv2/drumgizmo.ttl +++ b/lv2/drumgizmo.ttl @@ -16,7 +16,7 @@ @prefix doap: . @prefix foaf: . @prefix lv2: . -@prefix lv2ev: . +@prefix atom: . @prefix uiext: . @prefix state: . @@ -38,10 +38,11 @@ lv2:optionalFeature ; lv2:extensionData state:interface ; lv2:port [ - a lv2:InputPort , - lv2ev:EventPort ; - lv2ev:supportsEvent ; - lv2:index 0 ; + a atom:AtomPort , + lv2:InputPort; + atom:bufferType atom:Sequence ; + atom:supports ; + lv2:index 0 ; lv2:symbol "control" ; lv2:name "Control" ] , [ diff --git a/lv2/input_lv2.cc b/lv2/input_lv2.cc index 0d97760..d995e75 100644 --- a/lv2/input_lv2.cc +++ b/lv2/input_lv2.cc @@ -26,6 +26,8 @@ */ #include "input_lv2.h" +#include "lv2/lv2plug.in/ns/ext/atom/util.h" + #include #include @@ -70,14 +72,12 @@ event_t *InputLV2::run(size_t pos, size_t len, size_t *nevents) list = (event_t *)malloc(sizeof(event_t) * 1000); listsize = 0; - LV2_Event_Iterator iterator; - for(lv2_event_begin(&iterator, eventPort); - lv2_event_is_valid(&iterator); - lv2_event_increment(&iterator)) { - - LV2_Event* ev = lv2_event_get(&iterator, NULL); + LV2_Atom_Event* ev = lv2_atom_sequence_begin(&eventPort->body); - uint8_t* const data = (uint8_t* const)(ev + 1); + while(!lv2_atom_sequence_is_end(&eventPort->body, + eventPort->atom.size, + ev)) { + uint8_t* const data = (uint8_t*)(ev+1); if ((data[0] & 0xF0) == 0x80) { // note off int key = data[1]; @@ -96,7 +96,7 @@ event_t *InputLV2::run(size_t pos, size_t len, size_t *nevents) list[listsize].type = TYPE_ONSET; list[listsize].instrument = i; list[listsize].velocity = velocity / 127.0; - list[listsize].offset = ev->frames; + list[listsize].offset = ev->time.frames; listsize++; } /* @@ -105,6 +105,7 @@ event_t *InputLV2::run(size_t pos, size_t len, size_t *nevents) plugin->play = true; */ } + ev = lv2_atom_sequence_next(ev); } *nevents = listsize; diff --git a/lv2/input_lv2.h b/lv2/input_lv2.h index aa39a23..32e2fd8 100644 --- a/lv2/input_lv2.h +++ b/lv2/input_lv2.h @@ -29,7 +29,7 @@ #include -#include +#include class InputLV2 : public AudioInputEngineMidi { public: @@ -47,7 +47,7 @@ public: event_t *run(size_t pos, size_t len, size_t *nevents); void post(); - LV2_Event_Buffer *eventPort; + LV2_Atom_Sequence *eventPort; private: Instruments *instruments; diff --git a/lv2/lv2.cc b/lv2/lv2.cc index c1f1ecc..3aeb5f0 100644 --- a/lv2/lv2.cc +++ b/lv2/lv2.cc @@ -27,6 +27,7 @@ #include #include +#include #include "lv2_gui.h" @@ -34,7 +35,7 @@ #include -#define MIDI_EVENT_URI "http://lv2plug.in/ns/ext/midi#MidiEvent" +#include #define NS_ATOM "http://lv2plug.in/ns/ext/atom#" #define NS_DG "http://drumgizmo.org/lv2/atom#" @@ -310,7 +311,7 @@ void connect_port(LV2_Handle instance, DGLV2 *dglv2 = (DGLV2 *)instance; if(port == 0) {// MIDI in - dglv2->in->eventPort = (LV2_Event_Buffer*)data_location; + dglv2->in->eventPort = (LV2_Atom_Sequence*)data_location; } else {// Audio Port if(port - 1 < NUM_OUTPUTS) { dglv2->out->outputPorts[port - 1].samples = (sample_t*)data_location; -- cgit v1.2.3