Re: [LAD] LV2 realtime safe memory pool extension

From: Krzysztof Foltman <wdev@email-addr-hidden>
Date: Tue Nov 13 2007 - 16:10:33 EET

Nedko Arnaudov wrote:

>> - so is the ability to deliver MIDI or MIDI-like events with sample
>> accuracy. But that may be added later (I'm looking at your MIDI Port
>> extension, it looks perfect except for double values for timestamp - I
>> think int32 and sample accuracy would be simpler/faster and equally useful)
> it works for me :)

My only gripe with doubles is that double-to-int conversions are slow
(even if implemented by clever tricks) and unnecessary. And unaligned
doubles may slow things down even more (or even cause alignment CPU
exceptions on non-x86 architectures!). And I can't see the practical
benefit of doubles over ints in this case.

My preferred way of communicating MIDI events to the plugin would be an
array of those:

struct MIDIEvent {
  uint32_t timestamp; // in samples relative to start of the buffer
  uint8_t data[3]; // command, arg1, arg2
  uint8_t flags; // required to be 0 for now
};

The structure is 8 bytes long and requires 4 byte alignment. It wastes
one byte per event (or more for some rare kinds of events), but it's not
going to be a problem in the era of multigigabyte sampled pianos :)
After all, for a 512-sample buffer we'll rarely have more than 512
events (4 KB in total), and usually just two events or less (some note
ons/note offs).

It's simple to produce and simple to process. It's also optimized for
speed (because the timestamp can be properly aligned, and because it's
easy and quick to compare current sample number to the timestamp of the
first unprocessed event).

However, it doesn't deal with float value-based automation, so, in
version 2.0, it might be further expanded by adding the next structure:

struct MIDIExtendedAutomationEvent {
  uint32_t param_id;
  float value;
};

The structure follows the MIDIEvent structure when bit 0 in flags is
set. This extended event denotes a change in parameter 'param_id' to a
float value 'value'. It's basically a way to pass sample-accurate
automation data to a plugin, without using hacks like NRPNs.

Krzysztof

_______________________________________________
Linux-audio-dev mailing list
Linux-audio-dev@email-addr-hidden
http://lists.linuxaudio.org/mailman/listinfo/linux-audio-dev
Received on Tue Nov 13 20:15:02 2007

This archive was generated by hypermail 2.1.8 : Tue Nov 13 2007 - 20:15:02 EET