From aa5575826830ed953e8bc4d5e3fe17baf34d7feb Mon Sep 17 00:00:00 2001 From: trinitou Date: Wed, 15 Mar 2023 04:27:27 +0100 Subject: [PATCH 01/29] 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 02/29] 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 03/29] 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 04/29] 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 05/29] 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 06/29] 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 07/29] 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 a4e1605d37dae9c6943b288ea6a73bbbccb53f7e Mon Sep 17 00:00:00 2001 From: Alexandre Bique Date: Fri, 7 Jul 2023 16:07:04 +0200 Subject: [PATCH 08/29] Introduce incremental state --- ChangeLog.md | 4 ++ include/clap/clap.h | 1 + include/clap/ext/draft/incremental-state.h | 50 ++++++++++++++++++++++ 3 files changed, 55 insertions(+) create mode 100644 include/clap/ext/draft/incremental-state.h diff --git a/ChangeLog.md b/ChangeLog.md index 8e3c01dd..a7832091 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 + +* [incremental-state.h](include/clap/ext/draft/incremental-state.h): incremental state + # 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..b33579ee 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/incremental-state.h" diff --git a/include/clap/ext/draft/incremental-state.h b/include/clap/ext/draft/incremental-state.h new file mode 100644 index 00000000..a62cef24 --- /dev/null +++ b/include/clap/ext/draft/incremental-state.h @@ -0,0 +1,50 @@ +#pragma once + +#include "../../plugin.h" + +static CLAP_CONSTEXPR const char CLAP_EXT_INCREMENTAL_STATE[] = "clap.incremental-state.draft/0"; + +// This extension is useful for the host to collect incremental changes instead of saving the plugin +// state after each changes. +// +// The typical use case is for crash recovery: +// 1. the host saves the entire project (expensive) +// 2. many things, happens and the host saves little delta operations to disk (cheap) +// 3. the application crashes +// +// Then once the application is restarted, the user can decide to recover the project which will +// work as follow: +// 1. open the last project state +// 2. apply all the deltas in sequence +// 3. project is ready and should be in the same state as it was before the crash +// +// Saving a project, can be an expensive task especially for large project and can +// cause playback performance issues. +// This is why saving deltas is interesting because it is lightweight. +// +// This interface is not meant to replace saving the entire project. +// +// If the plugin decides to implement this interface, it should then be able to encode +// the deltas in a space efficient way. +// +// The plugin can assume that the delta will be applied on the same computer as the +// one used to produce it. Meaning that it doesn't have to take care of endianness +// and can store path to files on the computer. + +typedef struct clap_plugin_incremental_state { + // [main-thread] + bool (*apply_delta)(clap_plugin_t *plugin, const char *data, size_t size); +} clap_plugin_incremental_state_t; + +typedef struct clap_host_incremental_state { + // Adds a delta, its size should be reasonably small. + // + // [main-thread] + void (*add_delta)(clap_host_t *host, const char *data, size_t size); + + // One change happened which can't be encoded as a delta, and requires + // the host to save the entire state again. + // + // [main-thread] + void (*save_is_required)(clap_host_t *host); +} clap_host_incremental_state_t; From cc53c04c389bfe26575a8b169dbe7fca7fdf80ef Mon Sep 17 00:00:00 2001 From: Alexandre Bique Date: Fri, 7 Jul 2023 16:07:04 +0200 Subject: [PATCH 09/29] 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; From 5c9612d19af69f1af8542a3e79870ca3900329e3 Mon Sep 17 00:00:00 2001 From: Alexandre Bique Date: Mon, 10 Jul 2023 12:46:03 +0200 Subject: [PATCH 10/29] undo: try to clarify the call sequence and use change_id instead of id --- include/clap/ext/draft/undo.h | 56 +++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 22 deletions(-) diff --git a/include/clap/ext/draft/undo.h b/include/clap/ext/draft/undo.h index d5975e51..e39e4daf 100644 --- a/include/clap/ext/draft/undo.h +++ b/include/clap/ext/draft/undo.h @@ -5,51 +5,56 @@ static CLAP_CONSTEXPR const char CLAP_EXT_UNDO[] = "clap.undo.draft/0"; -// Describes an undo step -typedef struct clap_undo_info { +// Describes a change which can be undone or redone +typedef struct clap_undo_change_info { // This is the unique identifier of this undo step. // It is valid until loading a state or destroying the plugin. - clap_id id; + clap_id change_id; // A short string which describes the corresponding change. char description[CLAP_NAME_SIZE]; -} clap_undo_info_t; +} clap_undo_change_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); + bool (*get_current_undo_info)(clap_plugin_t *plugin, clap_undo_change_info_t *info); + bool (*get_current_redo_info)(clap_plugin_t *plugin, clap_undo_change_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 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. + // 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. // + // Call sequence: + // 1. plugin->request_undo(change_id=X) -> returns true + // 2. later on host->begin_undo(change_id=X) + // 3. later on host->end_undo(change_id=X), host->after_undo(change_id=X, true, nullptr) // [main-thread] - bool (*request_undo)(clap_plugin_t *plugin, clap_id id); - bool (*request_redo)(clap_plugin_t *plugin, clap_id id); + bool (*request_undo)(clap_plugin_t *plugin, clap_id change_id); + bool (*request_redo)(clap_plugin_t *plugin, clap_id change_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); + void (*begin_changes)(clap_host_t *host, const clap_undo_change_info_t *info); + void (*end_changes)(clap_host_t *host, const clap_undo_change_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); + void (*begin_undo)(clap_host_t *host, const clap_undo_change_info_t *info); + void (*end_undo)(clap_host_t *host, const clap_undo_change_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); + void (*begin_redo)(clap_host_t *host, const clap_undo_change_info_t *info); + void (*end_redo)(clap_host_t *host, const clap_undo_change_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. @@ -57,7 +62,14 @@ typedef struct clap_host_undo { void (*after_destructive_change)(clap_host_t *host); // Callbacks for clap_plugin_undo->request_*() + // If succeed is true, then error_msg is ignored and may be null. // [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); + void (*after_undo_request)(clap_host_t *host, + clap_id change_id, + bool succeed, + const char *error_msg); + void (*after_redo_request)(clap_host_t *host, + clap_id change_id, + bool succeed, + const char *error_msg); } clap_host_undo_t; From b768df6fe2a21780f453bf7f822192011739e076 Mon Sep 17 00:00:00 2001 From: jatin Date: Mon, 10 Jul 2023 13:58:36 -0700 Subject: [PATCH 11/29] Adding compile test for version macros --- CMakeLists.txt | 4 ++++ src/main.cc | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index c386acf0..8773c35f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -60,6 +60,10 @@ if (${CLAP_BUILD_TESTS}) add_test(NAME test-clap-compile-${SUFFIX} COMMAND clap-compile-${SUFFIX}) add_dependencies(clap-tests clap-compile-${SUFFIX}) + if (${EXT} STREQUAL "cc") + target_compile_definitions(clap-compile-${SUFFIX} PRIVATE CLAP_COMPILE_TEST_CXX_VERSION=${STDCPP}) + endif() + if (${CMAKE_C_COMPILER_ID} STREQUAL "GNU" OR ${CMAKE_C_COMPILER_ID} STREQUAL "Clang") target_compile_options(clap-compile-${SUFFIX} PRIVATE -Wall -Wextra -pedantic) endif() diff --git a/src/main.cc b/src/main.cc index 949d0bb8..80febfba 100644 --- a/src/main.cc +++ b/src/main.cc @@ -48,6 +48,18 @@ #error CLAP_VERSION_LT is inconsistent (REVISION) #endif +#if (CLAP_COMPILE_TEST_CXX_VERSION >= 11) && ! defined(CLAP_HAS_CXX11) +#error CLAP_HAS_CXX11 is not defined correctly +#endif + +#if (CLAP_COMPILE_TEST_CXX_VERSION >= 17) && ! defined(CLAP_HAS_CXX17) +#error CLAP_HAS_CXX17 is not defined correctly +#endif + +#if (CLAP_COMPILE_TEST_CXX_VERSION >= 20) && ! defined(CLAP_HAS_CXX20) +#error CLAP_HAS_CXX20 is not defined correctly +#endif + static const CLAP_CONSTEXPR clap_version m = CLAP_VERSION; int main(int, char **) { From 5c8b26d06ff67f580c9d0449bf697cba50d87a43 Mon Sep 17 00:00:00 2001 From: jatin Date: Mon, 10 Jul 2023 14:05:22 -0700 Subject: [PATCH 12/29] Trying to get msvc build happening on CI --- .github/workflows/cmake.yml | 11 ++++++++++- CMakePresets.json | 30 ++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 88040a96..7b9ccd9a 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -39,8 +39,17 @@ jobs: - name: Run CMake+Ninja+CTest to generate/build/test. uses: lukka/run-cmake@v10 - id: runcmake + id: runcmake-ninja with: configurePreset: 'ninja' buildPreset: 'ninja-release' testPreset: 'ninja-release' + + - name: Run CMake+MSVC+CTest to generate/build/test. + uses: lukka/run-cmake@v10 + if: startsWith(matrix.os, 'win') + id: runcmake-msvc + with: + configurePreset: 'msvc' + buildPreset: 'msvc-release' + testPreset: 'msvc-release' diff --git a/CMakePresets.json b/CMakePresets.json index d707bfb9..bd0b1c51 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -22,6 +22,23 @@ "value": true } } + }, + { + "name": "msvc", + "displayName": "MSVC", + "description": "Configure and generate MSVC project files for all configurations", + "binaryDir": "${sourceDir}/builds/${presetName}", + "generator": "Visual Studio 17 2022", + "cacheVariables": { + "CMAKE_EXPORT_COMPILE_COMMANDS": { + "type": "boolean", + "value": true + }, + "CLAP_BUILD_TESTS": { + "type": "boolean", + "value": true + } + } } ], "buildPresets": [ @@ -32,6 +49,14 @@ "description": "Build ninja Release configuration", "configuration": "RelWithDebInfo", "targets": ["clap-tests"] + }, + { + "name": "msvc-release", + "configurePreset": "msvc", + "displayName": "Build msvc-release", + "description": "Build msvc Release configuration", + "configuration": "RelWithDebInfo", + "targets": ["clap-tests"] } ], "testPresets": [ @@ -39,6 +64,11 @@ "name": "ninja-release", "configurePreset": "ninja", "configuration": "RelWithDebInfo" + }, + { + "name": "msvc-release", + "configurePreset": "msvc", + "configuration": "RelWithDebInfo" } ] } \ No newline at end of file From d23d576a9d96f23c58b529d803053333ac127918 Mon Sep 17 00:00:00 2001 From: jatin Date: Mon, 10 Jul 2023 14:12:37 -0700 Subject: [PATCH 13/29] Add MSVC bypass for getting C++ version macro --- include/clap/private/macros.h | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/include/clap/private/macros.h b/include/clap/private/macros.h index 15b6b1b3..0281de23 100644 --- a/include/clap/private/macros.h +++ b/include/clap/private/macros.h @@ -25,20 +25,28 @@ # endif #endif -#if defined(__cplusplus) && __cplusplus >= 201103L +#if defined(__cplusplus) +# if MSVC +# define CLAP_CPLUSPLUS _MSVC_LANG +# else +# define CLAP_CPLUSPLUS __cplusplus +# endif +#endif + +#if defined(CLAP_CPLUSPLUS) && CLAP_CPLUSPLUS >= 201103L # define CLAP_HAS_CXX11 # define CLAP_CONSTEXPR constexpr #else # define CLAP_CONSTEXPR #endif -#if defined(__cplusplus) && __cplusplus >= 201703L +#if defined(CLAP_CPLUSPLUS) && CLAP_CPLUSPLUS >= 201703L # define CLAP_HAS_CXX17 # define CLAP_NODISCARD [[nodiscard]] #else # define CLAP_NODISCARD #endif -#if defined(__cplusplus) && __cplusplus >= 202002L +#if defined(CLAP_CPLUSPLUS) && CLAP_CPLUSPLUS >= 202002L # define CLAP_HAS_CXX20 #endif From e661d1caa56deac3dc207af2445738b93e84e5a0 Mon Sep 17 00:00:00 2001 From: Jatin Chowdhury Date: Mon, 10 Jul 2023 14:32:43 -0700 Subject: [PATCH 14/29] Different strategy for definitions check --- include/clap/private/macros.h | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/include/clap/private/macros.h b/include/clap/private/macros.h index 0281de23..ba1d6656 100644 --- a/include/clap/private/macros.h +++ b/include/clap/private/macros.h @@ -25,12 +25,10 @@ # endif #endif -#if defined(__cplusplus) -# if MSVC -# define CLAP_CPLUSPLUS _MSVC_LANG -# else -# define CLAP_CPLUSPLUS __cplusplus -# endif +#if defined(_MSVC_LANG) +# define CLAP_CPLUSPLUS _MSVC_LANG +#elif defined(__cplusplus) +# define CLAP_CPLUSPLUS __cplusplus #endif #if defined(CLAP_CPLUSPLUS) && CLAP_CPLUSPLUS >= 201103L From 92f4a63502b91a610d060ae0e498d914cf49602b Mon Sep 17 00:00:00 2001 From: Alexandre Bique Date: Tue, 11 Jul 2023 16:37:40 +0200 Subject: [PATCH 15/29] Update include/clap/ext/draft/undo.h Co-authored-by: Trinitou <106991375+Trinitou@users.noreply.github.com> --- include/clap/ext/draft/undo.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/clap/ext/draft/undo.h b/include/clap/ext/draft/undo.h index e39e4daf..84204e6e 100644 --- a/include/clap/ext/draft/undo.h +++ b/include/clap/ext/draft/undo.h @@ -43,8 +43,8 @@ typedef struct clap_plugin_undo { 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_change_info_t *info); - void (*end_changes)(clap_host_t *host, const clap_undo_change_info_t *info); + void (*begin_change)(clap_host_t *host, const clap_undo_change_info_t *info); + void (*end_change)(clap_host_t *host, const clap_undo_change_info_t *info); // Marks the beginning and end of processing an undo change. // [main-thread] From fe8d233c1275ee5d665fe75c438f7fd14b9dd3e6 Mon Sep 17 00:00:00 2001 From: xris1658 Date: Wed, 19 Jul 2023 12:09:31 +0800 Subject: [PATCH 16/29] Fix typo filed -> field --- include/clap/ext/audio-ports.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/clap/ext/audio-ports.h b/include/clap/ext/audio-ports.h index d5b4a040..46186e76 100644 --- a/include/clap/ext/audio-ports.h +++ b/include/clap/ext/audio-ports.h @@ -49,7 +49,7 @@ typedef struct clap_audio_port_info { uint32_t channel_count; // If null or empty then it is unspecified (arbitrary audio). - // This filed can be compared against: + // This field can be compared against: // - CLAP_PORT_MONO // - CLAP_PORT_STEREO // - CLAP_PORT_SURROUND (defined in the surround extension) From 6062f41198fc42d9fe197345f0a5f64edbdca92a Mon Sep 17 00:00:00 2001 From: luzpaz Date: Sun, 6 Aug 2023 09:23:22 -0400 Subject: [PATCH 17/29] Fix various typos --- ChangeLog.md | 2 +- include/clap/ext/draft/resource-directory.h | 2 +- include/clap/ext/gui.h | 2 +- include/clap/factory/draft/preset-discovery.h | 2 +- include/clap/plugin.h | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index cfd44bcd..63979c5a 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -126,7 +126,7 @@ it is now **required** to deactivate the plugin before destroying it. * [params.h](include/clap/ext/params.h): improve documentation for `clap_host_params->request_flush()`. * [entry.h](include/clap/entry.h): improve documentation regarding `init()`, `deinit()` and CLAP search path. -* [gui.h](inclued/clap/gui.h): fix typo `clap_gui_resize_hints.preserve_aspect_ratio` +* [gui.h](include/clap/gui.h): fix typo `clap_gui_resize_hints.preserve_aspect_ratio` * [plugin-template](src/plugin-template.c): missing impl of plugin destroy. * various documentation improvements diff --git a/include/clap/ext/draft/resource-directory.h b/include/clap/ext/draft/resource-directory.h index 1d96da5f..fc65eaa8 100644 --- a/include/clap/ext/draft/resource-directory.h +++ b/include/clap/ext/draft/resource-directory.h @@ -44,7 +44,7 @@ extern "C" { typedef struct clap_plugin_resource_directory { // Sets the directory in which the plugin can save its resources. - // The directory remains valid until it is overriden or the plugin is destroyed. + // The directory remains valid until it is overridden or the plugin is destroyed. // If path is null or blank, it clears the directory location. // path must be absolute. // [main-thread] diff --git a/include/clap/ext/gui.h b/include/clap/ext/gui.h index 893d620c..13bb591c 100644 --- a/include/clap/ext/gui.h +++ b/include/clap/ext/gui.h @@ -118,7 +118,7 @@ typedef struct clap_plugin_gui { // // After this call, the GUI may not be visible yet; don't forget to call show(). // - // Returns true if the GUI is successfuly created. + // Returns true if the GUI is successfully created. // [main-thread] bool(CLAP_ABI *create)(const clap_plugin_t *plugin, const char *api, bool is_floating); diff --git a/include/clap/factory/draft/preset-discovery.h b/include/clap/factory/draft/preset-discovery.h index 76a2e6ac..db26f1e9 100644 --- a/include/clap/factory/draft/preset-discovery.h +++ b/include/clap/factory/draft/preset-discovery.h @@ -61,7 +61,7 @@ enum clap_preset_discovery_location_kind { CLAP_PRESET_DISCOVERY_LOCATION_FILE = 0, // The preset is bundled within the plugin DSO itself. - // The location must then be null, as the preset are within the plugin itsel and then the plugin + // The location must then be null, as the preset are within the plugin itself and then the plugin // will act as a preset container. CLAP_PRESET_DISCOVERY_LOCATION_PLUGIN = 1, }; diff --git a/include/clap/plugin.h b/include/clap/plugin.h index e366e051..2fd6530d 100644 --- a/include/clap/plugin.h +++ b/include/clap/plugin.h @@ -16,7 +16,7 @@ typedef struct clap_plugin_descriptor { // Otherwise the fields can be null or blank, though it is safer to make them blank. // // Some indications regarding id and version - // - id is an arbritrary string which should be unique to your plugin, + // - id is an arbitrary string which should be unique to your plugin, // we encourage you to use a reverse URI eg: "com.u-he.diva" // - version is an arbitrary string which describes a plugin, // it is useful for the host to understand and be able to compare two different From c56eaa9aee042031ebb31f073a416f13d5d12bb2 Mon Sep 17 00:00:00 2001 From: Alexandre Bique Date: Tue, 15 Aug 2023 11:13:40 +0200 Subject: [PATCH 18/29] specify the sample size to be used when activating the audio port Fixes #321 --- ChangeLog.md | 1 + include/clap/ext/draft/audio-ports-activation.h | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 4c450dcf..fde73e30 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -5,6 +5,7 @@ * [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 +* [audio-ports-activation.h](include/clap/ext/draft/audio-ports-activation.h): specify the sample size to be used when activating the audio port. ## Draft extensions diff --git a/include/clap/ext/draft/audio-ports-activation.h b/include/clap/ext/draft/audio-ports-activation.h index 63fb31e8..f451c005 100644 --- a/include/clap/ext/draft/audio-ports-activation.h +++ b/include/clap/ext/draft/audio-ports-activation.h @@ -26,7 +26,7 @@ /// clap_host_audio_ports.rescan(CLAP_AUDIO_PORTS_RESCAN_LIST). static CLAP_CONSTEXPR const char CLAP_EXT_AUDIO_PORTS_ACTIVATION[] = - "clap.audio-ports-activation/draft-1"; + "clap.audio-ports-activation/draft-2"; #ifdef __cplusplus extern "C" { @@ -42,12 +42,16 @@ typedef struct clap_plugin_audio_ports_activation { // It is only possible to activate and de-activate on the audio-thread if // can_activate_while_processing() returns true. // + // sample_size indicate if the host will provide 32 bit audio buffers or 64 bits one. + // Possible values are: 32, 64 or 0 if unspecified. + // // returns false if failed, or invalid parameters // [active ? audio-thread : main-thread] bool(CLAP_ABI *set_active)(const clap_plugin_t *plugin, bool is_input, uint32_t port_index, - bool is_active); + bool is_active, + uint32_t sample_size); } clap_plugin_audio_ports_activation_t; #ifdef __cplusplus From 48803fe177db696f982a19339ed9899bc98ecf4c Mon Sep 17 00:00:00 2001 From: Alexandre Bique Date: Tue, 15 Aug 2023 11:27:56 +0200 Subject: [PATCH 19/29] Cleanup changelog --- ChangeLog.md | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 5e9ead22..26a20f83 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,5 +1,6 @@ -# Changes in 1.1.10 +# Changes in 1.1.9 +* [entry.h](include/clap/entry.h): clarify what the `plugin_path` is on macOS * [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 @@ -10,15 +11,8 @@ ## Draft extensions * [undo.h](include/clap/ext/draft/undo.h): undo support - -## Draft Extensions - * [incremental-state.h](include/clap/ext/draft/incremental-state.h): incremental state -# 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 From dcd29e318c87915263a62bc8b53df1725f71ddd9 Mon Sep 17 00:00:00 2001 From: defiantnerd <97224712+defiantnerd@users.noreply.github.com> Date: Wed, 11 Oct 2023 14:24:25 +0200 Subject: [PATCH 20/29] clarify latency is defined in samples using the same wording as in tail extension to clarify details. --- include/clap/ext/latency.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/clap/ext/latency.h b/include/clap/ext/latency.h index ca068cab..862b3341 100644 --- a/include/clap/ext/latency.h +++ b/include/clap/ext/latency.h @@ -10,7 +10,7 @@ extern "C" { // The audio ports scan has to be done while the plugin is deactivated. typedef struct clap_plugin_latency { - // Returns the plugin latency. + // Returns the plugin latency in samples. // [main-thread] uint32_t(CLAP_ABI *get)(const clap_plugin_t *plugin); } clap_plugin_latency_t; From f9dffddcdc08b7f889ac1bf3d747963c6c619186 Mon Sep 17 00:00:00 2001 From: Alexandre Bique Date: Tue, 17 Oct 2023 10:22:04 +0200 Subject: [PATCH 21/29] Remove undo and incremental state as the design isn't ready yet and needs more work --- ChangeLog.md | 5 -- include/clap/ext/draft/incremental-state.h | 50 --------------- include/clap/ext/draft/undo.h | 75 ---------------------- 3 files changed, 130 deletions(-) delete mode 100644 include/clap/ext/draft/incremental-state.h delete mode 100644 include/clap/ext/draft/undo.h diff --git a/ChangeLog.md b/ChangeLog.md index 26a20f83..cce7a328 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -8,11 +8,6 @@ * [entry.h](include/clap/entry.h): documentation clarifications * [audio-ports-activation.h](include/clap/ext/draft/audio-ports-activation.h): specify the sample size to be used when activating the audio port. -## Draft extensions - -* [undo.h](include/clap/ext/draft/undo.h): undo support -* [incremental-state.h](include/clap/ext/draft/incremental-state.h): incremental state - # 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/ext/draft/incremental-state.h b/include/clap/ext/draft/incremental-state.h deleted file mode 100644 index a62cef24..00000000 --- a/include/clap/ext/draft/incremental-state.h +++ /dev/null @@ -1,50 +0,0 @@ -#pragma once - -#include "../../plugin.h" - -static CLAP_CONSTEXPR const char CLAP_EXT_INCREMENTAL_STATE[] = "clap.incremental-state.draft/0"; - -// This extension is useful for the host to collect incremental changes instead of saving the plugin -// state after each changes. -// -// The typical use case is for crash recovery: -// 1. the host saves the entire project (expensive) -// 2. many things, happens and the host saves little delta operations to disk (cheap) -// 3. the application crashes -// -// Then once the application is restarted, the user can decide to recover the project which will -// work as follow: -// 1. open the last project state -// 2. apply all the deltas in sequence -// 3. project is ready and should be in the same state as it was before the crash -// -// Saving a project, can be an expensive task especially for large project and can -// cause playback performance issues. -// This is why saving deltas is interesting because it is lightweight. -// -// This interface is not meant to replace saving the entire project. -// -// If the plugin decides to implement this interface, it should then be able to encode -// the deltas in a space efficient way. -// -// The plugin can assume that the delta will be applied on the same computer as the -// one used to produce it. Meaning that it doesn't have to take care of endianness -// and can store path to files on the computer. - -typedef struct clap_plugin_incremental_state { - // [main-thread] - bool (*apply_delta)(clap_plugin_t *plugin, const char *data, size_t size); -} clap_plugin_incremental_state_t; - -typedef struct clap_host_incremental_state { - // Adds a delta, its size should be reasonably small. - // - // [main-thread] - void (*add_delta)(clap_host_t *host, const char *data, size_t size); - - // One change happened which can't be encoded as a delta, and requires - // the host to save the entire state again. - // - // [main-thread] - void (*save_is_required)(clap_host_t *host); -} clap_host_incremental_state_t; diff --git a/include/clap/ext/draft/undo.h b/include/clap/ext/draft/undo.h deleted file mode 100644 index 84204e6e..00000000 --- a/include/clap/ext/draft/undo.h +++ /dev/null @@ -1,75 +0,0 @@ -#pragma once - -#include "../../plugin.h" -#include "../../string-sizes.h" - -static CLAP_CONSTEXPR const char CLAP_EXT_UNDO[] = "clap.undo.draft/0"; - -// Describes a change which can be undone or redone -typedef struct clap_undo_change_info { - // This is the unique identifier of this undo step. - // It is valid until loading a state or destroying the plugin. - clap_id change_id; - - // A short string which describes the corresponding change. - char description[CLAP_NAME_SIZE]; -} clap_undo_change_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_change_info_t *info); - bool (*get_current_redo_info)(clap_plugin_t *plugin, clap_undo_change_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. - // - // Call sequence: - // 1. plugin->request_undo(change_id=X) -> returns true - // 2. later on host->begin_undo(change_id=X) - // 3. later on host->end_undo(change_id=X), host->after_undo(change_id=X, true, nullptr) - // [main-thread] - bool (*request_undo)(clap_plugin_t *plugin, clap_id change_id); - bool (*request_redo)(clap_plugin_t *plugin, clap_id change_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_change)(clap_host_t *host, const clap_undo_change_info_t *info); - void (*end_change)(clap_host_t *host, const clap_undo_change_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_change_info_t *info); - void (*end_undo)(clap_host_t *host, const clap_undo_change_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_change_info_t *info); - void (*end_redo)(clap_host_t *host, const clap_undo_change_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_*() - // If succeed is true, then error_msg is ignored and may be null. - // [main-thread] - void (*after_undo_request)(clap_host_t *host, - clap_id change_id, - bool succeed, - const char *error_msg); - void (*after_redo_request)(clap_host_t *host, - clap_id change_id, - bool succeed, - const char *error_msg); -} clap_host_undo_t; From 92d7ebe55dafa47c20b9b5d5543b35abc21c4600 Mon Sep 17 00:00:00 2001 From: Alexandre Bique Date: Tue, 17 Oct 2023 10:23:39 +0200 Subject: [PATCH 22/29] Forgot to remove this include --- include/clap/clap.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/include/clap/clap.h b/include/clap/clap.h index 72fab306..e57dbf44 100644 --- a/include/clap/clap.h +++ b/include/clap/clap.h @@ -69,5 +69,3 @@ #include "ext/draft/tuning.h" #include "ext/draft/configurable-audio-ports.h" #include "ext/draft/extensible-audio-ports.h" -#include "ext/draft/incremental-state.h" -#include "ext/draft/undo.h" From 18922fad9d7e378721433904dbabf100f4f841b1 Mon Sep 17 00:00:00 2001 From: Alexandre Bique Date: Tue, 17 Oct 2023 13:43:47 +0200 Subject: [PATCH 23/29] Update version.h to 1.1.9 --- include/clap/version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/clap/version.h b/include/clap/version.h index ff45ddf5..1b9cc234 100644 --- a/include/clap/version.h +++ b/include/clap/version.h @@ -22,7 +22,7 @@ typedef struct clap_version { #define CLAP_VERSION_MAJOR 1 #define CLAP_VERSION_MINOR 1 -#define CLAP_VERSION_REVISION 8 +#define CLAP_VERSION_REVISION 9 #define CLAP_VERSION_INIT \ { (uint32_t)CLAP_VERSION_MAJOR, (uint32_t)CLAP_VERSION_MINOR, (uint32_t)CLAP_VERSION_REVISION } From 4a2aefc0963afd3dccd55b1ae2ccdce0b34391ed Mon Sep 17 00:00:00 2001 From: trinitou Date: Tue, 17 Oct 2023 22:32:06 +0200 Subject: [PATCH 24/29] Clarify ambisonic enums --- include/clap/ext/draft/ambisonic.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/include/clap/ext/draft/ambisonic.h b/include/clap/ext/draft/ambisonic.h index 26936023..556af9a6 100644 --- a/include/clap/ext/draft/ambisonic.h +++ b/include/clap/ext/draft/ambisonic.h @@ -12,15 +12,15 @@ static CLAP_CONSTEXPR const char CLAP_PORT_AMBISONIC[] = "ambisonic"; extern "C" { #endif -enum { +enum clap_ambisonic_ordering { // FuMa channel ordering - CLAP_AMBISONIC_FUMA = 0, + CLAP_AMBISONIC_ORDERING_FUMA = 0, // ACN channel ordering - CLAP_AMBISONIC_ACN = 1, + CLAP_AMBISONIC_ORDERING_ACN = 1, }; -enum { +enum clap_ambisonic_normalization { CLAP_AMBISONIC_NORMALIZATION_MAXN = 0, CLAP_AMBISONIC_NORMALIZATION_SN3D = 1, CLAP_AMBISONIC_NORMALIZATION_N3D = 2, @@ -29,8 +29,8 @@ enum { }; typedef struct clap_ambisonic_config { - uint32_t ordering; - uint32_t normalization; + uint32_t ordering; // see clap_ambisonic_ordering + uint32_t normalization; // see clap_ambisonic_normalization } clap_ambisonic_config_t; typedef struct clap_plugin_ambisonic { From b31b26a0a1532115e08dc48b6c5c29519f76573c Mon Sep 17 00:00:00 2001 From: Alexandre Bique Date: Wed, 18 Oct 2023 10:13:10 +0200 Subject: [PATCH 25/29] Update include/clap/ext/draft/surround.h Co-authored-by: Trinitou <106991375+Trinitou@users.noreply.github.com> --- include/clap/ext/draft/surround.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/clap/ext/draft/surround.h b/include/clap/ext/draft/surround.h index b54156c9..82f4e888 100644 --- a/include/clap/ext/draft/surround.h +++ b/include/clap/ext/draft/surround.h @@ -62,7 +62,7 @@ typedef struct clap_plugin_surround { // Stores the surround identifier of each channel into the channel_map array. // Returns the number of elements stored in channel_map. - // channel_map_capacity should be greater or equal to the channel count of the given port. + // channel_map_capacity must 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, From 98df4531c92b99e53bd62cc9c5b4d5c92712d97c Mon Sep 17 00:00:00 2001 From: Alexandre Bique Date: Wed, 18 Oct 2023 12:57:29 +0200 Subject: [PATCH 26/29] Doc. --- include/clap/ext/draft/configurable-audio-ports.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/clap/ext/draft/configurable-audio-ports.h b/include/clap/ext/draft/configurable-audio-ports.h index dcee8f18..58c382a8 100644 --- a/include/clap/ext/draft/configurable-audio-ports.h +++ b/include/clap/ext/draft/configurable-audio-ports.h @@ -31,6 +31,9 @@ typedef struct clap_audio_port_configuration_request { } clap_audio_port_configuration_request_t; typedef struct clap_plugin_configurable_audio_ports { + // 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 false, then applies the configuration. // Returns true if applied. From 093141f6eb25ded8dce095f067d6086f06bd59de Mon Sep 17 00:00:00 2001 From: Alexandre Bique Date: Wed, 18 Oct 2023 13:01:13 +0200 Subject: [PATCH 27/29] remove is_dry_run and make two functions instead --- include/clap/ext/draft/configurable-audio-ports.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/include/clap/ext/draft/configurable-audio-ports.h b/include/clap/ext/draft/configurable-audio-ports.h index 58c382a8..8a709d9c 100644 --- a/include/clap/ext/draft/configurable-audio-ports.h +++ b/include/clap/ext/draft/configurable-audio-ports.h @@ -31,17 +31,21 @@ typedef struct clap_audio_port_configuration_request { } clap_audio_port_configuration_request_t; typedef struct clap_plugin_configurable_audio_ports { + // Returns true if the given configurations can be applied using apply_configuration(). + // [main-thread && !active] + bool(CLAP_ABI *can_apply_configuration)( + const clap_plugin_t *plugin, + const struct clap_audio_port_configuration_request *requests, + uint32_t request_count); + // 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 false, then applies the configuration. // Returns true if applied. // [main-thread && !active] 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); + uint32_t request_count); } clap_plugin_configurable_audio_ports_t; #ifdef __cplusplus From 08d6b5efab0753838a95b600c90f36e1fffc78fd Mon Sep 17 00:00:00 2001 From: Alexandre Bique Date: Wed, 18 Oct 2023 13:06:51 +0200 Subject: [PATCH 28/29] Doc. --- include/clap/ext/draft/configurable-audio-ports.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/clap/ext/draft/configurable-audio-ports.h b/include/clap/ext/draft/configurable-audio-ports.h index 8a709d9c..4fe60cd1 100644 --- a/include/clap/ext/draft/configurable-audio-ports.h +++ b/include/clap/ext/draft/configurable-audio-ports.h @@ -41,6 +41,10 @@ typedef struct clap_plugin_configurable_audio_ports { // Submit a bunch of configuration requests which will atomically be applied together, // or discarded together. // + // Once the configuration is successfully applied, it isn't necessary for the plugin to call + // clap_host_audio_ports->changed(); and it isn't necessary for the host to scan the + // audio ports. + // // Returns true if applied. // [main-thread && !active] bool(CLAP_ABI *apply_configuration)(const clap_plugin_t *plugin, From 548f6fbf8733b86c1ebd57f8c92e56a9dd876feb Mon Sep 17 00:00:00 2001 From: deeedob Date: Thu, 19 Oct 2023 12:55:31 +0200 Subject: [PATCH 29/29] README: Re-phrase the mentioning of ABI ABI (Application Binary Interface), can be a confusing term for people who stumble over it. What we want to achieve is to let people know that the interface is stable and backwards compatible. --- README.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ddf6369a..52dc263c 100644 --- a/README.md +++ b/README.md @@ -22,8 +22,14 @@ # Learn about CLAP -CLAP stands for **CL**ever **A**udio **P**lugin. -It is an audio plugin ABI which defines a standard for *Digital Audio Workstations* and audio plugins (synthesizers, audio effects, ...) to work together. +CLAP stands for **CL**ever **A**udio **P**lugin. It is an interface that +provides a stable ABI to define a standard for *Digital Audio Workstations* and +audio plugins (synthesizers, audio effects, ...) to work together. + +The ABI, or **A**pplication **B**inary **I**nterface, serves as a means of +communication between a host and a plugin. It provides backwards compatibility, +that is, a plugin binary compiled with CLAP 1.x can be loaded by any other +CLAP 1.y. To work with CLAP, include [clap/clap.h](include/clap/clap.h).