so, the problem i'm having is getting midi input from carla.. the code below works in qtractor and ardour (haven't tested much else).. in carla, the light/led lights up when i press a midi key, but my plugin doesn't seem to receive the midi events..
i tried to extract the minimal code needed to show what i do.. let's hope it still understandable
i separate plugins into two classes, the main plugin class which handles/manages the plugin/.so itself, and the descriptors, etc, and an instance class for each, well, instance.. the plugin class is a static class (object?), mainly to have automatic cleanup via the destructor when the .so is unloaded.. MLV2* prefixed variables are part of the plugin (or instance) class, on_instance_midiEvent() is a virtual function that individual plugins override if they want midi input.. and also, most of this is wrapped in #ifdef PLUGIN_RECEIVE MIDI .. #endif and similar constructs..
define midi input port:
Code: Select all
lv2:port [
a ev:EventPort, lv2:InputPort;
lv2:index 6 ;
ev:supportsEvent <http://lv2plug.in/ns/ext/midi#MidiEvent> ;
lv2:symbol "midi" ;
lv2:name "MIDI Input" ;
] .
instantiation:
Code: Select all
LV2_URI_Map_Feature* map_feature;
const LV2_Feature* const* ft;
for (ft=features; *ft; ft++) {
if (!strcmp((*ft)->URI,"http://lv2plug.in/ns/ext/uri-map")) { // LV2_URI_MAP_URI
map_feature = (LV2_URI_Map_Feature*)(*ft)->data;
MLV2EventType = map_feature->uri_to_id(
map_feature->callback_data,
"http://lv2plug.in/ns/ext/event",
"http://lv2plug.in/ns/ext/midi#MidiEvent"
);
}
else if (!strcmp((*ft)->URI, "http://lv2plug.in/ns/ext/event")) {
MLV2EventFeature =(LV2_Event_Feature*)(*ft)->data;
}
}
connect the port:
Code: Select all
MLV2EventBuffer = (LV2_Event_Buffer*)data_location;
and finally, at the start of the run() function:
Code: Select all
LV2_Event_Iterator event_iterator;
lv2_event_begin(&event_iterator,MLV2EventBuffer);
while (lv2_event_is_valid(&event_iterator)) {
uint8_t* data;
LV2_Event* event = lv2_event_get(&event_iterator,&data);
if (event->type == 0) {
MLV2EventFeature->lv2_event_unref(MLV2EventFeature->callback_data, event);
}
else if (event->type == MLV2EventType) {
uint32_t offset = event->frames;
const uint8_t* msg = (uint8_t*)data;
on_instance_midiEvent(offset,msg[0],msg[1],msg[2]);
}
lv2_event_increment(&event_iterator);
}
does anybody see any obvious errors or missing things or other issues?
i also tried another way, using some AtomPort stuff (i think?), with the same results,
except that i felt it was more confusing - more terminology and stuff i don't fully grasp yet..
(but that also worked in qtractor and ardour, but not carla, so the problem might be somewhere else?)