Closed loki42 closed 1 year ago
plug->midi_out->atom.type = plug->midi_ev_urid;
You seem to be setting the type of the entire output buffer to MidiEvent? The buffer needs to be a sequence that contains events.
totally thought I might be doing something stupid. :)
I'm now doing:
if (plug->capacity == 0){
plug->capacity = plug->midi_out->atom.size;
}
lv2_atom_forge_set_buffer(&plug->forge, (uint8_t*)plug->midi_out, plug->capacity);
lv2_atom_forge_sequence_head(&plug->forge, &plug->frame, 0);
I mean, yes but also, it is kind of confusing. Consequence of making the output port, even sequences, atoms. Hosts could theoretically support individual atom output ports, but in the case of MIDI that's almost never what you'd want because it would only support a single event per call.
I have considered doing it more extensively for arbitrary "value" ports in ingen, but that just replicates the problems with control ports. Probably the other direction is best, where everything is a sequence, which is how it'd be without control ports, but... c'est la vie.
I have some code where I might be doing something stupid, but it's based on the 5ths LV2 example, i'm just checking when a control changes and sending a MIDI event.
When I get the capacity of the output sequence, with
In my run function, it sometimes returns 8 and less often returns 32760. When it returns 8 my calls to
r_v = lv2_atom_sequence_append_event(plug->midi_out, capacity, &midiatom.event);
return null and fail to queue the event, as the capacity check fails.
It appears that sometimes at the start of the function the value of atom.size isn't being set, though again, it could be something stupid I'm doing.