[LV2] Killing the event extension

David Robillard d at drobilla.net
Sat Feb 1 14:49:15 PST 2014


On Sat, 2014-02-01 at 20:51 +0100, Robin Gareus wrote:
> On 02/01/2014 07:11 PM, Bent Bisballe Nyeng wrote:
> 
> > Would it make sense to write a utility function for reading midi
> > notes as well, or is this task simple enough as it is already?
> 
> It's easy enough. basically just
> 
> -=-
> LV2_ATOM_SEQUENCE_FOREACH(seq, ev) {
>   my_process_midi( (uint8_t*)(ev+1), ev->body.size, ev->time.frames);
> }
[...]
> LV2_Atom_Event* ev = lv2_atom_sequence_begin(&(self->midiin)->body);
> 
> /* explicit LV2_ATOM_SEQUENCE_FOREACH */
> while(!lv2_atom_sequence_is_end(&(self->midiin)->body,
>                                  (self->midiin)->atom.size, ev))
[...]

Which is to say: yes.  The atom extension has a utility header,
atom/util.h, that defines iterators much like the event ones, among
other handy things.

Similar simple write functions were an oversight, since the much more
powerful forge is used for this.

Note that none of this is really MIDI specific.  There's not much you
can do to make handling raw MIDI nicer, though midi.h has some
definitions and midi-specific utility functions so you can at least use
human readable symbols like LV2_MIDI_MSG_NOTE_ON instead of bare hex in
your code.

-- 
dr





More information about the Devel mailing list