Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLAP 1.1.10 #359

Merged
merged 29 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
5f6121a
Add CLAP_PARAM_IS_ENUM to parameter flags
messmerd Nov 2, 2023
db714f0
Update wording
messmerd Nov 2, 2023
858a09f
Merge pull request #358 from messmerd/enum-parameters
abique Nov 3, 2023
bd4809d
Simplify the wording
abique Nov 3, 2023
5820476
ChangeLog + version.h
abique Nov 3, 2023
e5f86fb
Clarify return values in plugin.h
messmerd Nov 3, 2023
cde87e2
Clarify return values and fix style in audio-ports-config.h
messmerd Nov 3, 2023
8bc0fae
Clarify return values and fix typo in audio-ports.h
messmerd Nov 3, 2023
08c43d6
Fix typo in event-registry.h
messmerd Nov 3, 2023
0efc795
Use single-line comments in gui.h
messmerd Nov 3, 2023
aa8c410
Clarify return values and fix typo in note-ports.h
messmerd Nov 3, 2023
8b7a452
Clarify return values in posix-fd-support.h
messmerd Nov 3, 2023
47f1b44
Clarify return values in timer-support.h
messmerd Nov 3, 2023
c61906e
Clarify return values and fix typos in context-menu.h
messmerd Nov 3, 2023
555c99d
Clarify return values in midi-mappings.h
messmerd Nov 3, 2023
a401a2f
Clarify return values in preset-load.h
messmerd Nov 3, 2023
241899d
Clarify return values in remote-controls.h
messmerd Nov 3, 2023
d1eb56d
Clarify return values in track-info.h
messmerd Nov 3, 2023
05b1d87
Remove repeated statement in triggers.h
messmerd Nov 3, 2023
b89953c
Clarify return values in tuning.h
messmerd Nov 3, 2023
c82516c
Fix typo in preset-discovery.h
messmerd Nov 3, 2023
a8e6a06
Clarify return values in preset-discovery.h
messmerd Nov 3, 2023
92217e0
Fix style
messmerd Nov 3, 2023
3929e26
Merge pull request #360 from messmerd/return-value-clarifications
abique Nov 3, 2023
b8e5375
Update changelog
abique Nov 3, 2023
420a542
Few more documentation cleanup
abique Nov 3, 2023
de9aa5d
Update include/clap/ext/draft/midi-mappings.h
abique Nov 4, 2023
5b24f80
Update include/clap/ext/draft/preset-load.h
abique Nov 4, 2023
5651cd6
Apply suggestions from code review
abique Nov 4, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# Changes in 1.1.10

* [params.h](include/clap/ext/params.h): add `CLAP_PARAM_IS_ENUM` flag.
* various documentation improvements:
* clarification on the return value of many functions
* typos

# Changes in 1.1.9

