From aa5575826830ed953e8bc4d5e3fe17baf34d7feb Mon Sep 17 00:00:00 2001 From: trinitou Date: Wed, 15 Mar 2023 04:27:27 +0100 Subject: [PATCH 1/8] gui extension: use !floating tag for some more embedded-only methods --- include/clap/ext/gui.h | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/include/clap/ext/gui.h b/include/clap/ext/gui.h index 893d620c..b43aabb3 100644 --- a/include/clap/ext/gui.h +++ b/include/clap/ext/gui.h @@ -147,8 +147,7 @@ typedef struct clap_plugin_gui { bool(CLAP_ABI *get_size)(const clap_plugin_t *plugin, uint32_t *width, uint32_t *height); // Returns true if the window is resizeable (mouse drag). - // Only for embedded windows. - // [main-thread] + // [main-thread & !floating] bool(CLAP_ABI *can_resize)(const clap_plugin_t *plugin); // Returns true if the plugin can provide hints on how to resize the window. @@ -159,16 +158,14 @@ typedef struct clap_plugin_gui { // usable size which fits in the given size. // This method does not change the size. // - // Only for embedded windows. - // // Returns true if the plugin could adjust the given size. - // [main-thread] + // [main-thread & !floating] bool(CLAP_ABI *adjust_size)(const clap_plugin_t *plugin, uint32_t *width, uint32_t *height); - // Sets the window size. Only for embedded windows. + // Sets the window size. // // Returns true if the plugin could resize its window to the given size. - // [main-thread] + // [main-thread & !floating] bool(CLAP_ABI *set_size)(const clap_plugin_t *plugin, uint32_t width, uint32_t height); // Embeds the plugin window into the given window. @@ -215,7 +212,7 @@ typedef struct clap_host_gui { * 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] */ + * [thread-safe & !floating] */ bool(CLAP_ABI *request_resize)(const clap_host_t *host, uint32_t width, uint32_t height); /* Request the host to show the plugin gui. From d8f2f33fe3394e466bf1cfe69c65efe5376d79b4 Mon Sep 17 00:00:00 2001 From: trinitou Date: Wed, 15 Mar 2023 04:32:12 +0100 Subject: [PATCH 2/8] gui extension: use !floating tag for resize_hints methods as well --- include/clap/ext/gui.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/clap/ext/gui.h b/include/clap/ext/gui.h index b43aabb3..e2d2d24a 100644 --- a/include/clap/ext/gui.h +++ b/include/clap/ext/gui.h @@ -151,7 +151,7 @@ typedef struct clap_plugin_gui { bool(CLAP_ABI *can_resize)(const clap_plugin_t *plugin); // Returns true if the plugin can provide hints on how to resize the window. - // [main-thread] + // [main-thread & !floating] bool(CLAP_ABI *get_resize_hints)(const clap_plugin_t *plugin, clap_gui_resize_hints_t *hints); // If the plugin gui is resizable, then the plugin will calculate the closest @@ -201,7 +201,7 @@ typedef struct clap_plugin_gui { typedef struct clap_host_gui { // The host should call get_resize_hints() again. - // [thread-safe] + // [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. From f6d86a7e7c9cd3da233cb9ffa8e54396000ecabf Mon Sep 17 00:00:00 2001 From: Alexandre Bique Date: Fri, 24 Mar 2023 12:31:45 +0100 Subject: [PATCH 3/8] clarify what the `plugin_path` is on macOS --- ChangeLog.md | 4 ++++ include/clap/entry.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/ChangeLog.md b/ChangeLog.md index cfd44bcd..75260c83 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,3 +1,7 @@ +# Changes in 1.1.9 + +* [entry.h](include/clap/entry.h): clarify what the `plugin_path` is on macOS + # Changes in 1.1.8 * [params.h](include/clap/ext/params.h): document how persisting parameter values between sessions should be implemented diff --git a/include/clap/entry.h b/include/clap/entry.h index 33f07948..c1f9d9c3 100644 --- a/include/clap/entry.h +++ b/include/clap/entry.h @@ -48,6 +48,8 @@ typedef struct clap_plugin_entry { // // If init() returns false, then the host must not call deinit() nor any other clap // related symbols from the DSO. + // + // plugin_path is the path to the DSO (Linux, Windows), or the bundle (macOS). bool(CLAP_ABI *init)(const char *plugin_path); // No more calls into the DSO must be made after calling deinit(). From 111858ded845bdbfd86eaf7e95b0d88115ed722e Mon Sep 17 00:00:00 2001 From: Alexandre Bique Date: Tue, 23 May 2023 17:21:06 +0200 Subject: [PATCH 4/8] Rework audio ports configuration and surround / ambisonic --- include/clap/ext/draft/ambisonic.h | 19 +++++++----- .../clap/ext/draft/configurable-audio-ports.h | 30 ++++++------------- include/clap/ext/draft/surround.h | 18 +++++------ 3 files changed, 30 insertions(+), 37 deletions(-) diff --git a/include/clap/ext/draft/ambisonic.h b/include/clap/ext/draft/ambisonic.h index 285a2979..26936023 100644 --- a/include/clap/ext/draft/ambisonic.h +++ b/include/clap/ext/draft/ambisonic.h @@ -4,7 +4,7 @@ // This extension can be used to specify the channel mapping used by the plugin. -static CLAP_CONSTEXPR const char CLAP_EXT_AMBISONIC[] = "clap.ambisonic.draft/2"; +static CLAP_CONSTEXPR const char CLAP_EXT_AMBISONIC[] = "clap.ambisonic.draft/3"; static CLAP_CONSTEXPR const char CLAP_PORT_AMBISONIC[] = "ambisonic"; @@ -28,21 +28,26 @@ enum { CLAP_AMBISONIC_NORMALIZATION_N2D = 4, }; -typedef struct clap_ambisonic_info { +typedef struct clap_ambisonic_config { uint32_t ordering; uint32_t normalization; -} clap_ambisonic_info_t; +} clap_ambisonic_config_t; typedef struct clap_plugin_ambisonic { + // Returns true if the given configuration is supported. + // [main-thread] + bool(CLAP_ABI *is_config_supported)(const clap_plugin_t *plugin, + const clap_ambisonic_config_t *config); + // Returns true on success // // config_id: the configuration id, see clap_plugin_audio_ports_config. // If config_id is CLAP_INVALID_ID, then this function queries the current port info. // [main-thread] - bool(CLAP_ABI *get_info)(const clap_plugin_t *plugin, - bool is_input, - uint32_t port_index, - clap_ambisonic_info_t *info); + bool(CLAP_ABI *get_config)(const clap_plugin_t *plugin, + bool is_input, + uint32_t port_index, + clap_ambisonic_config_t *config); } clap_plugin_ambisonic_t; diff --git a/include/clap/ext/draft/configurable-audio-ports.h b/include/clap/ext/draft/configurable-audio-ports.h index 57de8057..431363af 100644 --- a/include/clap/ext/draft/configurable-audio-ports.h +++ b/include/clap/ext/draft/configurable-audio-ports.h @@ -9,13 +9,9 @@ extern "C" { // This extension lets the host configure the plugin's input and output audio ports. // This is a "push" approach to audio ports configuration. static CLAP_CONSTEXPR const char CLAP_EXT_CONFIGURABLE_AUDIO_PORTS[] = - "clap.configurable-audio-ports.draft0"; + "clap.configurable-audio-ports.draft1"; typedef struct clap_audio_port_configuration_request { - // When true, allows the plugin to pick a similar port configuration instead - // if the requested one can't be applied. - bool is_best_effort; - // Identifies the port by is_input and port_index bool is_input; uint32_t port_index; @@ -30,27 +26,19 @@ typedef struct clap_audio_port_configuration_request { // - CLAP_PORT_MONO: (discard) // - CLAP_PORT_STEREO: (discard) // - CLAP_PORT_SURROUND: const uint8_t *channel_map - // - CLAP_PORT_AMBISONIC: const clap_ambisonic_info_t *info + // - CLAP_PORT_AMBISONIC: const clap_ambisonic_config_t *info const void *port_details; } clap_audio_port_configuration_request_t; typedef struct clap_plugin_configurable_audio_ports { - // Some ports may not be configurable, or simply the result of another port configuration. - // For example if you have a simple delay plugin, then the output port must have the exact - // same type as the input port; in that example, we consider the output port type to be a - // function (identity) of the input port type. - // [main-thread && !active] - bool(CLAP_ABI *is_port_configurable)(const clap_plugin_t *plugin, - bool is_input, - uint32_t port_index); - - // Submit a bunch of configuration requests which will atomically be applied together, - // or discarded together. + // If is_dry_run is true, then checks if the configuration can be applied. + // If is_dry_run is true, then applies the configuration. + // Returns true if applied. // [main-thread && !active] - bool(CLAP_ABI *request_configuration)( - const clap_plugin_t *plugin, - const struct clap_audio_port_configuration_request *requests, - uint32_t request_count); + bool(CLAP_ABI *apply_configuration)(const clap_plugin_t *plugin, + const struct clap_audio_port_configuration_request *requests, + uint32_t request_count, + bool is_dry_run); } clap_plugin_configurable_audio_ports_t; #ifdef __cplusplus diff --git a/include/clap/ext/draft/surround.h b/include/clap/ext/draft/surround.h index 0f612653..b54156c9 100644 --- a/include/clap/ext/draft/surround.h +++ b/include/clap/ext/draft/surround.h @@ -24,7 +24,7 @@ // 3. host calls clap_plugin_surround->get_channel_map() // 4. host activates the plugin and can start processing audio -static CLAP_CONSTEXPR const char CLAP_EXT_SURROUND[] = "clap.surround.draft/3"; +static CLAP_CONSTEXPR const char CLAP_EXT_SURROUND[] = "clap.surround.draft/4"; static CLAP_CONSTEXPR const char CLAP_PORT_SURROUND[] = "surround"; @@ -54,21 +54,21 @@ enum { }; typedef struct clap_plugin_surround { - // Stores into the channel_map array, the surround identifier of each channel. + // Checks if a given channel mask is supported. + // The channel mask is a bitmask, for example: + // (1 << CLAP_SURROUND_FL) | (1 << CLAP_SURROUND_FR) | ... + // [main-thread] + bool(CLAP_ABI *is_channel_mask_supported)(const clap_plugin_t *plugin, uint64_t channel_mask); + + // Stores the surround identifier of each channel into the channel_map array. // Returns the number of elements stored in channel_map. - // - // config_id: the configuration id, see clap_plugin_audio_ports_config. - // If config_id is CLAP_INVALID_ID, then this function queries the current port info. + // channel_map_capacity should be greater or equal to the channel count of the given port. // [main-thread] uint32_t(CLAP_ABI *get_channel_map)(const clap_plugin_t *plugin, bool is_input, uint32_t port_index, uint8_t *channel_map, uint32_t channel_map_capacity); - - // Informs the plugin that the host preferred channel map has changed. - // [main-thread] - void(CLAP_ABI *changed)(const clap_plugin_t *plugin); } clap_plugin_surround_t; typedef struct clap_host_surround { From c04dae56296e79558c046f56b68137e6e0d710b8 Mon Sep 17 00:00:00 2001 From: Alexandre Bique Date: Tue, 23 May 2023 17:23:02 +0200 Subject: [PATCH 5/8] Update changelog --- ChangeLog.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ChangeLog.md b/ChangeLog.md index 75260c83..5c0392f2 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,3 +1,9 @@ +# Changes in 1.1.10 + +* [surround.h](include/clap/ext/draft/surround.h): simplify the design +* [ambisonic.h](include/clap/ext/draft/ambisonic.h): simplify the design +* [configurable-audio-ports.h](include/clap/ext/draft/configurable-audio-ports.h): simplify the design + # Changes in 1.1.9 * [entry.h](include/clap/entry.h): clarify what the `plugin_path` is on macOS From 007a10765b744c61641be242c3a8f42dfc757cd0 Mon Sep 17 00:00:00 2001 From: Alexandre Bique Date: Tue, 23 May 2023 17:26:31 +0200 Subject: [PATCH 6/8] update changelog --- ChangeLog.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ChangeLog.md b/ChangeLog.md index 5c0392f2..8e3c01dd 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -3,6 +3,8 @@ * [surround.h](include/clap/ext/draft/surround.h): simplify the design * [ambisonic.h](include/clap/ext/draft/ambisonic.h): simplify the design * [configurable-audio-ports.h](include/clap/ext/draft/configurable-audio-ports.h): simplify the design +* [gui.h](include/clap/ext/gui.h): documentation clarifications +* [entry.h](include/clap/entry.h): documentation clarifications # Changes in 1.1.9 From d2cf8b1d26ba3509de52980523a4a7f2f2a62206 Mon Sep 17 00:00:00 2001 From: Alexandre Bique Date: Wed, 24 May 2023 00:48:35 +0200 Subject: [PATCH 7/8] Update include/clap/ext/draft/configurable-audio-ports.h Co-authored-by: Robbert van der Helm --- include/clap/ext/draft/configurable-audio-ports.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/clap/ext/draft/configurable-audio-ports.h b/include/clap/ext/draft/configurable-audio-ports.h index 431363af..dcee8f18 100644 --- a/include/clap/ext/draft/configurable-audio-ports.h +++ b/include/clap/ext/draft/configurable-audio-ports.h @@ -32,7 +32,7 @@ typedef struct clap_audio_port_configuration_request { typedef struct clap_plugin_configurable_audio_ports { // If is_dry_run is true, then checks if the configuration can be applied. - // If is_dry_run is true, then applies the configuration. + // If is_dry_run is false, then applies the configuration. // Returns true if applied. // [main-thread && !active] bool(CLAP_ABI *apply_configuration)(const clap_plugin_t *plugin, From cc53c04c389bfe26575a8b169dbe7fca7fdf80ef Mon Sep 17 00:00:00 2001 From: Alexandre Bique Date: Fri, 7 Jul 2023 16:07:04 +0200 Subject: [PATCH 8/8] Initial take on undo support --- ChangeLog.md | 4 +++ include/clap/clap.h | 1 + include/clap/ext/draft/undo.h | 63 +++++++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+) create mode 100644 include/clap/ext/draft/undo.h diff --git a/ChangeLog.md b/ChangeLog.md index 8e3c01dd..62926cc6 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -6,6 +6,10 @@ * [gui.h](include/clap/ext/gui.h): documentation clarifications * [entry.h](include/clap/entry.h): documentation clarifications +## Draft extensions + +* [undo.h](include/clap/ext/draft/undo.h): undo support + # Changes in 1.1.9 * [entry.h](include/clap/entry.h): clarify what the `plugin_path` is on macOS diff --git a/include/clap/clap.h b/include/clap/clap.h index e57dbf44..16aebba2 100644 --- a/include/clap/clap.h +++ b/include/clap/clap.h @@ -69,3 +69,4 @@ #include "ext/draft/tuning.h" #include "ext/draft/configurable-audio-ports.h" #include "ext/draft/extensible-audio-ports.h" +#include "ext/draft/undo.h" diff --git a/include/clap/ext/draft/undo.h b/include/clap/ext/draft/undo.h new file mode 100644 index 00000000..d5975e51 --- /dev/null +++ b/include/clap/ext/draft/undo.h @@ -0,0 +1,63 @@ +#pragma once + +#include "../../plugin.h" +#include "../../string-sizes.h" + +static CLAP_CONSTEXPR const char CLAP_EXT_UNDO[] = "clap.undo.draft/0"; + +// Describes an undo step +typedef struct clap_undo_info { + // This is the unique identifier of this undo step. + // It is valid until loading a state or destroying the plugin. + clap_id id; + + // A short string which describes the corresponding change. + char description[CLAP_NAME_SIZE]; +} clap_undo_info_t; + +typedef struct clap_plugin_undo { + // returns true if an undo/redo step exists and the info were provided + // [main-thread] + bool (*get_current_undo_info)(clap_plugin_t *plugin, clap_undo_info_t *info); + bool (*get_current_redo_info)(clap_plugin_t *plugin, clap_undo_info_t *info); + + // request the plugin to perform an undo operation (async) + // returns true if the request is being processed, false otherwise. + // when returning true, the plugin must call clap_host_undo->after_undo_request() once the + // request is completed or failed. + // + // The plugin should only perform the operation if the current + // undo/redo operation matches the given id; this is because of the asynchronous nature of the + // task and to avoid race conditions if the plugin's undo manager lives in a different thread. + // + // [main-thread] + bool (*request_undo)(clap_plugin_t *plugin, clap_id id); + bool (*request_redo)(clap_plugin_t *plugin, clap_id id); +} clap_plugin_undo_t; + +typedef struct clap_host_undo { + // Marks the begining and end of a change which will lead to the creation of an undo step. + // [main-thread] + void (*begin_changes)(clap_host_t *host, const clap_undo_info_t *info); + void (*end_changes)(clap_host_t *host, const clap_undo_info_t *info); + + // Marks the beginning and end of processing an undo change. + // [main-thread] + void (*begin_undo)(clap_host_t *host, const clap_undo_info_t *info); + void (*end_undo)(clap_host_t *host, const clap_undo_info_t *info); + + // Marks the beginning and end of processing a redo change. + // [main-thread] + void (*begin_redo)(clap_host_t *host, const clap_undo_info_t *info); + void (*end_redo)(clap_host_t *host, const clap_undo_info_t *info); + + // A destructive change happened which makes it impossible to perform an undo. + // The entire plugin's undo/redo stack has been cleared. + // [main-thread] + void (*after_destructive_change)(clap_host_t *host); + + // Callbacks for clap_plugin_undo->request_*() + // [main-thread] + void (*after_undo_request)(clap_host_t *host, clap_id id, bool succeed, const char *error_msg); + void (*after_redo_request)(clap_host_t *host, clap_id id, bool succeed, const char *error_msg); +} clap_host_undo_t;