free-audio / clap

Audio Plugin API
https://cleveraudio.org/
MIT License
1.76k stars 97 forks source link

Input and output event queue clarification #266

Closed sadko4u closed 1 year ago

sadko4u commented 1 year ago

In the description of both clap_input_events and clap_output_events, there are remarks:

// Input event list, events must be sorted by time.
// Output event list, events must be sorted by time.

The description is missing the side that is responsible for providing sorted events. When we talk about the input event list, then probably the host is responsible for sorting out the events. When we talk about the output event list, then it is not clear who is responsible - the host or the plugin? Should the plugin care about sorting the events or is the host responble for sorting the events that come from the plugin?

I think this clarification should be added to the comments.

robbert-vdh commented 1 year ago

The plugin is the one inserting events into the event list, in which events must be sorted by time. Ergo, the plugin is the one who should be inserting sorted events into the list. This is the same for every plugin format. (other than the mandatory merge+sort in VST3 if you need to combine both the event queue and the parameter queues)

robbert-vdh commented 1 year ago

The clap-validator also verifies that all events output by the plugin are in a monotonically increasing order of time.

baconpaul commented 1 year ago

I agree we should update the documentation though.

defiantnerd commented 1 year ago

The host is responsible for ordering the input queue, the plugin is responsible for ordering the output queue.

abique commented 1 year ago

I think it is perfectly clear. Given the interfaces, the plugin can't re-order the events. I'm not sure how one can possibly understand it wrong.

baconpaul commented 1 year ago

“Input event list. The host will deliver these sorted in sample order. Output event list. The plugin must insert events in sample sorted order when inserting events”