* [entry.h](include/clap/entry.h): clarify what the `plugin_path` is on macOS
Expand Down
12 changes: 7 additions & 5 deletions include/clap/ext/audio-ports-config.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,21 @@ typedef struct clap_audio_ports_config {

// The audio ports config scan has to be done while the plugin is deactivated.
typedef struct clap_plugin_audio_ports_config {
// gets the number of available configurations
// Gets the number of available configurations
// [main-thread]
uint32_t(CLAP_ABI *count)(const clap_plugin_t *plugin);

// gets information about a configuration
// Gets information about a configuration
// Returns true on success and stores the result into config.
// [main-thread]
bool(CLAP_ABI *get)(const clap_plugin_t *plugin,
uint32_t index,
clap_audio_ports_config_t *config);

// selects the configuration designated by id
// returns true if the configuration could be applied.
// Selects the configuration designated by id
// Returns true if the configuration could be applied.
// Once applied the host should scan again the audio ports.
// [main-thread,plugin-deactivated]
// [main-thread & plugin-deactivated]
bool(CLAP_ABI *select)(const clap_plugin_t *plugin, clap_id config_id);
} clap_plugin_audio_ports_config_t;

Expand All @@ -82,6 +83,7 @@ typedef struct clap_plugin_audio_ports_config_info {

// Get info about an audio port, for a given config_id.
// This is analogous to clap_plugin_audio_ports.get().
// Returns true on success and stores the result into info.
// [main-thread]
bool(CLAP_ABI *get)(const clap_plugin_t *plugin,
clap_id config_id,
Expand Down
5 changes: 3 additions & 2 deletions include/clap/ext/audio-ports.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,12 @@ typedef struct clap_audio_port_info {

// The audio ports scan has to be done while the plugin is deactivated.
typedef struct clap_plugin_audio_ports {
// number of ports, for either input or output
// Number of ports, for either input or output
// [main-thread]
uint32_t(CLAP_ABI *count)(const clap_plugin_t *plugin, bool is_input);

// get info about about an audio port.
// Get info about an audio port.
// Returns true on success and stores the result into info.
// [main-thread]
bool(CLAP_ABI *get)(const clap_plugin_t *plugin,
uint32_t index,
Expand Down
8 changes: 7 additions & 1 deletion include/clap/ext/draft/context-menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ typedef struct clap_context_menu_builder {
void *ctx;

// Adds an entry to the menu.
// entry_data type is determined by entry_kind.
// item_data type is determined by item_kind.
// Returns true on success.
bool(CLAP_ABI *add_item)(const struct clap_context_menu_builder *builder,
clap_context_menu_item_kind_t item_kind,
const void *item_data);
Expand All @@ -107,13 +108,15 @@ typedef struct clap_context_menu_builder {
typedef struct clap_plugin_context_menu {
// Insert plugin's menu items into the menu builder.
// If target is null, assume global context.
// Returns true on success.
// [main-thread]
bool(CLAP_ABI *populate)(const clap_plugin_t *plugin,
const clap_context_menu_target_t *target,
const clap_context_menu_builder_t *builder);

// Performs the given action, which was previously provided to the host via populate().
// If target is null, assume global context.
// Returns true on success.
// [main-thread]
bool(CLAP_ABI *perform)(const clap_plugin_t *plugin,
const clap_context_menu_target_t *target,
Expand All @@ -123,13 +126,15 @@ typedef struct clap_plugin_context_menu {
typedef struct clap_host_context_menu {
// Insert host's menu items into the menu builder.
// If target is null, assume global context.
// Returns true on success.
// [main-thread]
bool(CLAP_ABI *populate)(const clap_host_t *host,
const clap_context_menu_target_t *target,
const clap_context_menu_builder_t *builder);

// Performs the given action, which was previously provided to the plugin via populate().
// If target is null, assume global context.
// Returns true on success.
// [main-thread]
bool(CLAP_ABI *perform)(const clap_host_t *host,
const clap_context_menu_target_t *target,
Expand All @@ -145,6 +150,7 @@ typedef struct clap_host_context_menu {
// If the plugin is using embedded GUI, then x and y are relative to the plugin's window,
// otherwise they're absolute coordinate, and screen index might be set accordingly.
// If target is null, assume global context.
// Returns true on success.
// [main-thread]
bool(CLAP_ABI *popup)(const clap_host_t *host,
const clap_context_menu_target_t *target,
Expand Down
1 change: 1 addition & 0 deletions include/clap/ext/draft/midi-mappings.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ typedef struct clap_plugin_midi_mappings {
uint32_t(CLAP_ABI *count)(const clap_plugin_t *plugin);

// [main-thread]
// Returns true on success and stores the result into mapping.
abique marked this conversation as resolved.
Show resolved Hide resolved
bool(CLAP_ABI *get)(const clap_plugin_t *plugin, uint32_t index, clap_midi_mapping_t *mapping);
} clap_plugin_midi_mappings_t;

Expand Down
1 change: 1 addition & 0 deletions include/clap/ext/draft/preset-load.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ extern "C" {
typedef struct clap_plugin_preset_load {
// Loads a preset in the plugin native preset file format from a location.
// The preset discovery provider defines the location and load_key to be passed to this function.
// Returns true on success.
//
// [main-thread]
abique marked this conversation as resolved.
Show resolved Hide resolved
bool(CLAP_ABI *from_location)(const clap_plugin_t *plugin,
Expand Down
1 change: 1 addition & 0 deletions include/clap/ext/draft/remote-controls.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ typedef struct clap_plugin_remote_controls {
uint32_t(CLAP_ABI *count)(const clap_plugin_t *plugin);

// Get a page by index.
// Returns true on success and stores the result into page.
// [main-thread]
bool(CLAP_ABI *get)(const clap_plugin_t *plugin,
uint32_t page_index,
Expand Down
1 change: 1 addition & 0 deletions include/clap/ext/draft/track-info.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ typedef struct clap_plugin_track_info {

typedef struct clap_host_track_info {
// Get info about the track the plugin belongs to.
// Returns true on success and stores the result into info.
// [main-thread]
bool(CLAP_ABI *get)(const clap_host_t *host, clap_track_info_t *info);
} clap_host_track_info_t;
Expand Down
1 change: 0 additions & 1 deletion include/clap/ext/draft/triggers.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ typedef struct clap_plugin_triggers {
uint32_t(CLAP_ABI *count)(const clap_plugin_t *plugin);

// Copies the trigger's info to trigger_info and returns true on success.
// Returns true on success.
// [main-thread]
bool(CLAP_ABI *get_info)(const clap_plugin_t *plugin,
uint32_t index,
Expand Down
1 change: 1 addition & 0 deletions include/clap/ext/draft/tuning.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ typedef struct clap_host_tuning {
uint32_t(CLAP_ABI *get_tuning_count)(const clap_host_t *host);

// Gets info about a tuning
// Returns true on success and stores the result into info.
// [main-thread]
bool(CLAP_ABI *get_info)(const clap_host_t *host,
uint32_t tuning_index,
Expand Down
2 changes: 1 addition & 1 deletion include/clap/ext/event-registry.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ typedef struct clap_host_event_registry {
// Queries an event space id.
// The space id 0 is reserved for CLAP's core events. See CLAP_CORE_EVENT_SPACE.
//
// Return false and sets *space to UINT16_MAX if the space name is unknown to the host.
// Return false and sets *space_id to UINT16_MAX if the space name is unknown to the host.
// [main-thread]
bool(CLAP_ABI *query)(const clap_host_t *host, const char *space_name, uint16_t *space_id);
} clap_host_event_registry_t;
Expand Down
30 changes: 15 additions & 15 deletions include/clap/ext/gui.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,25 +204,25 @@ typedef struct clap_host_gui {
// [thread-safe & !floating]
void(CLAP_ABI *resize_hints_changed)(const clap_host_t *host);

/* Request the host to resize the client area to width, height.
* Return true if the new size is accepted, false otherwise.
* The host doesn't have to call set_size().
*
* Note: if not called from the main thread, then a return value simply means that the host
* acknowledged the request and will process it asynchronously. If the request then can't be
* satisfied then the host will call set_size() to revert the operation.
*
* [thread-safe & !floating] */
// Request the host to resize the client area to width, height.
// Return true if the new size is accepted, false otherwise.
// The host doesn't have to call set_size().
//
// Note: if not called from the main thread, then a return value simply means that the host
// acknowledged the request and will process it asynchronously. If the request then can't be
// satisfied then the host will call set_size() to revert the operation.
//
// [thread-safe & !floating]
abique marked this conversation as resolved.
Show resolved Hide resolved
bool(CLAP_ABI *request_resize)(const clap_host_t *host, uint32_t width, uint32_t height);

/* Request the host to show the plugin gui.
* Return true on success, false otherwise.
* [thread-safe] */
// Request the host to show the plugin gui.
// Return true on success, false otherwise.
// [thread-safe]
bool(CLAP_ABI *request_show)(const clap_host_t *host);

/* Request the host to hide the plugin gui.
* Return true on success, false otherwise.
* [thread-safe] */
// Request the host to hide the plugin gui.
// Return true on success, false otherwise.
// [thread-safe]
bool(CLAP_ABI *request_hide)(const clap_host_t *host);

// The floating window has been closed, or the connection to the gui has been lost.
Expand Down
5 changes: 3 additions & 2 deletions include/clap/ext/note-ports.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,12 @@ typedef struct clap_note_port_info {

// The note ports scan has to be done while the plugin is deactivated.
typedef struct clap_plugin_note_ports {
// number of ports, for either input or output
// Number of ports, for either input or output.
// [main-thread]
uint32_t(CLAP_ABI *count)(const clap_plugin_t *plugin, bool is_input);

// get info about about a note port.
// Get info about a note port.
// Returns true on success and stores the result into info.
// [main-thread]
bool(CLAP_ABI *get)(const clap_plugin_t *plugin,
uint32_t index,
Expand Down
20 changes: 15 additions & 5 deletions include/clap/ext/params.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,11 @@ enum {
// A simple example would be a DC Offset, changing it will change the output signal and must be
// processed.
CLAP_PARAM_REQUIRES_PROCESS = 1 << 15,

// This parameter represents an enumerated value.
// If you set this flag, then you must set CLAP_PARAM_IS_STEPPED too.
// All values from min to max must not have a blank value_to_text().
CLAP_PARAM_IS_ENUM = 1 << 16,
abique marked this conversation as resolved.
Show resolved Hide resolved
};
typedef uint32_t clap_param_info_flags;

Expand Down Expand Up @@ -251,27 +256,32 @@ typedef struct clap_plugin_params {
// [main-thread]
uint32_t(CLAP_ABI *count)(const clap_plugin_t *plugin);

// Copies the parameter's info to param_info. Returns true on success.
// Copies the parameter's info to param_info.
// Returns true on success.
// [main-thread]
bool(CLAP_ABI *get_info)(const clap_plugin_t *plugin,
uint32_t param_index,
clap_param_info_t *param_info);

// Writes the parameter's current value to out_value. Returns true on success.
// Writes the parameter's current value to out_value.
// Returns true on success.
// [main-thread]
bool(CLAP_ABI *get_value)(const clap_plugin_t *plugin, clap_id param_id, double *out_value);

// Fills out_buffer with a null-terminated UTF-8 string that represents the parameter at the
// given 'value' argument. eg: "2.3 kHz". Returns true on success. The host should always use
// this to format parameter values before displaying it to the user. [main-thread]
// given 'value' argument. eg: "2.3 kHz". The host should always use this to format parameter
// values before displaying it to the user.
// Returns true on success.
Copy link
Contributor

@messmerd messmerd Nov 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the value_to_text() function, I think it would be useful if the host could know when conversion from the double value to the string in out_buffer is trivial (i.e. 1.0 --> "1.0").

I could compare the string std::to_string(value) with the string returned from value_to_text(), but they might still be different strings due to precision or locale differences in floating point to string conversions. (for example, "1.0000000" and "1.0" compare as false). This makes it difficult and inefficient for hosts to know whether the parameter value to string conversion was trivial.

In LMMS (and presumably any other DAWs where users work with plain integers or floats when editing parameter automation), this often leads to me having to display two nearly identical strings to users alongside each other - "1.0" (the parameter's internal value which users use to automate the parameter) and "1.0000" (the supposedly fancy parameter text from value_to_text()). In these cases, I would like to be able to only display one.

To fix this issue, maybe the return value of value_to_text() could be false when an error occurred OR the conversion to string would be trivial? This would be a recommendation for plugins to return false to let the host do a trivial double-to-string conversion instead of doing that same conversion themselves.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do your users edit plain floats? To edit a parameter they should type in a string which the host hands to string to value and let the parameter handle it no?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LMMS uses plain float or integer values in the automation editor and parameter editing dialog boxes, not custom strings like those returned from value_to_text(). The parameter/automation system could potentially be reworked in the future, but would require a lot of work just to better support CLAP.

Until that happens, LMMS and any other hosts that do not (yet) support CLAP's recommended practice of hiding internal parameter values from users and only exposing strings from value_to_text() will have an unnecessarily rough time which I believe could be alleviated if CLAP provided better guidance to plugin devs on how to implement value_to_text().

That is, use a return value of false to indicate that a particular parameter has no special way of presenting itself and can just be trivially converted to a string. This is similar to how leaving value_to_text() unimplemented indicates that none of the parameters have a special way of presenting themselves.

I understand if this is not a change you'd like to make, but to me it is better to specify the meaning of the false return value AND make it useful for certain hosts than it is to leave it unspecified and allow diverging implementations in plugins.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah i view 'false' as in 'i am unable to convert this value to a string'. for instance if you send an out of range value or haven't implemented the clap api. I don't think we should overload it to mean "I did nothing"; but rather it means "don't trust the value of the text buffer as being correctly populated". We could definitely add this to do the doc if people agree, though.

I understand and am sympathetic to the work in LMMS to rework to use strings through the editor. But I'm not that thrilled about changing the base API for that (although others may disagree). Having the param value <> string be bidirectional and both as a requirement of the plugin developer and a guide for the host author seems good.

Perhaps one solution would be to offer an LMMS specific extension where you could advertise this fact?

But also: taking a quick look at surge and the conduit plugins, I think none of our few hundred params would return true - maybe the 8 macros would but I think even those we convert to % * 100 at the edge. I'm not sure how other plugin authors would score.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Also I'm very excited for LMMS to get CLAP support; many of our users ask for quality electronic open source DAWs which can support Surge and since we don't ship a VST2 etc... if I can help separately from this issue please always do tag me in)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to be clear, this isn't a roadblock to implementing CLAP support in LMMS - it's just (in my opinion) a "nice to have" enhancement. If the value_to_text() function remains the same as it is, that's fine with me. I just figured it would be worth a shot suggesting a way to change it.

I also appreciate your offer to help regarding Surge support in LMMS. In the next few weeks, I'll be trying to get Surge to an operational state in LMMS's CLAP host, so I'll let you know if any issues come up that I don't know how to handle.

// [main-thread]
bool(CLAP_ABI *value_to_text)(const clap_plugin_t *plugin,
clap_id param_id,
double value,
char *out_buffer,
uint32_t out_buffer_capacity);

// Converts the null-terminated UTF-8 param_value_text into a double and writes it to out_value.
// Returns true on success. The host can use this to convert user input into a parameter value.
// The host can use this to convert user input into a parameter value.
// Returns true on success.
// [main-thread]
bool(CLAP_ABI *text_to_value)(const clap_plugin_t *plugin,
clap_id param_id,
Expand Down
3 changes: 3 additions & 0 deletions include/clap/ext/posix-fd-support.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,15 @@ typedef struct clap_plugin_posix_fd_support {
} clap_plugin_posix_fd_support_t;

typedef struct clap_host_posix_fd_support {
// Returns true on success.
// [main-thread]
bool(CLAP_ABI *register_fd)(const clap_host_t *host, int fd, clap_posix_fd_flags_t flags);

// Returns true on success.
// [main-thread]
bool(CLAP_ABI *modify_fd)(const clap_host_t *host, int fd, clap_posix_fd_flags_t flags);

// Returns true on success.
// [main-thread]
bool(CLAP_ABI *unregister_fd)(const clap_host_t *host, int fd);
} clap_host_posix_fd_support_t;
Expand Down
2 changes: 2 additions & 0 deletions include/clap/ext/timer-support.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ typedef struct clap_host_timer_support {
// Registers a periodic timer.
// The host may adjust the period if it is under a certain threshold.
// 30 Hz should be allowed.
// Returns true on success.
// [main-thread]
bool(CLAP_ABI *register_timer)(const clap_host_t *host, uint32_t period_ms, clap_id *timer_id);

// Returns true on success.
// [main-thread]
bool(CLAP_ABI *unregister_timer)(const clap_host_t *host, clap_id timer_id);
} clap_host_timer_support_t;
Expand Down
3 changes: 2 additions & 1 deletion include/clap/factory/draft/preset-discovery.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ typedef struct clap_preset_discovery_metadata_receiver {
// the plugin wants but it could also be some other unique id like a database primary key or a
// binary offset. It's use is entirely up to the plug-in.
//
// If the function returns false, the the provider must stop calling back into the receiver.
// If the function returns false, then the provider must stop calling back into the receiver.
bool(CLAP_ABI *begin_preset)(const struct clap_preset_discovery_metadata_receiver *receiver,
const char *name,
const char *load_key);
Expand Down Expand Up @@ -242,6 +242,7 @@ typedef struct clap_preset_discovery_provider {
void(CLAP_ABI *destroy)(const struct clap_preset_discovery_provider *provider);

// reads metadata from the given file and passes them to the metadata receiver
// Returns true on success.
bool(CLAP_ABI *get_metadata)(const struct clap_preset_discovery_provider *provider,
uint32_t location_kind,
const char *location,
Expand Down
2 changes: 2 additions & 0 deletions include/clap/plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ typedef struct clap_plugin {
// call. The process's sample rate will be constant and process's frame count will included in
// the [min, max] range, which is bounded by [1, INT32_MAX].
// Once activated the latency and port configuration must remain constant, until deactivation.
// Returns true on success.
//
// [main-thread & !active_state]
abique marked this conversation as resolved.
Show resolved Hide resolved
bool(CLAP_ABI *activate)(const struct clap_plugin *plugin,
Expand All @@ -69,6 +70,7 @@ typedef struct clap_plugin {
void(CLAP_ABI *deactivate)(const struct clap_plugin *plugin);

// Call start processing before processing.
// Returns true on success.
// [audio-thread & active_state & !processing_state]
bool(CLAP_ABI *start_processing)(const struct clap_plugin *plugin);

Expand Down
2 changes: 1 addition & 1 deletion include/clap/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ typedef struct clap_version {

#define CLAP_VERSION_MAJOR 1
#define CLAP_VERSION_MINOR 1
#define CLAP_VERSION_REVISION 9
#define CLAP_VERSION_REVISION 10

#define CLAP_VERSION_INIT \
{ (uint32_t)CLAP_VERSION_MAJOR, (uint32_t)CLAP_VERSION_MINOR, (uint32_t)CLAP_VERSION_REVISION }
Expand Down