free-audio / clap

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

Clarify Cookie Optionality #180

Closed baconpaul closed 1 year ago

baconpaul commented 1 year ago

Clarify Cookie Optionality. The documentation was ambiguous as to whether hosts can choose to ignore the plugin cookie. This change documents the fact that they can, and the plugin must react accordingly

baconpaul commented 1 year ago

Just FYI when you read this in the morning @abique - since a lot went by on discord

  1. I think most of us think this is wrong and cookies should be host mandatory as described in #174 but
  2. If they are not mandatory (which most of us think they should be) then this is an improvement and
  3. Either 1 or 2 is better than the current ambiguous state

To make surge meet this optional spec makes a bit of a mess in the way juce wraps a clap and would be super inefficient but I made it work. If they were mandatory, i could instead just skip those malformed events with a null cookie and be a to-spec plugin.

abique commented 1 year ago

I think the host should be encouraged to provide the cookie if it can do better than N hash map lookup, with N being the number of events addressing parameters. Otherwise there is no benefit in passing the cookie, the plugin may as well do the resolution.

In Bitwig, once we did scan the parameters, we build an array with all the cached parameters info and internally work with param index, so we get immediate access to the cookie, therefore the optimization works.

abique commented 1 year ago

I'm 100% convinced that the cookie must not be mandatory and the explanation is short:

The scenario is a device in which the user would manually enter the GUI a parameter id and amplitude, and then the device would generate parameter modulation events which would be merged into the event stream. This device can't know the cookie, and the host providing the event stream may not be aware of plugin parameters.

CLAP needs to be working for all, for a very long time and prove to be flexible enough to work in situations we did not even think of. Making the cookie mandatory reduces the flexibility, and may make CLAP inappropriate for certain things.

baconpaul commented 1 year ago

I have updated the juce wrappers and also updated surge to support null cookies.

robbert-vdh commented 1 year ago

The validator now also explicitly zeroes out the cookies in one of its test cases: https://github.com/robbert-vdh/clap-validator/commit/ba9564ce04f688fa3f21ed1b1033cce8155e68b8

abique commented 1 year ago

I'll merge this on Friday unless anyone comes with strong arguments against it.

baconpaul commented 1 year ago

I mean you know my arguments against it :)

But we have to pick one. So that's fine with me.