lv2 midi input

Programming applications for making music on Linux.

Moderators: khz, MattKingUSA

User avatar
skei
Established Member
Posts: 146
Joined: Sun May 18, 2014 4:24 pm

Re: lv2 midi input

Postby skei » Sat Jun 23, 2018 7:33 pm

i looked at the example from here: http://lv2plug.in/book/#_midi_gate
and came up with something like the below.. i don't fully understand what everyting is doing yet, so i absolutely need to look at some docs :-)

but, same result.. works in qtractor, didn't test in ardour, doesn't work in carla..

the little led/light on the plugin in the carla rack view lights up when i press a midi key.. does that mean carla is sending the midi to the plugin?

kode_debug.ttl:

Code: Select all

@prefix doap:      <http://usefulinc.com/ns/doap#> .
@prefix lv2:      <http://lv2plug.in/ns/lv2core#> .
@prefix rdf:      <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs:      <http://www.w3.org/2000/01/rdf-schema#> .
@prefix atom:      <http://lv2plug.in/ns/ext/atom#> .
@prefix midi:      <http://lv2plug.in/ns/ext/midi#> .
@prefix urid:      <http://lv2plug.in/ns/ext/urid#> .

<urn:skei.audio/kode_debug>
   a lv2:Plugin , lv2:InstrumentPlugin ;
   doap:name         "kode_debug" ;
   lv2:optionalFeature   lv2:hardRTCapable ;
   lv2:requiredFeature   urid:map ;
   lv2:port [
      ...
      ...
   ] , [
      a lv2:InputPort , atom:AtomPort ;
      atom:bufferType      atom:Sequence ;
      atom:supports      midi:MidiEvent ;
      lv2:designation      lv2:control ;
      lv2:index         6 ;
      lv2:symbol         "midi_in" ;
      lv2:name         "Midi in"
   ] .


Code: Select all

#define KODE_PLUGIN_LV2_MAX_URIS 16

plugin instance class:

   const LV2_Atom_Sequence*   MLV2AtomSequence   = KODE_NULL;
   LV2_URID_Map*            MLV2Map            = KODE_NULL;
   KODE_uint32               MMidiEventType      = 0;
   LV2_URID*                MLV2URIS         = KODE_NULL;
      
plugin class.

   // for some reason, i thought it could be smart to prepare for multiple uri's..
   LV2_URID   MLV2URIS[KODE_PLUGIN_LV2_MAX_URIS]   = {0};
      
instantiate()

   LV2_URID_Map* map = NULL;
   for (int i=0; features[i]; ++i) {
      if (!strcmp(features[i]->URI, LV2_URID__map)) {
         map = (LV2_URID_Map*)features[i]->data;
         break;
      }
   }
   if (!map) return KODE_NULL;
   MLV2URIS[0] = map->map(map->handle, LV2_MIDI__MidiEvent);
   ...
   instance->MLV2URIS = MLV2URIS;   

connect()

   MLV2AtomSequence = (const LV2_Atom_Sequence*)data_location;

run()

   uint32_t offset = 0;
   LV2_ATOM_SEQUENCE_FOREACH(MLV2AtomSequence, ev) {
      if (ev->body.type == MLV2URIS[0]) {
         const uint8_t* const msg = (const uint8_t*)(ev + 1);
         offset = (uint32_t)ev->time.frames;
         on_instance_midiEvent(offset,msg[0],msg[1],msg[2]);
      }
   }
todo..

User avatar
skei
Established Member
Posts: 146
Joined: Sun May 18, 2014 4:24 pm

Re: lv2 midi input

Postby skei » Sat Jun 23, 2018 9:16 pm

falkTX wrote:are you trying to send MIDI CCs by any chance?
those are disabled by default.

btw, when plugins have midi input, you can use the built-in keyboard widget to send some notes to the plugin.
test that too, to see if something gets received or not.


no, i'm sending/playing notes..
and, nothing happens if i click on the on-screen keyboard..
it looks like everything is ok on the carla side, but no reaction from my plugin..
so, i just tested with jalv (jalv.select?)..
the plugin loads and everything, but just like carla, nothing is printed out..
(and it looks ok in catia, with a red midi_in port)

maybe that indicates that it's the handling of events insinde my plugin that is the problem?
hmmm...

i just watched a video about the atom stuff, and read some docs, or specs?.. something are a little bit clearer (atom, uri/urid, at least the principles, the 'what' part).. but something are maybe a bit more confusing (the 'how') part)..

it wouldn't hurt if there were more 'how to get started with..' or 'introduction to..' tutorials.. :-)
todo..

User avatar
skei
Established Member
Posts: 146
Joined: Sun May 18, 2014 4:24 pm

Re: lv2 midi input

Postby skei » Sun Jun 24, 2018 6:42 am

i feel so stupid! my connect_port function was buggy! :oops:
after fixing this, i have midi input in carla too!!
sorry for taking up everybody's time with my stupidity!
todo..

User avatar
skei
Established Member
Posts: 146
Joined: Sun May 18, 2014 4:24 pm

Re: lv2 midi input

Postby skei » Sun Jun 24, 2018 10:49 am

yeah.. but at least i got rid of the deprecated stuff.. :)
todo..


Return to “Developer's Section”

Who is online

Users browsing this forum: No registered users and 5 guests