free-audio / clap

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

Named stepped parameters #309

Closed IcedQuinn closed 1 year ago

IcedQuinn commented 1 year ago

In LV2 there is an extension where if a parameter is marked as stepped you may also provide the name of each integer value in the manifest. This allows a plugin to for example make a filter controlled by a parameter, which is stepped, and export that the values mean "Low Pass Filter" or "High Pass Filter." The plugin UI can then read this out of the manifest and present them to the user.

I didn't see a feature like this when I read the CLAP spec; does this already exist or will it need a new draft extension?

robbert-vdh commented 1 year ago

Take a look at the clap_plugin_params::value_to_text() and clap_plugin_params::text_to_value() functions:

https://github.com/free-audio/clap/blob/065d685d4e9657f0344f350eef748be2b4d8e318/include/clap/ext/params.h#L249-L264

Any parameter can (and probably should!) have custom conversion functions that map between the untyped floating point value used to communicate parameter values between the plugin and the host and the actual meaning of those values.

baconpaul commented 1 year ago

https://github.com/surge-synthesizer/clap-saw-demo/blob/ea07f4ac4b957d4b53ff4a9a7513a3dabb3a55b6/src/clap-saw-demo.cpp#L215

And there’s an example of using it to make a stepped parameter show discrete non integral names in the clap saw demo (which is a super direct interpretation of the api)

IcedQuinn commented 1 year ago

@baconpaul @robbert-vdh so the recommended method is to check if a parameter has the integer bit set and then query for the name of every integer in range?

abique commented 1 year ago

yes that'll work.

baconpaul commented 1 year ago

Yes

robbert-vdh commented 1 year ago

See REAPER's generic UI for an example. They show stepped parameters as dropdown menus.