<div dir="ltr">Hello everybody, Im trying to make a lv2 plugin that translate audio to MIDI, im using Aubio lib and Im having trouble to send the MIDI output. I already saw a bunch of lv2 examples, like fifths, sampler and gxtuner but couldn't solve my problem... I'm confuse about the steps i should follow to prepare my LV2_Atom_Sequence struct to output. Here's what i did until now (This is not the actual code, I modified it to give a context, tried to put only things related to the midi output port):<br>
<br><div><div>class Note2midi {</div><div>public:</div><div><span class="" style="white-space:pre"> </span>LV2_Atom_Sequence *out;</div><div><span class="" style="white-space:pre"> </span>MIDINoteEvent note;</div><div><br>
</div><div> LV2_URID_Map* map;</div><div> LV2_URID midi_event;</div><div>.</div><div>.</div><div>.</div><div>};</div><div><br></div><div>uint32_t out_capacity;</div><div><br></div><div>/*****(MIDINoteEvent is the struct used in fifths example:</div>
<div><br></div><div>typedef struct {</div><div><span class="" style="white-space:pre"> </span>LV2_Atom_Event event;</div><div><span class="" style="white-space:pre"> </span>uint8_t msg[3];</div><div><span class="" style="white-space:pre"> </span>} MIDINoteEvent;</div>
<div><br></div><div>) *****/</div><div><br></div><div>LV2_Handle Note2midi::instantiate(const LV2_Descriptor* descriptor, double SampleRate, const char* bundle_path, const LV2_Feature* const* features)</div><div>{</div><div>
Note2midi *plugin = new Note2midi();</div><div> plugin->out = new LV2_Atom_Sequence();</div><div><br></div><div> for (int i = 0; features[i]; ++i) {</div><div> if (!strcmp(features[i]->URI, LV2_URID__map)) {</div>
<div> plugin->map = (LV2_URID_Map*)features[i]->data;</div><div> }</div><div> }</div><div><br></div><div> if (!plugin->map) {</div><div> // fprintf(stderr, "Missing feature urid:map\n");</div>
<div> delete (plugin);</div><div> return NULL;</div><div> }</div><div><br></div><div><span class="" style="white-space:pre"> </span>plugin->midi_event = plugin->map->map(plugin->map->handle, LV2_MIDI__MidiEvent);</div>
<div><span class="" style="white-space:pre"> </span>.</div><div><span class="" style="white-space:pre"> </span>.</div><div><span class="" style="white-space:pre"> </span>.</div><div><span class="" style="white-space:pre"> </span>plugin->out->atom.type = plugin->midi_event;</div>
<div> plugin->out->atom.size = sizeof(plugin->note.msg);</div><div><br></div><div> out_capacity = plugin->out->atom.size;</div><div><br></div><div>}</div><div><br></div><div>void Note2midi::run(LV2_Handle instance, uint32_t SampleCount)</div>
<div>{</div><div> Note2midi *plugin = (Note2midi *) instance;</div><div><br></div><div> lv2_atom_sequence_clear(plugin->out);</div><div><br></div><div> plugin->note.event.body.size = 3;</div><div> plugin->note.event.body.type = 19;</div>
<div> plugin->note.event.time.frames = rand()%256;</div><div> plugin->note.msg[2] = velo;</div><div> plugin->note.msg[1] = mpitch;</div><div> if (velo == 0) {</div><div> plugins->note.msg[0] = 0x80; /* note off */</div>
<div> }</div><div> else{</div><div> plugin->note.msg[0] = 0x90; /* note on */</div><div> }</div><div><br></div><div> lv2_atom_sequence_append_event(plugin->out, out_capacity, &(plugin->note.event));</div>
<div><br></div><div style>}<br><br>Hope this is not asking too much =) <br>Thanks in advance</div></div><div><br></div>
</div>