From 14ef114986327cc7bd923dcb8a9ba7fb99e60f15 Mon Sep 17 00:00:00 2001 From: Roelof van Krimpen Date: Mon, 22 Apr 2024 12:59:26 +0200 Subject: [PATCH 1/8] Extend clap_track_info_t with a "track_index" field. --- include/clap/ext/track-info.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/clap/ext/track-info.h b/include/clap/ext/track-info.h index 3e1a5559..70d6ff3f 100644 --- a/include/clap/ext/track-info.h +++ b/include/clap/ext/track-info.h @@ -31,6 +31,9 @@ enum { // This plugin is on the master, initialize with appropriate settings for channel processing CLAP_TRACK_INFO_IS_FOR_MASTER = (1 << 5), + + // The clap_track_info_t struct contains a track_index. + CLAP_TRACK_INFO_HAS_TRACK_INDEX = (1 << 6), }; typedef struct clap_track_info { @@ -46,6 +49,9 @@ typedef struct clap_track_info { // see audio-ports.h, struct clap_audio_port_info to learn how to use channel count and port type int32_t audio_channel_count; const char *audio_port_type; + + // Track index within the host, available if flags contain CLAP_TRACK_INFO_HAS_TRACK_INDEX. + int32_t track_index; } clap_track_info_t; typedef struct clap_plugin_track_info { From 1bd5636ea1e6ceba2858c63d86f3976d588e0410 Mon Sep 17 00:00:00 2001 From: Roelof van Krimpen Date: Mon, 6 May 2024 10:47:20 +0200 Subject: [PATCH 2/8] Revert previous change to track-info extension. --- include/clap/ext/track-info.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/include/clap/ext/track-info.h b/include/clap/ext/track-info.h index 70d6ff3f..2c91e96e 100644 --- a/include/clap/ext/track-info.h +++ b/include/clap/ext/track-info.h @@ -31,9 +31,6 @@ enum { // This plugin is on the master, initialize with appropriate settings for channel processing CLAP_TRACK_INFO_IS_FOR_MASTER = (1 << 5), - - // The clap_track_info_t struct contains a track_index. - CLAP_TRACK_INFO_HAS_TRACK_INDEX = (1 << 6), }; typedef struct clap_track_info { @@ -50,8 +47,6 @@ typedef struct clap_track_info { int32_t audio_channel_count; const char *audio_port_type; - // Track index within the host, available if flags contain CLAP_TRACK_INFO_HAS_TRACK_INDEX. - int32_t track_index; } clap_track_info_t; typedef struct clap_plugin_track_info { From 287074fe42282e97f846df8e94b00520c357fb3f Mon Sep 17 00:00:00 2001 From: Roelof van Krimpen Date: Mon, 6 May 2024 11:00:02 +0200 Subject: [PATCH 3/8] Add a track-info-extended extension that supplements the track-info extension with a more generic key/value store --- include/clap/ext/draft/track-info-extended.h | 44 ++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 include/clap/ext/draft/track-info-extended.h diff --git a/include/clap/ext/draft/track-info-extended.h b/include/clap/ext/draft/track-info-extended.h new file mode 100644 index 00000000..660ebdfc --- /dev/null +++ b/include/clap/ext/draft/track-info-extended.h @@ -0,0 +1,44 @@ +#pragma once + +#include "../../plugin.h" +#include "../../string-sizes.h" + +// This extension extends the track-info extension with a more generic key/value system. +// As it extends track-info, it doesn't have its own clap_plugin_* struct with a callback for +// when the values change, instead the host is expected to call clap_plugin_track_info::changed in +// this case. + +static CLAP_CONSTEXPR const char CLAP_EXT_TRACK_INFO_EXTENDED[] = "clap.track-info-extended/1"; + + +// Index of the track the instance is on (read_only, int32_t). +static CLAP_CONSTEXPR const char CLAP_TRACK_INFO_EXTENDED_TRACK_INDEX[] = "clap.track-info-extended.track-index"; +// Index of the plugin instance within the track (read_only, int32_t). +static CLAP_CONSTEXPR const char CLAP_TRACK_INFO_EXTENDED_PLUGIN_INDEX[] = "clap.track-info-extended.plugin-index"; + +#ifdef __cplusplus +extern "C" { +#endif + + +typedef struct clap_host_track_info_extended { + + // Gets a value with a given key from the host, fills 'value' with the + // corresponding value and returns true if a value was filled succesfully. + // If it returns false, the value of 'value' isn't touched. + // [main-thread] + bool(CLAP_ABI *get_int)(const clap_host_t *host, const char *key, int32_t *value); + bool(CLAP_ABI *get_string)(const clap_host_t *host, const char *key, char (*value)[CLAP_NAME_SIZE]); + bool(CLAP_ABI *get_double)(const clap_host_t *host, const char *key, double *value); + + // Sets a value with a given key. Returns true if the value was set succesfully. + // [main-thread] + bool(CLAP_ABI *set_int)(const clap_host_t *host, const char *key, int32_t value); + bool(CLAP_ABI *set_string)(const clap_host_t *host, const char *key, char (value)[CLAP_NAME_SIZE]); + bool(CLAP_ABI *set_double)(const clap_host_t *host, const char *key, double value); + +} clap_host_track_info_extended_t; + +#ifdef __cplusplus +} +#endif From c9a449839eced7a13408e42cbeaf86befacacef2 Mon Sep 17 00:00:00 2001 From: Roelof van Krimpen Date: Mon, 6 May 2024 11:14:16 +0200 Subject: [PATCH 4/8] Add include for track-info-extended to all.h --- include/clap/all.h | 1 + include/clap/ext/track-info.h | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/include/clap/all.h b/include/clap/all.h index 45412475..b1cc97a2 100644 --- a/include/clap/all.h +++ b/include/clap/all.h @@ -10,3 +10,4 @@ #include "ext/draft/transport-control.h" #include "ext/draft/triggers.h" #include "ext/draft/tuning.h" +#include "ext/draft/track-info-extended.h" diff --git a/include/clap/ext/track-info.h b/include/clap/ext/track-info.h index 2c91e96e..3e1a5559 100644 --- a/include/clap/ext/track-info.h +++ b/include/clap/ext/track-info.h @@ -46,7 +46,6 @@ typedef struct clap_track_info { // see audio-ports.h, struct clap_audio_port_info to learn how to use channel count and port type int32_t audio_channel_count; const char *audio_port_type; - } clap_track_info_t; typedef struct clap_plugin_track_info { From a3c28cb87ee6e2d3d852c733e1fada87903a8172 Mon Sep 17 00:00:00 2001 From: Roelof van Krimpen Date: Mon, 6 May 2024 14:48:22 +0200 Subject: [PATCH 5/8] Clean up get-/set_string interface. --- include/clap/ext/draft/track-info-extended.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/include/clap/ext/draft/track-info-extended.h b/include/clap/ext/draft/track-info-extended.h index 660ebdfc..e6d80455 100644 --- a/include/clap/ext/draft/track-info-extended.h +++ b/include/clap/ext/draft/track-info-extended.h @@ -26,16 +26,26 @@ typedef struct clap_host_track_info_extended { // Gets a value with a given key from the host, fills 'value' with the // corresponding value and returns true if a value was filled succesfully. // If it returns false, the value of 'value' isn't touched. + // + // For the string value getter specifically, the get function should return the + // size of the value it's written (or would've written if it had fit in the + // buffer), excluding the null terminator. + // If there's no value matching the key, a value of 0 is returned. If no value + // pointer is provided and/or value_capacity is 0, the value shouldn't be touched, + // but a correct required length should be returned. + // . // [main-thread] bool(CLAP_ABI *get_int)(const clap_host_t *host, const char *key, int32_t *value); - bool(CLAP_ABI *get_string)(const clap_host_t *host, const char *key, char (*value)[CLAP_NAME_SIZE]); bool(CLAP_ABI *get_double)(const clap_host_t *host, const char *key, double *value); + int32_t(CLAP_ABI *get_string)(const clap_host_t *host, const char *key, char *value, int32_t value_capacity); // Sets a value with a given key. Returns true if the value was set succesfully. + // Note that string values provided are null-terminated and shouldn't be + // expected to have a lifetime past the set_string call. // [main-thread] bool(CLAP_ABI *set_int)(const clap_host_t *host, const char *key, int32_t value); - bool(CLAP_ABI *set_string)(const clap_host_t *host, const char *key, char (value)[CLAP_NAME_SIZE]); bool(CLAP_ABI *set_double)(const clap_host_t *host, const char *key, double value); + bool(CLAP_ABI *set_string)(const clap_host_t *host, const char *key, const char *value); } clap_host_track_info_extended_t; From 82c0e6faec66aacebf1c67aadd26cb442baea82b Mon Sep 17 00:00:00 2001 From: Roelof van Krimpen Date: Thu, 5 Sep 2024 12:51:40 +0200 Subject: [PATCH 6/8] Replace track-info-extended plugin with a new location plugin --- include/clap/all.h | 2 +- include/clap/ext/draft/location.h | 46 +++++++++++++++++ include/clap/ext/draft/track-info-extended.h | 54 -------------------- 3 files changed, 47 insertions(+), 55 deletions(-) create mode 100644 include/clap/ext/draft/location.h delete mode 100644 include/clap/ext/draft/track-info-extended.h diff --git a/include/clap/all.h b/include/clap/all.h index b1cc97a2..f19b3c25 100644 --- a/include/clap/all.h +++ b/include/clap/all.h @@ -10,4 +10,4 @@ #include "ext/draft/transport-control.h" #include "ext/draft/triggers.h" #include "ext/draft/tuning.h" -#include "ext/draft/track-info-extended.h" +#include "ext/draft/location.h" diff --git a/include/clap/ext/draft/location.h b/include/clap/ext/draft/location.h new file mode 100644 index 00000000..42c56bb3 --- /dev/null +++ b/include/clap/ext/draft/location.h @@ -0,0 +1,46 @@ +#pragma once + +#include "../../plugin.h" + +// This extension allows a host to tell the plugin more about its position +// within a project or session. + +static CLAP_CONSTEXPR const char CLAP_EXT_LOCATION[] = "clap.location/1"; + +#ifdef __cplusplus +extern "C" { +#endif + +enum { + CLAP_PLUGIN_LOCATION_TRACK, + CLAP_PLUGIN_LOCATION_TRACK_GROUP, + CLAP_PLUGIN_LOCATION_DEVICE + CLAP_PLUGIN_LOCATION_DEVICE_PARALLEL_GROUP, + CLAP_PLUGIN_LOCATION_DEVICE_SERIAL_GROUP, +}; + +typedef struct clap_plugin_location_element { + // Name of the element. + const char *name; + // Kind of the element, must be one of the CLAP_PLUGIN_LOCATION_* values. + int kind; + // Index within the parent element. + uint32_t index_in_group; + // Index of the element in a global context. When sorting elements by this index, + // the order should mirror the order as it is displayed in the host. + uint32_t global_index; +} clap_plugin_location_element_t; + + +typedef struct clap_plugin_location { + // Called by the host when the location of the plugin instance changes. + // + // The last item in this array always refers to the device itself, and as + // such is expected to be of kind CLAP_PLUGIN_LOCATION_DEVICE. + // [main-thread] + void (*set_location)(clap_plugin_t *plugin, clap_plugin_location_element_t *path, int num_elements); +} clap_plugin_location_t; + +#ifdef __cplusplus +} +#endif diff --git a/include/clap/ext/draft/track-info-extended.h b/include/clap/ext/draft/track-info-extended.h deleted file mode 100644 index e6d80455..00000000 --- a/include/clap/ext/draft/track-info-extended.h +++ /dev/null @@ -1,54 +0,0 @@ -#pragma once - -#include "../../plugin.h" -#include "../../string-sizes.h" - -// This extension extends the track-info extension with a more generic key/value system. -// As it extends track-info, it doesn't have its own clap_plugin_* struct with a callback for -// when the values change, instead the host is expected to call clap_plugin_track_info::changed in -// this case. - -static CLAP_CONSTEXPR const char CLAP_EXT_TRACK_INFO_EXTENDED[] = "clap.track-info-extended/1"; - - -// Index of the track the instance is on (read_only, int32_t). -static CLAP_CONSTEXPR const char CLAP_TRACK_INFO_EXTENDED_TRACK_INDEX[] = "clap.track-info-extended.track-index"; -// Index of the plugin instance within the track (read_only, int32_t). -static CLAP_CONSTEXPR const char CLAP_TRACK_INFO_EXTENDED_PLUGIN_INDEX[] = "clap.track-info-extended.plugin-index"; - -#ifdef __cplusplus -extern "C" { -#endif - - -typedef struct clap_host_track_info_extended { - - // Gets a value with a given key from the host, fills 'value' with the - // corresponding value and returns true if a value was filled succesfully. - // If it returns false, the value of 'value' isn't touched. - // - // For the string value getter specifically, the get function should return the - // size of the value it's written (or would've written if it had fit in the - // buffer), excluding the null terminator. - // If there's no value matching the key, a value of 0 is returned. If no value - // pointer is provided and/or value_capacity is 0, the value shouldn't be touched, - // but a correct required length should be returned. - // . - // [main-thread] - bool(CLAP_ABI *get_int)(const clap_host_t *host, const char *key, int32_t *value); - bool(CLAP_ABI *get_double)(const clap_host_t *host, const char *key, double *value); - int32_t(CLAP_ABI *get_string)(const clap_host_t *host, const char *key, char *value, int32_t value_capacity); - - // Sets a value with a given key. Returns true if the value was set succesfully. - // Note that string values provided are null-terminated and shouldn't be - // expected to have a lifetime past the set_string call. - // [main-thread] - bool(CLAP_ABI *set_int)(const clap_host_t *host, const char *key, int32_t value); - bool(CLAP_ABI *set_double)(const clap_host_t *host, const char *key, double value); - bool(CLAP_ABI *set_string)(const clap_host_t *host, const char *key, const char *value); - -} clap_host_track_info_extended_t; - -#ifdef __cplusplus -} -#endif From fc8ff5f5462582a963ffff6a4c833199488273ec Mon Sep 17 00:00:00 2001 From: Roelof van Krimpen Date: Thu, 5 Sep 2024 13:57:34 +0200 Subject: [PATCH 7/8] Add a color property to location elements. --- include/clap/ext/draft/location.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/clap/ext/draft/location.h b/include/clap/ext/draft/location.h index 42c56bb3..aa9bb281 100644 --- a/include/clap/ext/draft/location.h +++ b/include/clap/ext/draft/location.h @@ -1,6 +1,7 @@ #pragma once #include "../../plugin.h" +#include "../../color.h" // This extension allows a host to tell the plugin more about its position // within a project or session. @@ -29,6 +30,9 @@ typedef struct clap_plugin_location_element { // Index of the element in a global context. When sorting elements by this index, // the order should mirror the order as it is displayed in the host. uint32_t global_index; + // Color for this element, should be 0x00000000 if no color is used for this + // element. + clap_color_t color; } clap_plugin_location_element_t; From 845502ae3c6ac2f8f03c9a8a4ca4f912e3fd28fe Mon Sep 17 00:00:00 2001 From: Roelof van Krimpen Date: Thu, 5 Sep 2024 14:51:59 +0200 Subject: [PATCH 8/8] Add id to location element and expand kind enum. --- include/clap/ext/draft/location.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/include/clap/ext/draft/location.h b/include/clap/ext/draft/location.h index aa9bb281..9cc424dd 100644 --- a/include/clap/ext/draft/location.h +++ b/include/clap/ext/draft/location.h @@ -13,6 +13,7 @@ extern "C" { #endif enum { + CLAP_PLUGIN_LOCATION_PROJECT, CLAP_PLUGIN_LOCATION_TRACK, CLAP_PLUGIN_LOCATION_TRACK_GROUP, CLAP_PLUGIN_LOCATION_DEVICE @@ -21,7 +22,10 @@ enum { }; typedef struct clap_plugin_location_element { - // Name of the element. + // Internal ID of the element. This is not intended for display to the user, + // but rather to give the host a potential quick way for lookups. + const char *id; + // User friendly name of the element. const char *name; // Kind of the element, must be one of the CLAP_PLUGIN_LOCATION_* values. int kind;