From 863ba702f064e8706ccd8ada4914c2e8415cf241 Mon Sep 17 00:00:00 2001 From: Bremmers Date: Thu, 20 Jul 2023 22:06:02 +0200 Subject: [PATCH 01/40] Add draft midici-profiles.h --- include/clap/ext/draft/midici-profiles.h | 55 ++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 include/clap/ext/draft/midici-profiles.h diff --git a/include/clap/ext/draft/midici-profiles.h b/include/clap/ext/draft/midici-profiles.h new file mode 100644 index 00000000..5950d89b --- /dev/null +++ b/include/clap/ext/draft/midici-profiles.h @@ -0,0 +1,55 @@ +#pragma once + +#include "../../plugin.h" + +//usage examples: +//- the host can tell a MIDI keyboard the plugin conforms to the drawbar organ profile, so the keyboard can set up its faders for that. +//- the plugin can adapt its MIDI controller mapping if a MIDI keyboard actives a profile (via the host). +//- the host can send per-note articulations in note attributes if there's an active profile for this. + +//the 5 bytes repesenting a profile go in a uint64_t. +//the Default Control Change Mapping profile would be 0x00000000_0000217e for example. + +//TODO : for completeness this should work per-input port. Is that worth it? +//TODO : for even more completeness it could work for outputs too. A MIDI effect plugin might want to know +// the host can receive per-note articulations in note attributes for example. + +static CLAP_CONSTEXPR const char CLAP_EXT_MIDICI_PROFILES[] = "clap.midici-profiles.draft/0"; + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct clap_plugin_midici_profiles { + // Returns the number of profiles supported. + // [main-thread] + uint32_t(CLAP_ABI *count)(const clap_plugin_t *plugin); + + // Get a profile by index. + // [main-thread] + bool(CLAP_ABI *get)(const clap_plugin_t *plugin, + uint32_t profile_index, + uint64_t *profile + bool *active); + + //Actives a profile + //returns true if the profile was activated + //TODO : should this call struct clap_host_midici_profiles.changed or not? + bool(CLAP_ABI *activate)(const clap_plugin_t *plugin, + uint64_t profile); + + //Deactives a profile + //returns true if the profile was deactivated + bool(CLAP_ABI *deactivate)(const clap_plugin_t *plugin, + uint64_t profile); +} clap_plugin_midici_profiles_t; + +typedef struct clap_host_midici_profiles { + // Informs the host that the available or active profiles changed. + // [main-thread] + void(CLAP_ABI *changed)(const clap_host_t *host); +} clap_host_midici_profiles_t; + +#ifdef __cplusplus +} +#endif \ No newline at end of file From 6738f8b99393c84129319889ea4428b7e0c5c6d6 Mon Sep 17 00:00:00 2001 From: Bremmers Date: Sat, 18 Nov 2023 14:10:05 +0100 Subject: [PATCH 02/40] added profile specific data --- include/clap/ext/draft/midici-profiles.h | 36 ++++++++++++++++++------ 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/include/clap/ext/draft/midici-profiles.h b/include/clap/ext/draft/midici-profiles.h index 5950d89b..68ed09e4 100644 --- a/include/clap/ext/draft/midici-profiles.h +++ b/include/clap/ext/draft/midici-profiles.h @@ -4,14 +4,14 @@ //usage examples: //- the host can tell a MIDI keyboard the plugin conforms to the drawbar organ profile, so the keyboard can set up its faders for that. -//- the plugin can adapt its MIDI controller mapping if a MIDI keyboard actives a profile (via the host). -//- the host can send per-note articulations in note attributes if there's an active profile for this. +//- the host can send per-note articulations in MIDI 2.0 protocol note-on attributes if there's an active profile for this. //the 5 bytes repesenting a profile go in a uint64_t. //the Default Control Change Mapping profile would be 0x00000000_0000217e for example. -//TODO : for completeness this should work per-input port. Is that worth it? -//TODO : for even more completeness it could work for outputs too. A MIDI effect plugin might want to know +//TODO : profiles can be different for each MIDI channel, and this should work per-input port. +// we can add that once we've agreed on the basic functionality. +//TODO : for completeness it could work for outputs too. A MIDI effect plugin might want to know // the host can receive per-note articulations in note attributes for example. static CLAP_CONSTEXPR const char CLAP_EXT_MIDICI_PROFILES[] = "clap.midici-profiles.draft/0"; @@ -32,14 +32,32 @@ typedef struct clap_plugin_midici_profiles { uint64_t *profile bool *active); - //Actives a profile - //returns true if the profile was activated - //TODO : should this call struct clap_host_midici_profiles.changed or not? + // get number of bytes for profile specific data for the specified Inquiry Target + // if result=0 there's no data available for this Inquiry Target + // [main-thread] + uint32_t(CLAP_ABI *get_data_size)(const clap_plugin_t *plugin, + uint32_t profile_index, + uint8_t inquiry_target); + + // get profile specific data for the specified Inquiry Target + // buffer must be large enough to contain the number of bytes returned by get_data_size() + // [main-thread] + bool(CLAP_ABI *get_data)(const clap_plugin_t *plugin, + uint32_t profile_index, + uint8_t inquiry_target, + const uint8_t *buffer); + + // Actives a profile, so the plugin knows the host will use this + // returns true if the profile was activated + // Note: do not call clap_host_midici_profiles.changed + // [main-thread] bool(CLAP_ABI *activate)(const clap_plugin_t *plugin, uint64_t profile); - //Deactives a profile - //returns true if the profile was deactivated + // Deactives a profile + // returns true if the profile was deactivated + // Note: do not call clap_host_midici_profiles.changed + // [main-thread] bool(CLAP_ABI *deactivate)(const clap_plugin_t *plugin, uint64_t profile); } clap_plugin_midici_profiles_t; From d6d577f8cf2c7bc372b54306e49ee4846c756574 Mon Sep 17 00:00:00 2001 From: Bremmers Date: Mon, 20 Nov 2023 13:04:37 +0100 Subject: [PATCH 03/40] added TODO about 'active' --- include/clap/ext/draft/midici-profiles.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/clap/ext/draft/midici-profiles.h b/include/clap/ext/draft/midici-profiles.h index 68ed09e4..a6be6c31 100644 --- a/include/clap/ext/draft/midici-profiles.h +++ b/include/clap/ext/draft/midici-profiles.h @@ -13,6 +13,8 @@ // we can add that once we've agreed on the basic functionality. //TODO : for completeness it could work for outputs too. A MIDI effect plugin might want to know // the host can receive per-note articulations in note attributes for example. +//TODO : perhaps remove the "active" parameter from clap_plugin_midici_profiles.get(). In this scenario the host decides which profiles +// will be used, which is cleaner and probably better reflects how profiles will be used for the host/plugin case. static CLAP_CONSTEXPR const char CLAP_EXT_MIDICI_PROFILES[] = "clap.midici-profiles.draft/0"; From 479ad2fef968c41f8ca605839adc178b2acf76c0 Mon Sep 17 00:00:00 2001 From: Bremmers Date: Thu, 2 May 2024 16:21:28 +0200 Subject: [PATCH 04/40] Add files via upload now works per-port, supports single channel, multi channel, group and port profiles, activate/deactivate renamed to enable/disable --- include/clap/ext/draft/midici_profiles.h | 122 +++++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 include/clap/ext/draft/midici_profiles.h diff --git a/include/clap/ext/draft/midici_profiles.h b/include/clap/ext/draft/midici_profiles.h new file mode 100644 index 00000000..32038c13 --- /dev/null +++ b/include/clap/ext/draft/midici_profiles.h @@ -0,0 +1,122 @@ +#pragma once + +#include "../../plugin.h" + +//usage examples: +//- the host can tell a MIDI keyboard the plugin conforms to the drawbar organ profile, so the keyboard can set up its faders for that. +//- the host can send per-note articulations in MIDI 2.0 protocol note-on attributes if there's an active profile for this. + +// background: +// There are 4 types of profiles: single channel, multi channel, group and function block (called "port" here). +// The profile specifications define the type for a specific profile. +// +// clap_plugin_midici_profiles.count()/get() return a list of profile_t structs. +// There'll typically be multiple entries for a single supported profile_id_t: +// enabled single channel profiles: one entry per enabled channel. One entry if profile isn't enabled at all. +// enabled multi channel profiles: one entry per enabled block of channels. One entry if profile isn't enabled at all. +// enabled group profiles: one entry per enabled group. One entry if profile isn't enabled at all. +// port profiles: one entry + +//TODO : for completeness this extension could work for outputs too. A MIDI effect plugin might want to know +// the host can receive per-note articulations in note attributes for example. +// can we simply define CLAP_EXT_MIDICI_PROFILES_PLUG_TO_HOST[] = "clap.midici-profiles.plug-to-host/draft/1" ??? + +static CLAP_CONSTEXPR const char CLAP_EXT_MIDICI_PROFILES[] = "clap.midici-profiles/draft/1"; + +#ifdef __cplusplus +extern "C" { +#endif + +typedef profile_id_t profile_id[5]; + +typedef struct profile_t { + profile_id_t profile_id; + byte_t enabled; // 0 = off, 1 = on, 2 = always on + byte_t channel; // single-channel profiles: channel is 0..255 + // multi-channel profiles: channel is 0..255 + // group profiles: channel is 16 * group + // port profiles: channel is 0 + uint16_t num_channels; // single-channel profiles: num_channels is 0..255 + // multi-channel profiles: num_channels is 0..255 + // group profiles: num_channels is 0 + // port profiles: num_channels is 0 +}; + +typedef struct clap_plugin_midici_profiles { + // Returns the number of profiles supported. + // [main-thread] + uint32_t(CLAP_ABI *count)(const clap_plugin_t *plugin, + uint16_t port_index); + + // Get a profile by index. + // [main-thread] + bool(CLAP_ABI *get)(const clap_plugin_t *plugin, + uint16_t port_index, + uint32_t profile_index, + profile_t *profile); + + // Get number of bytes for profile specific data for the specified Inquiry Target. + // If result=0 there's no data available for this Inquiry Target. + // channel defines the destination: + // single-channel profiles: channel is 0..255 + // multi-channel profiles: channel is 0..255 + // group profiles: channel is 16 * group + // port profiles: channel is 0 + // [main-thread] + uint32_t(CLAP_ABI *get_data_size)(const clap_plugin_t *plugin, + uint16_t port_index, + uint32_t profile_index, + byte_t channel, + uint8_t inquiry_target); + + // Get profile specific data for the specified Inquiry Target. + // buffer must be large enough to contain the number of bytes returned by get_data_size(). + // channel defines the destination: + // single-channel profiles: channel is 0..255 + // multi-channel profiles: channel is 0..255 + // group profiles: channel is 16 * group + // port profiles: channel is 0 + // [main-thread] + bool(CLAP_ABI *get_data)(const clap_plugin_t *plugin, + uint16_t port_index, + uint32_t profile_index, + byte_t channel, + uint8_t inquiry_target, + const uint8_t *buffer); + + // Enables a profile, so the plugin knows the host will use it. + // Returns true if the profile is enabled when the function returns. + // Can be called multiple times to enabled a profile for multiple channels or groups. + // channel and num-channels define the destination: + // single-channel profiles: channel is 0..255, num_channels = 1 + // multi-channel profiles: channel is 0..255, num_channels = 1..256 + // group profiles: channel is 16 * group, num_channels = 0 + // port profiles: channel is 0, num_channels = 0 + // Note for hosts: after calling this function count()/get() may have changed !! + // Note for plugins: do not call clap_host_midici_profiles.changed. + // [main-thread] + bool(CLAP_ABI *enable)(const clap_plugin_t *plugin, + uint16_t port_index, + profile_id_t profile, + byte_t channel, + uint16_t num_channels); + + // Disables a profile. + // Returns true if the profile is disabled when the function returns. + // Note for hosts: after calling this function count()/get() may have changed !! + // Note for plugins: do not call clap_host_midici_profiles.changed. + // [main-thread] + bool(CLAP_ABI *disable)(const clap_plugin_t *plugin, + uint16_t port_index, + profile_id_t profile); +} clap_plugin_midici_profiles_t; + +typedef struct clap_host_midici_profiles { + // Informs the host that the available or active profiles changed. + // [main-thread] + void(CLAP_ABI *changed)(const clap_host_t *host); +} clap_host_midici_profiles_t; + +#ifdef __cplusplus +} +#endif \ No newline at end of file From c935d340ca995b04c179be519928c368b7e95df3 Mon Sep 17 00:00:00 2001 From: Bremmers Date: Thu, 2 May 2024 16:24:32 +0200 Subject: [PATCH 05/40] Delete include/clap/ext/draft/midici_profiles.h --- include/clap/ext/draft/midici_profiles.h | 122 ----------------------- 1 file changed, 122 deletions(-) delete mode 100644 include/clap/ext/draft/midici_profiles.h diff --git a/include/clap/ext/draft/midici_profiles.h b/include/clap/ext/draft/midici_profiles.h deleted file mode 100644 index 32038c13..00000000 --- a/include/clap/ext/draft/midici_profiles.h +++ /dev/null @@ -1,122 +0,0 @@ -#pragma once - -#include "../../plugin.h" - -//usage examples: -//- the host can tell a MIDI keyboard the plugin conforms to the drawbar organ profile, so the keyboard can set up its faders for that. -//- the host can send per-note articulations in MIDI 2.0 protocol note-on attributes if there's an active profile for this. - -// background: -// There are 4 types of profiles: single channel, multi channel, group and function block (called "port" here). -// The profile specifications define the type for a specific profile. -// -// clap_plugin_midici_profiles.count()/get() return a list of profile_t structs. -// There'll typically be multiple entries for a single supported profile_id_t: -// enabled single channel profiles: one entry per enabled channel. One entry if profile isn't enabled at all. -// enabled multi channel profiles: one entry per enabled block of channels. One entry if profile isn't enabled at all. -// enabled group profiles: one entry per enabled group. One entry if profile isn't enabled at all. -// port profiles: one entry - -//TODO : for completeness this extension could work for outputs too. A MIDI effect plugin might want to know -// the host can receive per-note articulations in note attributes for example. -// can we simply define CLAP_EXT_MIDICI_PROFILES_PLUG_TO_HOST[] = "clap.midici-profiles.plug-to-host/draft/1" ??? - -static CLAP_CONSTEXPR const char CLAP_EXT_MIDICI_PROFILES[] = "clap.midici-profiles/draft/1"; - -#ifdef __cplusplus -extern "C" { -#endif - -typedef profile_id_t profile_id[5]; - -typedef struct profile_t { - profile_id_t profile_id; - byte_t enabled; // 0 = off, 1 = on, 2 = always on - byte_t channel; // single-channel profiles: channel is 0..255 - // multi-channel profiles: channel is 0..255 - // group profiles: channel is 16 * group - // port profiles: channel is 0 - uint16_t num_channels; // single-channel profiles: num_channels is 0..255 - // multi-channel profiles: num_channels is 0..255 - // group profiles: num_channels is 0 - // port profiles: num_channels is 0 -}; - -typedef struct clap_plugin_midici_profiles { - // Returns the number of profiles supported. - // [main-thread] - uint32_t(CLAP_ABI *count)(const clap_plugin_t *plugin, - uint16_t port_index); - - // Get a profile by index. - // [main-thread] - bool(CLAP_ABI *get)(const clap_plugin_t *plugin, - uint16_t port_index, - uint32_t profile_index, - profile_t *profile); - - // Get number of bytes for profile specific data for the specified Inquiry Target. - // If result=0 there's no data available for this Inquiry Target. - // channel defines the destination: - // single-channel profiles: channel is 0..255 - // multi-channel profiles: channel is 0..255 - // group profiles: channel is 16 * group - // port profiles: channel is 0 - // [main-thread] - uint32_t(CLAP_ABI *get_data_size)(const clap_plugin_t *plugin, - uint16_t port_index, - uint32_t profile_index, - byte_t channel, - uint8_t inquiry_target); - - // Get profile specific data for the specified Inquiry Target. - // buffer must be large enough to contain the number of bytes returned by get_data_size(). - // channel defines the destination: - // single-channel profiles: channel is 0..255 - // multi-channel profiles: channel is 0..255 - // group profiles: channel is 16 * group - // port profiles: channel is 0 - // [main-thread] - bool(CLAP_ABI *get_data)(const clap_plugin_t *plugin, - uint16_t port_index, - uint32_t profile_index, - byte_t channel, - uint8_t inquiry_target, - const uint8_t *buffer); - - // Enables a profile, so the plugin knows the host will use it. - // Returns true if the profile is enabled when the function returns. - // Can be called multiple times to enabled a profile for multiple channels or groups. - // channel and num-channels define the destination: - // single-channel profiles: channel is 0..255, num_channels = 1 - // multi-channel profiles: channel is 0..255, num_channels = 1..256 - // group profiles: channel is 16 * group, num_channels = 0 - // port profiles: channel is 0, num_channels = 0 - // Note for hosts: after calling this function count()/get() may have changed !! - // Note for plugins: do not call clap_host_midici_profiles.changed. - // [main-thread] - bool(CLAP_ABI *enable)(const clap_plugin_t *plugin, - uint16_t port_index, - profile_id_t profile, - byte_t channel, - uint16_t num_channels); - - // Disables a profile. - // Returns true if the profile is disabled when the function returns. - // Note for hosts: after calling this function count()/get() may have changed !! - // Note for plugins: do not call clap_host_midici_profiles.changed. - // [main-thread] - bool(CLAP_ABI *disable)(const clap_plugin_t *plugin, - uint16_t port_index, - profile_id_t profile); -} clap_plugin_midici_profiles_t; - -typedef struct clap_host_midici_profiles { - // Informs the host that the available or active profiles changed. - // [main-thread] - void(CLAP_ABI *changed)(const clap_host_t *host); -} clap_host_midici_profiles_t; - -#ifdef __cplusplus -} -#endif \ No newline at end of file From 0753bb065e3bbc636de0245b3ef542c305fe77a1 Mon Sep 17 00:00:00 2001 From: Bremmers Date: Thu, 2 May 2024 16:25:07 +0200 Subject: [PATCH 06/40] Add files via upload now works per-port, supports single channel, multi channel, group and port profiles, activate/deactivate renamed to enable/disable --- include/clap/ext/draft/midici-profiles.h | 97 ++++++++++++++++++------ 1 file changed, 72 insertions(+), 25 deletions(-) diff --git a/include/clap/ext/draft/midici-profiles.h b/include/clap/ext/draft/midici-profiles.h index a6be6c31..32038c13 100644 --- a/include/clap/ext/draft/midici-profiles.h +++ b/include/clap/ext/draft/midici-profiles.h @@ -6,62 +6,109 @@ //- the host can tell a MIDI keyboard the plugin conforms to the drawbar organ profile, so the keyboard can set up its faders for that. //- the host can send per-note articulations in MIDI 2.0 protocol note-on attributes if there's an active profile for this. -//the 5 bytes repesenting a profile go in a uint64_t. -//the Default Control Change Mapping profile would be 0x00000000_0000217e for example. +// background: +// There are 4 types of profiles: single channel, multi channel, group and function block (called "port" here). +// The profile specifications define the type for a specific profile. +// +// clap_plugin_midici_profiles.count()/get() return a list of profile_t structs. +// There'll typically be multiple entries for a single supported profile_id_t: +// enabled single channel profiles: one entry per enabled channel. One entry if profile isn't enabled at all. +// enabled multi channel profiles: one entry per enabled block of channels. One entry if profile isn't enabled at all. +// enabled group profiles: one entry per enabled group. One entry if profile isn't enabled at all. +// port profiles: one entry -//TODO : profiles can be different for each MIDI channel, and this should work per-input port. -// we can add that once we've agreed on the basic functionality. -//TODO : for completeness it could work for outputs too. A MIDI effect plugin might want to know +//TODO : for completeness this extension could work for outputs too. A MIDI effect plugin might want to know // the host can receive per-note articulations in note attributes for example. -//TODO : perhaps remove the "active" parameter from clap_plugin_midici_profiles.get(). In this scenario the host decides which profiles -// will be used, which is cleaner and probably better reflects how profiles will be used for the host/plugin case. +// can we simply define CLAP_EXT_MIDICI_PROFILES_PLUG_TO_HOST[] = "clap.midici-profiles.plug-to-host/draft/1" ??? -static CLAP_CONSTEXPR const char CLAP_EXT_MIDICI_PROFILES[] = "clap.midici-profiles.draft/0"; +static CLAP_CONSTEXPR const char CLAP_EXT_MIDICI_PROFILES[] = "clap.midici-profiles/draft/1"; #ifdef __cplusplus extern "C" { #endif +typedef profile_id_t profile_id[5]; + +typedef struct profile_t { + profile_id_t profile_id; + byte_t enabled; // 0 = off, 1 = on, 2 = always on + byte_t channel; // single-channel profiles: channel is 0..255 + // multi-channel profiles: channel is 0..255 + // group profiles: channel is 16 * group + // port profiles: channel is 0 + uint16_t num_channels; // single-channel profiles: num_channels is 0..255 + // multi-channel profiles: num_channels is 0..255 + // group profiles: num_channels is 0 + // port profiles: num_channels is 0 +}; + typedef struct clap_plugin_midici_profiles { // Returns the number of profiles supported. // [main-thread] - uint32_t(CLAP_ABI *count)(const clap_plugin_t *plugin); + uint32_t(CLAP_ABI *count)(const clap_plugin_t *plugin, + uint16_t port_index); // Get a profile by index. // [main-thread] bool(CLAP_ABI *get)(const clap_plugin_t *plugin, + uint16_t port_index, uint32_t profile_index, - uint64_t *profile - bool *active); + profile_t *profile); - // get number of bytes for profile specific data for the specified Inquiry Target - // if result=0 there's no data available for this Inquiry Target + // Get number of bytes for profile specific data for the specified Inquiry Target. + // If result=0 there's no data available for this Inquiry Target. + // channel defines the destination: + // single-channel profiles: channel is 0..255 + // multi-channel profiles: channel is 0..255 + // group profiles: channel is 16 * group + // port profiles: channel is 0 // [main-thread] uint32_t(CLAP_ABI *get_data_size)(const clap_plugin_t *plugin, + uint16_t port_index, uint32_t profile_index, + byte_t channel, uint8_t inquiry_target); - // get profile specific data for the specified Inquiry Target - // buffer must be large enough to contain the number of bytes returned by get_data_size() + // Get profile specific data for the specified Inquiry Target. + // buffer must be large enough to contain the number of bytes returned by get_data_size(). + // channel defines the destination: + // single-channel profiles: channel is 0..255 + // multi-channel profiles: channel is 0..255 + // group profiles: channel is 16 * group + // port profiles: channel is 0 // [main-thread] bool(CLAP_ABI *get_data)(const clap_plugin_t *plugin, + uint16_t port_index, uint32_t profile_index, + byte_t channel, uint8_t inquiry_target, const uint8_t *buffer); - // Actives a profile, so the plugin knows the host will use this - // returns true if the profile was activated - // Note: do not call clap_host_midici_profiles.changed + // Enables a profile, so the plugin knows the host will use it. + // Returns true if the profile is enabled when the function returns. + // Can be called multiple times to enabled a profile for multiple channels or groups. + // channel and num-channels define the destination: + // single-channel profiles: channel is 0..255, num_channels = 1 + // multi-channel profiles: channel is 0..255, num_channels = 1..256 + // group profiles: channel is 16 * group, num_channels = 0 + // port profiles: channel is 0, num_channels = 0 + // Note for hosts: after calling this function count()/get() may have changed !! + // Note for plugins: do not call clap_host_midici_profiles.changed. // [main-thread] - bool(CLAP_ABI *activate)(const clap_plugin_t *plugin, - uint64_t profile); + bool(CLAP_ABI *enable)(const clap_plugin_t *plugin, + uint16_t port_index, + profile_id_t profile, + byte_t channel, + uint16_t num_channels); - // Deactives a profile - // returns true if the profile was deactivated - // Note: do not call clap_host_midici_profiles.changed + // Disables a profile. + // Returns true if the profile is disabled when the function returns. + // Note for hosts: after calling this function count()/get() may have changed !! + // Note for plugins: do not call clap_host_midici_profiles.changed. // [main-thread] - bool(CLAP_ABI *deactivate)(const clap_plugin_t *plugin, - uint64_t profile); + bool(CLAP_ABI *disable)(const clap_plugin_t *plugin, + uint16_t port_index, + profile_id_t profile); } clap_plugin_midici_profiles_t; typedef struct clap_host_midici_profiles { From f07273e6860800030789e9d24cd45050653d906e Mon Sep 17 00:00:00 2001 From: Bremmers Date: Thu, 2 May 2024 16:29:12 +0200 Subject: [PATCH 07/40] typos --- include/clap/ext/draft/midici-profiles.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/clap/ext/draft/midici-profiles.h b/include/clap/ext/draft/midici-profiles.h index 32038c13..f1556827 100644 --- a/include/clap/ext/draft/midici-profiles.h +++ b/include/clap/ext/draft/midici-profiles.h @@ -36,8 +36,8 @@ typedef struct profile_t { // multi-channel profiles: channel is 0..255 // group profiles: channel is 16 * group // port profiles: channel is 0 - uint16_t num_channels; // single-channel profiles: num_channels is 0..255 - // multi-channel profiles: num_channels is 0..255 + uint16_t num_channels; // single-channel profiles: num_channels is q + // multi-channel profiles: num_channels is 1..256 // group profiles: num_channels is 0 // port profiles: num_channels is 0 }; @@ -119,4 +119,4 @@ typedef struct clap_host_midici_profiles { #ifdef __cplusplus } -#endif \ No newline at end of file +#endif From 415de4d3f0ebfc35cd45ba63347645ff87dfc9e8 Mon Sep 17 00:00:00 2001 From: Bremmers Date: Thu, 2 May 2024 16:29:33 +0200 Subject: [PATCH 08/40] more typos --- include/clap/ext/draft/midici-profiles.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/clap/ext/draft/midici-profiles.h b/include/clap/ext/draft/midici-profiles.h index f1556827..d86399dd 100644 --- a/include/clap/ext/draft/midici-profiles.h +++ b/include/clap/ext/draft/midici-profiles.h @@ -36,7 +36,7 @@ typedef struct profile_t { // multi-channel profiles: channel is 0..255 // group profiles: channel is 16 * group // port profiles: channel is 0 - uint16_t num_channels; // single-channel profiles: num_channels is q + uint16_t num_channels; // single-channel profiles: num_channels is 1 // multi-channel profiles: num_channels is 1..256 // group profiles: num_channels is 0 // port profiles: num_channels is 0 From 012f3108185e5bb77ba59a5e70a912d9def4748a Mon Sep 17 00:00:00 2001 From: Bremmers Date: Thu, 2 May 2024 19:34:54 +0200 Subject: [PATCH 09/40] get_data_size() / get_data() don't need channel parameter --- include/clap/ext/draft/midici-profiles.h | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/include/clap/ext/draft/midici-profiles.h b/include/clap/ext/draft/midici-profiles.h index d86399dd..477433bc 100644 --- a/include/clap/ext/draft/midici-profiles.h +++ b/include/clap/ext/draft/midici-profiles.h @@ -57,30 +57,18 @@ typedef struct clap_plugin_midici_profiles { // Get number of bytes for profile specific data for the specified Inquiry Target. // If result=0 there's no data available for this Inquiry Target. - // channel defines the destination: - // single-channel profiles: channel is 0..255 - // multi-channel profiles: channel is 0..255 - // group profiles: channel is 16 * group - // port profiles: channel is 0 // [main-thread] uint32_t(CLAP_ABI *get_data_size)(const clap_plugin_t *plugin, uint16_t port_index, uint32_t profile_index, - byte_t channel, uint8_t inquiry_target); // Get profile specific data for the specified Inquiry Target. // buffer must be large enough to contain the number of bytes returned by get_data_size(). - // channel defines the destination: - // single-channel profiles: channel is 0..255 - // multi-channel profiles: channel is 0..255 - // group profiles: channel is 16 * group - // port profiles: channel is 0 // [main-thread] bool(CLAP_ABI *get_data)(const clap_plugin_t *plugin, uint16_t port_index, uint32_t profile_index, - byte_t channel, uint8_t inquiry_target, const uint8_t *buffer); From ff0779fea96acf35960b1697846f5fbcaa7cacbc Mon Sep 17 00:00:00 2001 From: Bremmers Date: Thu, 2 May 2024 19:42:31 +0200 Subject: [PATCH 10/40] use clap_ostream_t for get_data() --- include/clap/ext/draft/midici-profiles.h | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/include/clap/ext/draft/midici-profiles.h b/include/clap/ext/draft/midici-profiles.h index 477433bc..0530e553 100644 --- a/include/clap/ext/draft/midici-profiles.h +++ b/include/clap/ext/draft/midici-profiles.h @@ -1,6 +1,7 @@ #pragma once #include "../../plugin.h" +#include "../stream.h" //usage examples: //- the host can tell a MIDI keyboard the plugin conforms to the drawbar organ profile, so the keyboard can set up its faders for that. @@ -55,22 +56,14 @@ typedef struct clap_plugin_midici_profiles { uint32_t profile_index, profile_t *profile); - // Get number of bytes for profile specific data for the specified Inquiry Target. - // If result=0 there's no data available for this Inquiry Target. - // [main-thread] - uint32_t(CLAP_ABI *get_data_size)(const clap_plugin_t *plugin, - uint16_t port_index, - uint32_t profile_index, - uint8_t inquiry_target); - // Get profile specific data for the specified Inquiry Target. - // buffer must be large enough to contain the number of bytes returned by get_data_size(). + // Returns true if data is written to stream correctly. // [main-thread] bool(CLAP_ABI *get_data)(const clap_plugin_t *plugin, uint16_t port_index, uint32_t profile_index, uint8_t inquiry_target, - const uint8_t *buffer); + const clap_ostream_t *stream); // Enables a profile, so the plugin knows the host will use it. // Returns true if the profile is enabled when the function returns. From d9e1433f832e6029257230b1c5e3de51be3c1118 Mon Sep 17 00:00:00 2001 From: Bremmers Date: Thu, 2 May 2024 19:57:23 +0200 Subject: [PATCH 11/40] Added support for output ports --- include/clap/ext/draft/midici-profiles.h | 78 +++++++++++++++++------- 1 file changed, 57 insertions(+), 21 deletions(-) diff --git a/include/clap/ext/draft/midici-profiles.h b/include/clap/ext/draft/midici-profiles.h index 0530e553..d247e8bc 100644 --- a/include/clap/ext/draft/midici-profiles.h +++ b/include/clap/ext/draft/midici-profiles.h @@ -18,10 +18,6 @@ // enabled group profiles: one entry per enabled group. One entry if profile isn't enabled at all. // port profiles: one entry -//TODO : for completeness this extension could work for outputs too. A MIDI effect plugin might want to know -// the host can receive per-note articulations in note attributes for example. -// can we simply define CLAP_EXT_MIDICI_PROFILES_PLUG_TO_HOST[] = "clap.midici-profiles.plug-to-host/draft/1" ??? - static CLAP_CONSTEXPR const char CLAP_EXT_MIDICI_PROFILES[] = "clap.midici-profiles/draft/1"; #ifdef __cplusplus @@ -51,19 +47,20 @@ typedef struct clap_plugin_midici_profiles { // Get a profile by index. // [main-thread] - bool(CLAP_ABI *get)(const clap_plugin_t *plugin, - uint16_t port_index, - uint32_t profile_index, - profile_t *profile); + bool(CLAP_ABI *get)(const clap_plugin_t *plugin, + uint16_t port_index, + uint32_t profile_index, + profile_t *profile); // Get profile specific data for the specified Inquiry Target. // Returns true if data is written to stream correctly. + // The profile_index profile must be enabled. // [main-thread] - bool(CLAP_ABI *get_data)(const clap_plugin_t *plugin, - uint16_t port_index, - uint32_t profile_index, - uint8_t inquiry_target, - const clap_ostream_t *stream); + bool(CLAP_ABI *get_data)(const clap_plugin_t *plugin, + uint16_t port_index, + uint32_t profile_index, + uint8_t inquiry_target, + const clap_ostream_t *stream); // Enables a profile, so the plugin knows the host will use it. // Returns true if the profile is enabled when the function returns. @@ -76,20 +73,20 @@ typedef struct clap_plugin_midici_profiles { // Note for hosts: after calling this function count()/get() may have changed !! // Note for plugins: do not call clap_host_midici_profiles.changed. // [main-thread] - bool(CLAP_ABI *enable)(const clap_plugin_t *plugin, - uint16_t port_index, - profile_id_t profile, - byte_t channel, - uint16_t num_channels); + bool(CLAP_ABI *enable)(const clap_plugin_t *plugin, + uint16_t port_index, + profile_id_t profile, + byte_t channel, + uint16_t num_channels); // Disables a profile. // Returns true if the profile is disabled when the function returns. // Note for hosts: after calling this function count()/get() may have changed !! // Note for plugins: do not call clap_host_midici_profiles.changed. // [main-thread] - bool(CLAP_ABI *disable)(const clap_plugin_t *plugin, - uint16_t port_index, - profile_id_t profile); + bool(CLAP_ABI *disable)(const clap_plugin_t *plugin, + uint16_t port_index, + profile_id_t profile); } clap_plugin_midici_profiles_t; typedef struct clap_host_midici_profiles { @@ -98,6 +95,45 @@ typedef struct clap_host_midici_profiles { void(CLAP_ABI *changed)(const clap_host_t *host); } clap_host_midici_profiles_t; + + + + +// Below are exactly the same interfaces, but for output ports. +// A MIDI effect plugin might want to know the host can receive per-note articulations in note attributes for example. + +static CLAP_CONSTEXPR const char CLAP_EXT_MIDICI_PROFILES_OUTPUT[] = "clap.midici-profiles-output/draft/1"; + +typedef struct clap_plugin_midici_profiles_output { + void(CLAP_ABI *changed)(const clap_plugin_t *plugin); +} clap_plugin_midici_profiles_output_t; + +typedef struct clap_host_midici_profiles_output { + uint32_t(CLAP_ABI *count)(const clap_host_t *host, + uint16_t port_index); + + bool(CLAP_ABI *get)(const clap_host_t *host, + uint16_t port_index, + uint32_t profile_index, + profile_t *profile); + + bool(CLAP_ABI *get_data)(const clap_host_t *host, + uint16_t port_index, + uint32_t profile_index, + uint8_t inquiry_target, + const clap_ostream_t *stream); + + bool(CLAP_ABI *enable)(const clap_host_t *host, + uint16_t port_index, + profile_id_t profile, + byte_t channel, + uint16_t num_channels); + + bool(CLAP_ABI *disable)(const clap_host_t *host, + uint16_t port_index, + profile_id_t profile); +} clap_host_midici_profiles_output_t; + #ifdef __cplusplus } #endif From 297a8ad0b35f48b5ac888590954ed8ffc8eb6dc4 Mon Sep 17 00:00:00 2001 From: Bremmers Date: Thu, 2 May 2024 20:10:32 +0200 Subject: [PATCH 12/40] comments --- include/clap/ext/draft/midici-profiles.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/clap/ext/draft/midici-profiles.h b/include/clap/ext/draft/midici-profiles.h index d247e8bc..3aaf68a3 100644 --- a/include/clap/ext/draft/midici-profiles.h +++ b/include/clap/ext/draft/midici-profiles.h @@ -18,6 +18,8 @@ // enabled group profiles: one entry per enabled group. One entry if profile isn't enabled at all. // port profiles: one entry +// This extension can only be used with note ports using the CLAP_NOTE_DIALECT_MIDI2 dialect. + static CLAP_CONSTEXPR const char CLAP_EXT_MIDICI_PROFILES[] = "clap.midici-profiles/draft/1"; #ifdef __cplusplus From 03bf236c8a78fbd440e8ac22ee0e327a2842ef8f Mon Sep 17 00:00:00 2001 From: Bremmers Date: Thu, 2 May 2024 20:15:12 +0200 Subject: [PATCH 13/40] comments --- include/clap/ext/draft/midici-profiles.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/clap/ext/draft/midici-profiles.h b/include/clap/ext/draft/midici-profiles.h index 3aaf68a3..3efd39e1 100644 --- a/include/clap/ext/draft/midici-profiles.h +++ b/include/clap/ext/draft/midici-profiles.h @@ -18,7 +18,7 @@ // enabled group profiles: one entry per enabled group. One entry if profile isn't enabled at all. // port profiles: one entry -// This extension can only be used with note ports using the CLAP_NOTE_DIALECT_MIDI2 dialect. +// Some features of this extension can only be used with note ports using the CLAP_NOTE_DIALECT_MIDI2 dialect (groups in particular). static CLAP_CONSTEXPR const char CLAP_EXT_MIDICI_PROFILES[] = "clap.midici-profiles/draft/1"; From a69c9fcf0388360578cffbebcc68be16ab96c225 Mon Sep 17 00:00:00 2001 From: Bremmers Date: Thu, 2 May 2024 20:33:53 +0200 Subject: [PATCH 14/40] comments --- include/clap/ext/draft/midici-profiles.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/clap/ext/draft/midici-profiles.h b/include/clap/ext/draft/midici-profiles.h index 3efd39e1..68c83342 100644 --- a/include/clap/ext/draft/midici-profiles.h +++ b/include/clap/ext/draft/midici-profiles.h @@ -56,6 +56,7 @@ typedef struct clap_plugin_midici_profiles { // Get profile specific data for the specified Inquiry Target. // Returns true if data is written to stream correctly. + // Returns false if there's no data available for this inquiry_target. // The profile_index profile must be enabled. // [main-thread] bool(CLAP_ABI *get_data)(const clap_plugin_t *plugin, From 11ab8bda13280bc983ec3f56e31230510a463534 Mon Sep 17 00:00:00 2001 From: Bremmers Date: Thu, 2 May 2024 21:28:41 +0200 Subject: [PATCH 15/40] comments --- include/clap/ext/draft/midici-profiles.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/clap/ext/draft/midici-profiles.h b/include/clap/ext/draft/midici-profiles.h index 68c83342..bd361c1e 100644 --- a/include/clap/ext/draft/midici-profiles.h +++ b/include/clap/ext/draft/midici-profiles.h @@ -5,7 +5,7 @@ //usage examples: //- the host can tell a MIDI keyboard the plugin conforms to the drawbar organ profile, so the keyboard can set up its faders for that. -//- the host can send per-note articulations in MIDI 2.0 protocol note-on attributes if there's an active profile for this. +//- the host can send per-note articulations in MIDI 2.0 protocol note-on attributes if there's an enabled profile for this. // background: // There are 4 types of profiles: single channel, multi channel, group and function block (called "port" here). @@ -82,7 +82,7 @@ typedef struct clap_plugin_midici_profiles { byte_t channel, uint16_t num_channels); - // Disables a profile. + // Disables all instances of a profile. // Returns true if the profile is disabled when the function returns. // Note for hosts: after calling this function count()/get() may have changed !! // Note for plugins: do not call clap_host_midici_profiles.changed. @@ -93,7 +93,7 @@ typedef struct clap_plugin_midici_profiles { } clap_plugin_midici_profiles_t; typedef struct clap_host_midici_profiles { - // Informs the host that the available or active profiles changed. + // Informs the host that the available or enabled profiles changed. // [main-thread] void(CLAP_ABI *changed)(const clap_host_t *host); } clap_host_midici_profiles_t; From d8c514f8cb3eb09ecc1836f17e8e3512a487e288 Mon Sep 17 00:00:00 2001 From: Bremmers Date: Thu, 2 May 2024 21:40:11 +0200 Subject: [PATCH 16/40] comments --- include/clap/ext/draft/midici-profiles.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/clap/ext/draft/midici-profiles.h b/include/clap/ext/draft/midici-profiles.h index bd361c1e..a87eb16a 100644 --- a/include/clap/ext/draft/midici-profiles.h +++ b/include/clap/ext/draft/midici-profiles.h @@ -42,7 +42,8 @@ typedef struct profile_t { }; typedef struct clap_plugin_midici_profiles { - // Returns the number of profiles supported. + // Returns the number of profile_id_t entries available. + // The comments above describe what's supposed to be in the list. // [main-thread] uint32_t(CLAP_ABI *count)(const clap_plugin_t *plugin, uint16_t port_index); @@ -54,7 +55,7 @@ typedef struct clap_plugin_midici_profiles { uint32_t profile_index, profile_t *profile); - // Get profile specific data for the specified Inquiry Target. + // Get profile specific data for the specified inquiry_target. // Returns true if data is written to stream correctly. // Returns false if there's no data available for this inquiry_target. // The profile_index profile must be enabled. From 3861f24690f60177b547a827b43d70c8691c07dc Mon Sep 17 00:00:00 2001 From: Bremmers Date: Thu, 2 May 2024 23:23:09 +0200 Subject: [PATCH 17/40] comments --- include/clap/ext/draft/midici-profiles.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/clap/ext/draft/midici-profiles.h b/include/clap/ext/draft/midici-profiles.h index a87eb16a..c41a28eb 100644 --- a/include/clap/ext/draft/midici-profiles.h +++ b/include/clap/ext/draft/midici-profiles.h @@ -13,9 +13,9 @@ // // clap_plugin_midici_profiles.count()/get() return a list of profile_t structs. // There'll typically be multiple entries for a single supported profile_id_t: -// enabled single channel profiles: one entry per enabled channel. One entry if profile isn't enabled at all. -// enabled multi channel profiles: one entry per enabled block of channels. One entry if profile isn't enabled at all. -// enabled group profiles: one entry per enabled group. One entry if profile isn't enabled at all. +// enabled single channel profiles: one entry per enabled channel. One entry if profile isn't enabled for any channel. +// enabled multi channel profiles: one entry per enabled block of channels. One entry if profile isn't enabled for any channel. +// enabled group profiles: one entry per enabled group. One entry if profile isn't enabled for any group. // port profiles: one entry // Some features of this extension can only be used with note ports using the CLAP_NOTE_DIALECT_MIDI2 dialect (groups in particular). From 59f8376c1f44e7dd29930b0943bda85820a7eb8e Mon Sep 17 00:00:00 2001 From: Bremmers Date: Fri, 3 May 2024 10:22:22 +0200 Subject: [PATCH 18/40] avoid plugins having to implement stream --- include/clap/ext/draft/midici-profiles.h | 33 ++++++++++++++++++------ 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/include/clap/ext/draft/midici-profiles.h b/include/clap/ext/draft/midici-profiles.h index c41a28eb..f3c0ae70 100644 --- a/include/clap/ext/draft/midici-profiles.h +++ b/include/clap/ext/draft/midici-profiles.h @@ -1,7 +1,7 @@ #pragma once #include "../../plugin.h" -#include "../stream.h" +#include "../../stream.h" //usage examples: //- the host can tell a MIDI keyboard the plugin conforms to the drawbar organ profile, so the keyboard can set up its faders for that. @@ -26,7 +26,7 @@ static CLAP_CONSTEXPR const char CLAP_EXT_MIDICI_PROFILES[] = "clap.midici-profi extern "C" { #endif -typedef profile_id_t profile_id[5]; +typedef byte_t profile_id_t[5]; typedef struct profile_t { profile_id_t profile_id; @@ -109,30 +109,47 @@ typedef struct clap_host_midici_profiles { static CLAP_CONSTEXPR const char CLAP_EXT_MIDICI_PROFILES_OUTPUT[] = "clap.midici-profiles-output/draft/1"; typedef struct clap_plugin_midici_profiles_output { + // see clap_host_midici_profiles.changed + // [main-thread] void(CLAP_ABI *changed)(const clap_plugin_t *plugin); } clap_plugin_midici_profiles_output_t; typedef struct clap_host_midici_profiles_output { + // see clap_plugin_midici_profiles.count + // [main-thread] uint32_t(CLAP_ABI *count)(const clap_host_t *host, uint16_t port_index); + // see clap_plugin_midici_profiles.get + // [main-thread] bool(CLAP_ABI *get)(const clap_host_t *host, uint16_t port_index, uint32_t profile_index, profile_t *profile); - bool(CLAP_ABI *get_data)(const clap_host_t *host, - uint16_t port_index, - uint32_t profile_index, - uint8_t inquiry_target, - const clap_ostream_t *stream); - + // see clap_plugin_midici_profiles.get_data + // here a buffer is used instead instead of a stream, which is easier for plugins + // Result > 0: buffer contains Result bytes of data. + // Result = 0: no data available for this inquiry_target. + // Result < 0: buffer too small, buffer_size should be -Result bytes + // [main-thread] + int32_t(CLAP_ABI *get_data)(const clap_host_t *host, + uint16_t port_index, + uint32_t profile_index, + uint8_t inquiry_target, + const uint8_t *buffer, + uint32_t buffer_size); + + // see clap_plugin_midici_profiles.enable + // [main-thread] bool(CLAP_ABI *enable)(const clap_host_t *host, uint16_t port_index, profile_id_t profile, byte_t channel, uint16_t num_channels); + // see clap_plugin_midici_profiles.disable + // [main-thread] bool(CLAP_ABI *disable)(const clap_host_t *host, uint16_t port_index, profile_id_t profile); From b6764f608e2fd88db9a49c3da0efbc176927a5bc Mon Sep 17 00:00:00 2001 From: Bremmers Date: Fri, 3 May 2024 10:25:30 +0200 Subject: [PATCH 19/40] Update all.h --- include/clap/all.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/clap/all.h b/include/clap/all.h index 45412475..3247897d 100644 --- a/include/clap/all.h +++ b/include/clap/all.h @@ -10,3 +10,5 @@ #include "ext/draft/transport-control.h" #include "ext/draft/triggers.h" #include "ext/draft/tuning.h" +#include "ext/draft/tuning.h" +#include "ext/draft/midici-profiles.h" From 6901df6c6dbb28eae4f9c84e3eab5f2366265df7 Mon Sep 17 00:00:00 2001 From: Bremmers Date: Fri, 3 May 2024 10:26:01 +0200 Subject: [PATCH 20/40] Update all.h --- include/clap/all.h | 1 - 1 file changed, 1 deletion(-) diff --git a/include/clap/all.h b/include/clap/all.h index 3247897d..c2e1d693 100644 --- a/include/clap/all.h +++ b/include/clap/all.h @@ -10,5 +10,4 @@ #include "ext/draft/transport-control.h" #include "ext/draft/triggers.h" #include "ext/draft/tuning.h" -#include "ext/draft/tuning.h" #include "ext/draft/midici-profiles.h" From dbec0600f23b35007a4265add21a4d39065b0a8a Mon Sep 17 00:00:00 2001 From: Bremmers Date: Fri, 3 May 2024 11:32:16 +0200 Subject: [PATCH 21/40] better profile_id_t --- include/clap/ext/draft/midici-profiles.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/include/clap/ext/draft/midici-profiles.h b/include/clap/ext/draft/midici-profiles.h index f3c0ae70..389e349e 100644 --- a/include/clap/ext/draft/midici-profiles.h +++ b/include/clap/ext/draft/midici-profiles.h @@ -26,7 +26,13 @@ static CLAP_CONSTEXPR const char CLAP_EXT_MIDICI_PROFILES[] = "clap.midici-profi extern "C" { #endif -typedef byte_t profile_id_t[5]; +typedef struct profile_id_t { + byte_t id; + byte_t bank; + byte_t number; + byte_t version; + byte_t level; +}; typedef struct profile_t { profile_id_t profile_id; From 9039f3ad0d65d79d9f2899e9053a32d2adf4d9f6 Mon Sep 17 00:00:00 2001 From: Bremmers Date: Fri, 3 May 2024 11:38:59 +0200 Subject: [PATCH 22/40] better alignment --- include/clap/ext/draft/midici-profiles.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/clap/ext/draft/midici-profiles.h b/include/clap/ext/draft/midici-profiles.h index 389e349e..f58aaded 100644 --- a/include/clap/ext/draft/midici-profiles.h +++ b/include/clap/ext/draft/midici-profiles.h @@ -36,7 +36,6 @@ typedef struct profile_id_t { typedef struct profile_t { profile_id_t profile_id; - byte_t enabled; // 0 = off, 1 = on, 2 = always on byte_t channel; // single-channel profiles: channel is 0..255 // multi-channel profiles: channel is 0..255 // group profiles: channel is 16 * group @@ -45,6 +44,7 @@ typedef struct profile_t { // multi-channel profiles: num_channels is 1..256 // group profiles: num_channels is 0 // port profiles: num_channels is 0 + byte_t enabled; // 0 = off, 1 = on, 2 = always on }; typedef struct clap_plugin_midici_profiles { From 88e38c1ea7390ab06e11014c72d24e7a1e69ca1e Mon Sep 17 00:00:00 2001 From: Bremmers Date: Fri, 3 May 2024 15:23:08 +0200 Subject: [PATCH 23/40] improvements --- include/clap/ext/draft/midici-profiles.h | 41 +++++++++++++----------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/include/clap/ext/draft/midici-profiles.h b/include/clap/ext/draft/midici-profiles.h index f58aaded..03ac3511 100644 --- a/include/clap/ext/draft/midici-profiles.h +++ b/include/clap/ext/draft/midici-profiles.h @@ -10,7 +10,12 @@ // background: // There are 4 types of profiles: single channel, multi channel, group and function block (called "port" here). // The profile specifications define the type for a specific profile. -// +// A channel + num_channels pair allows for targeting profiles (used in profile_t, get_data() and enable()): +// single-channel profiles: channel is 0..255, num_channels is 1 +// multi-channel profiles: channel is 0..255, num_channels is 1..256 +// group profiles: channel is 16 * group, num_channels is 0 +// port profiles: channel is 255, num_channels is 0 + // clap_plugin_midici_profiles.count()/get() return a list of profile_t structs. // There'll typically be multiple entries for a single supported profile_id_t: // enabled single channel profiles: one entry per enabled channel. One entry if profile isn't enabled for any channel. @@ -26,6 +31,12 @@ static CLAP_CONSTEXPR const char CLAP_EXT_MIDICI_PROFILES[] = "clap.midici-profi extern "C" { #endif +enum { + CLAP_MIDICI_PROFILE_DISABLED = 0, + CLAP_MIDICI_PROFILE_ENABLED = 1, + CLAP_MIDICI_PROFILE_ALWAYSON = 2 +}; + typedef struct profile_id_t { byte_t id; byte_t bank; @@ -36,15 +47,9 @@ typedef struct profile_id_t { typedef struct profile_t { profile_id_t profile_id; - byte_t channel; // single-channel profiles: channel is 0..255 - // multi-channel profiles: channel is 0..255 - // group profiles: channel is 16 * group - // port profiles: channel is 0 - uint16_t num_channels; // single-channel profiles: num_channels is 1 - // multi-channel profiles: num_channels is 1..256 - // group profiles: num_channels is 0 - // port profiles: num_channels is 0 - byte_t enabled; // 0 = off, 1 = on, 2 = always on + byte_t channel; // see description at top of file + uint16_t num_channels; // see description at top of file + byte_t enabled; // CLAP_MIDICI_PROFILE_* }; typedef struct clap_plugin_midici_profiles { @@ -64,22 +69,20 @@ typedef struct clap_plugin_midici_profiles { // Get profile specific data for the specified inquiry_target. // Returns true if data is written to stream correctly. // Returns false if there's no data available for this inquiry_target. - // The profile_index profile must be enabled. + // The profile targeted by channel/num_channels must be enabled. Return false otherwise. // [main-thread] bool(CLAP_ABI *get_data)(const clap_plugin_t *plugin, uint16_t port_index, - uint32_t profile_index, + profile_id_t profile, + byte_t channel, + uint16_t num_channels, uint8_t inquiry_target, const clap_ostream_t *stream); // Enables a profile, so the plugin knows the host will use it. // Returns true if the profile is enabled when the function returns. // Can be called multiple times to enabled a profile for multiple channels or groups. - // channel and num-channels define the destination: - // single-channel profiles: channel is 0..255, num_channels = 1 - // multi-channel profiles: channel is 0..255, num_channels = 1..256 - // group profiles: channel is 16 * group, num_channels = 0 - // port profiles: channel is 0, num_channels = 0 + // channel and num-channels: see description at top of file // Note for hosts: after calling this function count()/get() may have changed !! // Note for plugins: do not call clap_host_midici_profiles.changed. // [main-thread] @@ -141,7 +144,9 @@ typedef struct clap_host_midici_profiles_output { // [main-thread] int32_t(CLAP_ABI *get_data)(const clap_host_t *host, uint16_t port_index, - uint32_t profile_index, + profile_id_t profile, + byte_t channel, + uint16_t num_channels, uint8_t inquiry_target, const uint8_t *buffer, uint32_t buffer_size); From 88c74af521b4640a1f3bff4f6fd2275193ce4712 Mon Sep 17 00:00:00 2001 From: Bremmers Date: Fri, 3 May 2024 22:24:27 +0200 Subject: [PATCH 24/40] more comments, removed output port version for now, renamed get_data() to get_details() --- include/clap/ext/draft/midici-profiles.h | 130 ++++++++--------------- 1 file changed, 43 insertions(+), 87 deletions(-) diff --git a/include/clap/ext/draft/midici-profiles.h b/include/clap/ext/draft/midici-profiles.h index 03ac3511..18ef654c 100644 --- a/include/clap/ext/draft/midici-profiles.h +++ b/include/clap/ext/draft/midici-profiles.h @@ -3,25 +3,37 @@ #include "../../plugin.h" #include "../../stream.h" -//usage examples: -//- the host can tell a MIDI keyboard the plugin conforms to the drawbar organ profile, so the keyboard can set up its faders for that. -//- the host can send per-note articulations in MIDI 2.0 protocol note-on attributes if there's an enabled profile for this. +// usage examples: +// - the host can tell a MIDI keyboard the plugin conforms to the drawbar organ profile, so the keyboard can set up its faders for that. +// - the host can send per-note articulations in MIDI 2.0 protocol note-on attributes if there's an enabled profile for this. -// background: +// destination addressing: // There are 4 types of profiles: single channel, multi channel, group and function block (called "port" here). // The profile specifications define the type for a specific profile. -// A channel + num_channels pair allows for targeting profiles (used in profile_t, get_data() and enable()): +// A channel/num_channels pair allows for targeting profiles (used in profile_t, get_details() and enable()): // single-channel profiles: channel is 0..255, num_channels is 1 // multi-channel profiles: channel is 0..255, num_channels is 1..256 // group profiles: channel is 16 * group, num_channels is 0 // port profiles: channel is 255, num_channels is 0 -// clap_plugin_midici_profiles.count()/get() return a list of profile_t structs. -// There'll typically be multiple entries for a single supported profile_id_t: -// enabled single channel profiles: one entry per enabled channel. One entry if profile isn't enabled for any channel. -// enabled multi channel profiles: one entry per enabled block of channels. One entry if profile isn't enabled for any channel. -// enabled group profiles: one entry per enabled group. One entry if profile isn't enabled for any group. -// port profiles: one entry +// enumerating profiles +// clap_plugin_midici_profiles.count()/get() return a list of profile_t structs. Both enabled and available profiles are listed. +// All enabled profiles are listed. Multiple entries will appear if a channel or group profile is enabled on multiple channels or groups. +// If a profile isn't enabled a single CLAP_MIDICI_PROFILE_DISABLED entry appears in the list. In case of a channel or group profile the host can try to enable it on any channel or group, +// and the plugin can reject this if it isn't possible. +// In detail: +// enabled single channel profiles: one entry per enabled channel. One CLAP_MIDICI_PROFILE_DISABLED entry if the profile isn't enabled for any channel. +// enabled multi channel profiles: one entry per enabled block of channels. One CLAP_MIDICI_PROFILE_DISABLED entry if the profile isn't enabled for any channel. +// enabled group profiles: one entry per enabled group. One CLAP_MIDICI_PROFILE_DISABLED entry if the profile isn't enabled for any group. +// port profiles: one entry. + +// A host will typically proceed in this order: +// 1. get list using clap_plugin_midici_profiles.count()/get(). +// 2. enable/disable profiles. +// 3. get profile details using clap_plugin_midici_profiles.get_details(). + +// Plugins can use CLAP_MIDICI_PROFILE_ALWAYSON for profiles which can't be enabled/disabled by the host. +// Note that a plugin can remove a CLAP_MIDICI_PROFILE_ALWAYSON profile and call clap_host_midici_profiles.changed(). // Some features of this extension can only be used with note ports using the CLAP_NOTE_DIALECT_MIDI2 dialect (groups in particular). @@ -47,42 +59,44 @@ typedef struct profile_id_t { typedef struct profile_t { profile_id_t profile_id; - byte_t channel; // see description at top of file - uint16_t num_channels; // see description at top of file - byte_t enabled; // CLAP_MIDICI_PROFILE_* + byte_t channel; // see "destination addressing" paragraph at top of file. + uint16_t num_channels; // see "destination addressing" paragraph at top of file. + byte_t enabled; // CLAP_MIDICI_PROFILE_* }; typedef struct clap_plugin_midici_profiles { - // Returns the number of profile_id_t entries available. - // The comments above describe what's supposed to be in the list. + // Returns the number of profile_t entries available. + // The "enumerating profiles" paragraph above describes what's supposed to be in the list. // [main-thread] uint32_t(CLAP_ABI *count)(const clap_plugin_t *plugin, uint16_t port_index); - // Get a profile by index. + // Get a profile_t by index. // [main-thread] bool(CLAP_ABI *get)(const clap_plugin_t *plugin, uint16_t port_index, uint32_t profile_index, profile_t *profile); - // Get profile specific data for the specified inquiry_target. + // Get profile details for the specified inquiry_target. // Returns true if data is written to stream correctly. // Returns false if there's no data available for this inquiry_target. - // The profile targeted by channel/num_channels must be enabled. Return false otherwise. + // channel and num-channels: see "destination addressing" paragraph at top of file. + // The profile targeted by channel/num_channels should generally be enabled before calling this function. + // In some cases profile detals like available channels are needed before enabling a profile. Plugins should make sure this is handled correctly. // [main-thread] - bool(CLAP_ABI *get_data)(const clap_plugin_t *plugin, - uint16_t port_index, - profile_id_t profile, - byte_t channel, - uint16_t num_channels, - uint8_t inquiry_target, - const clap_ostream_t *stream); + bool(CLAP_ABI *get_details)(const clap_plugin_t *plugin, + uint16_t port_index, + profile_id_t profile, + byte_t channel, + uint16_t num_channels, + uint8_t inquiry_target, + const clap_ostream_t *stream); // Enables a profile, so the plugin knows the host will use it. - // Returns true if the profile is enabled when the function returns. + // Returns true if the profile is enabled at channel/num_channels when the function returns. // Can be called multiple times to enabled a profile for multiple channels or groups. - // channel and num-channels: see description at top of file + // channel and num-channels: see "destination addressing" paragraph at top of file. // Note for hosts: after calling this function count()/get() may have changed !! // Note for plugins: do not call clap_host_midici_profiles.changed. // [main-thread] @@ -93,7 +107,7 @@ typedef struct clap_plugin_midici_profiles { uint16_t num_channels); // Disables all instances of a profile. - // Returns true if the profile is disabled when the function returns. + // Returns true if all instances of the profile are disabled when the function returns. // Note for hosts: after calling this function count()/get() may have changed !! // Note for plugins: do not call clap_host_midici_profiles.changed. // [main-thread] @@ -108,64 +122,6 @@ typedef struct clap_host_midici_profiles { void(CLAP_ABI *changed)(const clap_host_t *host); } clap_host_midici_profiles_t; - - - - -// Below are exactly the same interfaces, but for output ports. -// A MIDI effect plugin might want to know the host can receive per-note articulations in note attributes for example. - -static CLAP_CONSTEXPR const char CLAP_EXT_MIDICI_PROFILES_OUTPUT[] = "clap.midici-profiles-output/draft/1"; - -typedef struct clap_plugin_midici_profiles_output { - // see clap_host_midici_profiles.changed - // [main-thread] - void(CLAP_ABI *changed)(const clap_plugin_t *plugin); -} clap_plugin_midici_profiles_output_t; - -typedef struct clap_host_midici_profiles_output { - // see clap_plugin_midici_profiles.count - // [main-thread] - uint32_t(CLAP_ABI *count)(const clap_host_t *host, - uint16_t port_index); - - // see clap_plugin_midici_profiles.get - // [main-thread] - bool(CLAP_ABI *get)(const clap_host_t *host, - uint16_t port_index, - uint32_t profile_index, - profile_t *profile); - - // see clap_plugin_midici_profiles.get_data - // here a buffer is used instead instead of a stream, which is easier for plugins - // Result > 0: buffer contains Result bytes of data. - // Result = 0: no data available for this inquiry_target. - // Result < 0: buffer too small, buffer_size should be -Result bytes - // [main-thread] - int32_t(CLAP_ABI *get_data)(const clap_host_t *host, - uint16_t port_index, - profile_id_t profile, - byte_t channel, - uint16_t num_channels, - uint8_t inquiry_target, - const uint8_t *buffer, - uint32_t buffer_size); - - // see clap_plugin_midici_profiles.enable - // [main-thread] - bool(CLAP_ABI *enable)(const clap_host_t *host, - uint16_t port_index, - profile_id_t profile, - byte_t channel, - uint16_t num_channels); - - // see clap_plugin_midici_profiles.disable - // [main-thread] - bool(CLAP_ABI *disable)(const clap_host_t *host, - uint16_t port_index, - profile_id_t profile); -} clap_host_midici_profiles_output_t; - #ifdef __cplusplus } #endif From b6e4a0b97b731e01a1be6891bc38397a256ccf5b Mon Sep 17 00:00:00 2001 From: Bremmers Date: Sat, 4 May 2024 10:57:35 +0200 Subject: [PATCH 25/40] comments --- include/clap/ext/draft/midici-profiles.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/include/clap/ext/draft/midici-profiles.h b/include/clap/ext/draft/midici-profiles.h index 18ef654c..f8005b4f 100644 --- a/include/clap/ext/draft/midici-profiles.h +++ b/include/clap/ext/draft/midici-profiles.h @@ -19,17 +19,19 @@ // enumerating profiles // clap_plugin_midici_profiles.count()/get() return a list of profile_t structs. Both enabled and available profiles are listed. // All enabled profiles are listed. Multiple entries will appear if a channel or group profile is enabled on multiple channels or groups. -// If a profile isn't enabled a single CLAP_MIDICI_PROFILE_DISABLED entry appears in the list. In case of a channel or group profile the host can try to enable it on any channel or group, +// If a profile isn't enabled at least one CLAP_MIDICI_PROFILE_DISABLED entry appears in the list, so the host can detect the profile is supported. In case of a channel or group profile the host can try to enable it on any channel or group, // and the plugin can reject this if it isn't possible. // In detail: -// enabled single channel profiles: one entry per enabled channel. One CLAP_MIDICI_PROFILE_DISABLED entry if the profile isn't enabled for any channel. -// enabled multi channel profiles: one entry per enabled block of channels. One CLAP_MIDICI_PROFILE_DISABLED entry if the profile isn't enabled for any channel. -// enabled group profiles: one entry per enabled group. One CLAP_MIDICI_PROFILE_DISABLED entry if the profile isn't enabled for any group. +// enabled single channel profiles: one entry per enabled channel. At least one CLAP_MIDICI_PROFILE_DISABLED entry if the profile isn't enabled for any channel. +// enabled multi channel profiles: one entry per enabled block of channels. At least one CLAP_MIDICI_PROFILE_DISABLED entry if the profile isn't enabled for any channel. +// enabled group profiles: one entry per enabled group. At least one CLAP_MIDICI_PROFILE_DISABLED entry if the profile isn't enabled for any group. // port profiles: one entry. +// Plugins can typically use a simple fixed list. For example: in case of a single-channel profile and 16 channels, clap_plugin_midici_profiles.count() can always return 16. get() uses the current enabled state for each channel. + // A host will typically proceed in this order: // 1. get list using clap_plugin_midici_profiles.count()/get(). -// 2. enable/disable profiles. +// 2. enable/disable profiles as needed. // 3. get profile details using clap_plugin_midici_profiles.get_details(). // Plugins can use CLAP_MIDICI_PROFILE_ALWAYSON for profiles which can't be enabled/disabled by the host. From 7006b80baf6711ccf237366b1b833eeb9659ac52 Mon Sep 17 00:00:00 2001 From: Bremmers Date: Sat, 4 May 2024 14:35:09 +0200 Subject: [PATCH 26/40] supports Profile Specific Data Messages for (MPE Channel Response etc.) --- include/clap/ext/draft/midici-profiles.h | 35 ++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/include/clap/ext/draft/midici-profiles.h b/include/clap/ext/draft/midici-profiles.h index f8005b4f..7e96f5bd 100644 --- a/include/clap/ext/draft/midici-profiles.h +++ b/include/clap/ext/draft/midici-profiles.h @@ -19,15 +19,16 @@ // enumerating profiles // clap_plugin_midici_profiles.count()/get() return a list of profile_t structs. Both enabled and available profiles are listed. // All enabled profiles are listed. Multiple entries will appear if a channel or group profile is enabled on multiple channels or groups. -// If a profile isn't enabled at least one CLAP_MIDICI_PROFILE_DISABLED entry appears in the list, so the host can detect the profile is supported. In case of a channel or group profile the host can try to enable it on any channel or group, -// and the plugin can reject this if it isn't possible. +// If a profile isn't enabled at least one CLAP_MIDICI_PROFILE_DISABLED entry appears in the list, so the host can detect the profile is supported. +// In case of a channel or group profile the host can try to enable it on any channel or group, and the plugin can reject this if it isn't possible. // In detail: // enabled single channel profiles: one entry per enabled channel. At least one CLAP_MIDICI_PROFILE_DISABLED entry if the profile isn't enabled for any channel. // enabled multi channel profiles: one entry per enabled block of channels. At least one CLAP_MIDICI_PROFILE_DISABLED entry if the profile isn't enabled for any channel. // enabled group profiles: one entry per enabled group. At least one CLAP_MIDICI_PROFILE_DISABLED entry if the profile isn't enabled for any group. // port profiles: one entry. -// Plugins can typically use a simple fixed list. For example: in case of a single-channel profile and 16 channels, clap_plugin_midici_profiles.count() can always return 16. get() uses the current enabled state for each channel. +// Plugins can typically use a simple fixed list. For example: in case of a single-channel profile and 16 channels, clap_plugin_midici_profiles.count() can always return 16. +// get() uses the current enabled state for each channel. // A host will typically proceed in this order: // 1. get list using clap_plugin_midici_profiles.count()/get(). @@ -51,6 +52,10 @@ enum { CLAP_MIDICI_PROFILE_ALWAYSON = 2 }; +enum { + CLAP_MIDICI_PROFILE_INQUIRY_TARGET_DATA = 255 +}; + typedef struct profile_id_t { byte_t id; byte_t bank; @@ -86,6 +91,8 @@ typedef struct clap_plugin_midici_profiles { // channel and num-channels: see "destination addressing" paragraph at top of file. // The profile targeted by channel/num_channels should generally be enabled before calling this function. // In some cases profile detals like available channels are needed before enabling a profile. Plugins should make sure this is handled correctly. + // inquiry_target is 0..127. CLAP_MIDICI_PROFILE_INQUIRY_TARGET_DATA can be used to get Profile Specific Data from the plugin. + // Multiple Profile Specific Data Messages can be written to stream. Each one starts with 0xF0, followed by the actual Profile Specific Data, and ends with 0xF7. // [main-thread] bool(CLAP_ABI *get_details)(const clap_plugin_t *plugin, uint16_t port_index, @@ -95,6 +102,19 @@ typedef struct clap_plugin_midici_profiles { uint8_t inquiry_target, const clap_ostream_t *stream); + // Send Profile Specific Data to plugin. + // Returns true if data was accepted + // Multiple Profile Specific Data Messages can be passed in buffer. Each one starts with 0xF0, followed by the actual Profile Specific Data, and ends with 0xF7. + // A profile may specify multiple data messages. It's recommended to send the complete 'state' in a single set_data() call. + // [main-thread] + bool(CLAP_ABI *set_data)(const clap_plugin_t *plugin, + uint16_t port_index, + profile_id_t profile, + byte_t channel, + uint16_t num_channels, + const uint8_t *buffer, + uint32_t buffer_size); + // Enables a profile, so the plugin knows the host will use it. // Returns true if the profile is enabled at channel/num_channels when the function returns. // Can be called multiple times to enabled a profile for multiple channels or groups. @@ -122,6 +142,15 @@ typedef struct clap_host_midici_profiles { // Informs the host that the available or enabled profiles changed. // [main-thread] void(CLAP_ABI *changed)(const clap_host_t *host); + + // Plugins calls this if host needs to read Profile Specific Data Messages again. + // Host calls get_details(.., port_index, profile, channel, num_channels, CLAP_MIDICI_PROFILE_INQUIRY_TARGET_DATA, ..). + // [main-thread] + void(CLAP_ABI *datachanged)(const clap_host_t *host, + uint16_t port_index, + profile_id_t profile, + byte_t channel, + uint16_t num_channels); } clap_host_midici_profiles_t; #ifdef __cplusplus From 63438569f21544b5bce26191bd577de4dbb4c14d Mon Sep 17 00:00:00 2001 From: Bremmers Date: Sat, 4 May 2024 22:15:21 +0200 Subject: [PATCH 27/40] added const --- include/clap/ext/draft/midici-profiles.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/include/clap/ext/draft/midici-profiles.h b/include/clap/ext/draft/midici-profiles.h index 7e96f5bd..ca344b9e 100644 --- a/include/clap/ext/draft/midici-profiles.h +++ b/include/clap/ext/draft/midici-profiles.h @@ -96,7 +96,7 @@ typedef struct clap_plugin_midici_profiles { // [main-thread] bool(CLAP_ABI *get_details)(const clap_plugin_t *plugin, uint16_t port_index, - profile_id_t profile, + const profile_id_t profile, byte_t channel, uint16_t num_channels, uint8_t inquiry_target, @@ -109,7 +109,7 @@ typedef struct clap_plugin_midici_profiles { // [main-thread] bool(CLAP_ABI *set_data)(const clap_plugin_t *plugin, uint16_t port_index, - profile_id_t profile, + const profile_id_t profile, byte_t channel, uint16_t num_channels, const uint8_t *buffer, @@ -124,7 +124,7 @@ typedef struct clap_plugin_midici_profiles { // [main-thread] bool(CLAP_ABI *enable)(const clap_plugin_t *plugin, uint16_t port_index, - profile_id_t profile, + const profile_id_t profile, byte_t channel, uint16_t num_channels); @@ -135,7 +135,7 @@ typedef struct clap_plugin_midici_profiles { // [main-thread] bool(CLAP_ABI *disable)(const clap_plugin_t *plugin, uint16_t port_index, - profile_id_t profile); + const profile_id_t profile); } clap_plugin_midici_profiles_t; typedef struct clap_host_midici_profiles { @@ -148,7 +148,7 @@ typedef struct clap_host_midici_profiles { // [main-thread] void(CLAP_ABI *datachanged)(const clap_host_t *host, uint16_t port_index, - profile_id_t profile, + const profile_id_t profile, byte_t channel, uint16_t num_channels); } clap_host_midici_profiles_t; From d94bdc6cddc0b479dba8162aa872b39016e308ee Mon Sep 17 00:00:00 2001 From: Bremmers Date: Sun, 5 May 2024 12:23:24 +0200 Subject: [PATCH 28/40] disable now works per-instance --- include/clap/ext/draft/midici-profiles.h | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/include/clap/ext/draft/midici-profiles.h b/include/clap/ext/draft/midici-profiles.h index ca344b9e..a83f71d8 100644 --- a/include/clap/ext/draft/midici-profiles.h +++ b/include/clap/ext/draft/midici-profiles.h @@ -85,14 +85,15 @@ typedef struct clap_plugin_midici_profiles { uint32_t profile_index, profile_t *profile); - // Get profile details for the specified inquiry_target. + // Get profile details from profile at channel/num_channels for the specified inquiry_target. // Returns true if data is written to stream correctly. // Returns false if there's no data available for this inquiry_target. // channel and num-channels: see "destination addressing" paragraph at top of file. - // The profile targeted by channel/num_channels should generally be enabled before calling this function. - // In some cases profile detals like available channels are needed before enabling a profile. Plugins should make sure this is handled correctly. // inquiry_target is 0..127. CLAP_MIDICI_PROFILE_INQUIRY_TARGET_DATA can be used to get Profile Specific Data from the plugin. // Multiple Profile Specific Data Messages can be written to stream. Each one starts with 0xF0, followed by the actual Profile Specific Data, and ends with 0xF7. + // Example: MPE Channel Response Type Notification would be F0 01 F7 + // The profile targeted by channel/num_channels should generally be enabled before calling this function. + // In some cases profile detals like available channels are needed before enabling a profile. Plugins should make sure this is handled correctly. // [main-thread] bool(CLAP_ABI *get_details)(const clap_plugin_t *plugin, uint16_t port_index, @@ -102,9 +103,10 @@ typedef struct clap_plugin_midici_profiles { uint8_t inquiry_target, const clap_ostream_t *stream); - // Send Profile Specific Data to plugin. + // Send Profile Specific Data to profile at channel/num_channels. // Returns true if data was accepted // Multiple Profile Specific Data Messages can be passed in buffer. Each one starts with 0xF0, followed by the actual Profile Specific Data, and ends with 0xF7. + // Example: MPE Channel Response Type Notification would be F0 01 F7 // A profile may specify multiple data messages. It's recommended to send the complete 'state' in a single set_data() call. // [main-thread] bool(CLAP_ABI *set_data)(const clap_plugin_t *plugin, @@ -115,7 +117,7 @@ typedef struct clap_plugin_midici_profiles { const uint8_t *buffer, uint32_t buffer_size); - // Enables a profile, so the plugin knows the host will use it. + // Enables a profile at channel/num_channels. // Returns true if the profile is enabled at channel/num_channels when the function returns. // Can be called multiple times to enabled a profile for multiple channels or groups. // channel and num-channels: see "destination addressing" paragraph at top of file. @@ -128,14 +130,16 @@ typedef struct clap_plugin_midici_profiles { byte_t channel, uint16_t num_channels); - // Disables all instances of a profile. - // Returns true if all instances of the profile are disabled when the function returns. + // Disables a profile at channel/num_channels. + // Returns true if the profile isn't enabled at channel/num_channels when the function returns. // Note for hosts: after calling this function count()/get() may have changed !! // Note for plugins: do not call clap_host_midici_profiles.changed. // [main-thread] bool(CLAP_ABI *disable)(const clap_plugin_t *plugin, uint16_t port_index, - const profile_id_t profile); + const profile_id_t profile, + byte_t channel, + uint16_t num_channels); } clap_plugin_midici_profiles_t; typedef struct clap_host_midici_profiles { From 1fa02a323bc856d6446b446da85eb401dc1669a5 Mon Sep 17 00:00:00 2001 From: Bremmers Date: Sun, 5 May 2024 12:57:26 +0200 Subject: [PATCH 29/40] C fixes --- include/clap/ext/draft/midici-profiles.h | 72 ++++++++++++------------ 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/include/clap/ext/draft/midici-profiles.h b/include/clap/ext/draft/midici-profiles.h index a83f71d8..c3fb3279 100644 --- a/include/clap/ext/draft/midici-profiles.h +++ b/include/clap/ext/draft/midici-profiles.h @@ -57,18 +57,18 @@ enum { }; typedef struct profile_id_t { - byte_t id; - byte_t bank; - byte_t number; - byte_t version; - byte_t level; + uint8_t id; + uint8_t bank; + uint8_t number; + uint8_t version; + uint8_t level; }; typedef struct profile_t { profile_id_t profile_id; - byte_t channel; // see "destination addressing" paragraph at top of file. + uint8_t channel; // see "destination addressing" paragraph at top of file. uint16_t num_channels; // see "destination addressing" paragraph at top of file. - byte_t enabled; // CLAP_MIDICI_PROFILE_* + uint8_t enabled; // CLAP_MIDICI_PROFILE_* }; typedef struct clap_plugin_midici_profiles { @@ -95,13 +95,13 @@ typedef struct clap_plugin_midici_profiles { // The profile targeted by channel/num_channels should generally be enabled before calling this function. // In some cases profile detals like available channels are needed before enabling a profile. Plugins should make sure this is handled correctly. // [main-thread] - bool(CLAP_ABI *get_details)(const clap_plugin_t *plugin, - uint16_t port_index, - const profile_id_t profile, - byte_t channel, - uint16_t num_channels, - uint8_t inquiry_target, - const clap_ostream_t *stream); + bool(CLAP_ABI *get_details)(const clap_plugin_t *plugin, + uint16_t port_index, + const struct profile_id_t profile, + uint8_t channel, + uint16_t num_channels, + uint8_t inquiry_target, + const clap_ostream_t *stream); // Send Profile Specific Data to profile at channel/num_channels. // Returns true if data was accepted @@ -109,13 +109,13 @@ typedef struct clap_plugin_midici_profiles { // Example: MPE Channel Response Type Notification would be F0 01 F7 // A profile may specify multiple data messages. It's recommended to send the complete 'state' in a single set_data() call. // [main-thread] - bool(CLAP_ABI *set_data)(const clap_plugin_t *plugin, - uint16_t port_index, - const profile_id_t profile, - byte_t channel, - uint16_t num_channels, - const uint8_t *buffer, - uint32_t buffer_size); + bool(CLAP_ABI *set_data)(const clap_plugin_t *plugin, + uint16_t port_index, + const struct profile_id_t profile, + uint8_t channel, + uint16_t num_channels, + const uint8_t *buffer, + uint32_t buffer_size); // Enables a profile at channel/num_channels. // Returns true if the profile is enabled at channel/num_channels when the function returns. @@ -124,22 +124,22 @@ typedef struct clap_plugin_midici_profiles { // Note for hosts: after calling this function count()/get() may have changed !! // Note for plugins: do not call clap_host_midici_profiles.changed. // [main-thread] - bool(CLAP_ABI *enable)(const clap_plugin_t *plugin, - uint16_t port_index, - const profile_id_t profile, - byte_t channel, - uint16_t num_channels); + bool(CLAP_ABI *enable)(const clap_plugin_t *plugin, + uint16_t port_index, + const struct profile_id_t profile, + uint8_t channel, + uint16_t num_channels); // Disables a profile at channel/num_channels. // Returns true if the profile isn't enabled at channel/num_channels when the function returns. // Note for hosts: after calling this function count()/get() may have changed !! // Note for plugins: do not call clap_host_midici_profiles.changed. // [main-thread] - bool(CLAP_ABI *disable)(const clap_plugin_t *plugin, - uint16_t port_index, - const profile_id_t profile, - byte_t channel, - uint16_t num_channels); + bool(CLAP_ABI *disable)(const clap_plugin_t *plugin, + uint16_t port_index, + const struct profile_id_t profile, + uint8_t channel, + uint16_t num_channels); } clap_plugin_midici_profiles_t; typedef struct clap_host_midici_profiles { @@ -150,11 +150,11 @@ typedef struct clap_host_midici_profiles { // Plugins calls this if host needs to read Profile Specific Data Messages again. // Host calls get_details(.., port_index, profile, channel, num_channels, CLAP_MIDICI_PROFILE_INQUIRY_TARGET_DATA, ..). // [main-thread] - void(CLAP_ABI *datachanged)(const clap_host_t *host, - uint16_t port_index, - const profile_id_t profile, - byte_t channel, - uint16_t num_channels); + void(CLAP_ABI *datachanged)(const clap_host_t *host, + uint16_t port_index, + const structprofile_id_t profile, + uint8_t channel, + uint16_t num_channels); } clap_host_midici_profiles_t; #ifdef __cplusplus From 1987528f1289de833e6dd530c819922757095583 Mon Sep 17 00:00:00 2001 From: Bremmers Date: Sun, 5 May 2024 13:09:42 +0200 Subject: [PATCH 30/40] more --- include/clap/ext/draft/midici-profiles.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/include/clap/ext/draft/midici-profiles.h b/include/clap/ext/draft/midici-profiles.h index c3fb3279..72ce30ff 100644 --- a/include/clap/ext/draft/midici-profiles.h +++ b/include/clap/ext/draft/midici-profiles.h @@ -65,7 +65,7 @@ typedef struct profile_id_t { }; typedef struct profile_t { - profile_id_t profile_id; + profile_id_t id; uint8_t channel; // see "destination addressing" paragraph at top of file. uint16_t num_channels; // see "destination addressing" paragraph at top of file. uint8_t enabled; // CLAP_MIDICI_PROFILE_* @@ -80,10 +80,10 @@ typedef struct clap_plugin_midici_profiles { // Get a profile_t by index. // [main-thread] - bool(CLAP_ABI *get)(const clap_plugin_t *plugin, - uint16_t port_index, - uint32_t profile_index, - profile_t *profile); + bool(CLAP_ABI *get)(const clap_plugin_t *plugin, + uint16_t port_index, + uint32_t profile_index, + const struct profile_t *profile); // Get profile details from profile at channel/num_channels for the specified inquiry_target. // Returns true if data is written to stream correctly. @@ -150,10 +150,10 @@ typedef struct clap_host_midici_profiles { // Plugins calls this if host needs to read Profile Specific Data Messages again. // Host calls get_details(.., port_index, profile, channel, num_channels, CLAP_MIDICI_PROFILE_INQUIRY_TARGET_DATA, ..). // [main-thread] - void(CLAP_ABI *datachanged)(const clap_host_t *host, - uint16_t port_index, - const structprofile_id_t profile, - uint8_t channel, + void(CLAP_ABI *datachanged)(const clap_host_t *host, + uint16_t port_index, + const struct profile_id_t profile, + uint8_t channel, uint16_t num_channels); } clap_host_midici_profiles_t; From 0c6e28c5d6ad4f0de9d78b9b1d6ccccd0e3ffc59 Mon Sep 17 00:00:00 2001 From: Bremmers Date: Sun, 5 May 2024 13:15:14 +0200 Subject: [PATCH 31/40] more --- include/clap/ext/draft/midici-profiles.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/clap/ext/draft/midici-profiles.h b/include/clap/ext/draft/midici-profiles.h index 72ce30ff..102c291b 100644 --- a/include/clap/ext/draft/midici-profiles.h +++ b/include/clap/ext/draft/midici-profiles.h @@ -56,20 +56,20 @@ enum { CLAP_MIDICI_PROFILE_INQUIRY_TARGET_DATA = 255 }; -typedef struct profile_id_t { +typedef struct profile_id { uint8_t id; uint8_t bank; uint8_t number; uint8_t version; uint8_t level; -}; +} profile_id_t; -typedef struct profile_t { +typedef struct profile { profile_id_t id; uint8_t channel; // see "destination addressing" paragraph at top of file. uint16_t num_channels; // see "destination addressing" paragraph at top of file. uint8_t enabled; // CLAP_MIDICI_PROFILE_* -}; +} profile_t; typedef struct clap_plugin_midici_profiles { // Returns the number of profile_t entries available. From 16a34702bdf6f06524ad926793a3abfd27c17f04 Mon Sep 17 00:00:00 2001 From: Bremmers Date: Sun, 5 May 2024 13:23:53 +0200 Subject: [PATCH 32/40] Update midici-profiles.h --- include/clap/ext/draft/midici-profiles.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/clap/ext/draft/midici-profiles.h b/include/clap/ext/draft/midici-profiles.h index 102c291b..b428255c 100644 --- a/include/clap/ext/draft/midici-profiles.h +++ b/include/clap/ext/draft/midici-profiles.h @@ -83,7 +83,7 @@ typedef struct clap_plugin_midici_profiles { bool(CLAP_ABI *get)(const clap_plugin_t *plugin, uint16_t port_index, uint32_t profile_index, - const struct profile_t *profile); + const struct profile *profile); // Get profile details from profile at channel/num_channels for the specified inquiry_target. // Returns true if data is written to stream correctly. @@ -97,7 +97,7 @@ typedef struct clap_plugin_midici_profiles { // [main-thread] bool(CLAP_ABI *get_details)(const clap_plugin_t *plugin, uint16_t port_index, - const struct profile_id_t profile, + const struct profile_id profile, uint8_t channel, uint16_t num_channels, uint8_t inquiry_target, From e209ae8635775322cf24a344d73e83e944039a64 Mon Sep 17 00:00:00 2001 From: Bremmers Date: Sun, 5 May 2024 13:26:19 +0200 Subject: [PATCH 33/40] Update midici-profiles.h --- include/clap/ext/draft/midici-profiles.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/clap/ext/draft/midici-profiles.h b/include/clap/ext/draft/midici-profiles.h index b428255c..9e3c41b3 100644 --- a/include/clap/ext/draft/midici-profiles.h +++ b/include/clap/ext/draft/midici-profiles.h @@ -111,7 +111,7 @@ typedef struct clap_plugin_midici_profiles { // [main-thread] bool(CLAP_ABI *set_data)(const clap_plugin_t *plugin, uint16_t port_index, - const struct profile_id_t profile, + const profile_id_t profile, uint8_t channel, uint16_t num_channels, const uint8_t *buffer, @@ -126,7 +126,7 @@ typedef struct clap_plugin_midici_profiles { // [main-thread] bool(CLAP_ABI *enable)(const clap_plugin_t *plugin, uint16_t port_index, - const struct profile_id_t profile, + const profile_id_t profile, uint8_t channel, uint16_t num_channels); @@ -137,7 +137,7 @@ typedef struct clap_plugin_midici_profiles { // [main-thread] bool(CLAP_ABI *disable)(const clap_plugin_t *plugin, uint16_t port_index, - const struct profile_id_t profile, + const profile_id_t profile, uint8_t channel, uint16_t num_channels); } clap_plugin_midici_profiles_t; @@ -152,7 +152,7 @@ typedef struct clap_host_midici_profiles { // [main-thread] void(CLAP_ABI *datachanged)(const clap_host_t *host, uint16_t port_index, - const struct profile_id_t profile, + const profile_id_t profile, uint8_t channel, uint16_t num_channels); } clap_host_midici_profiles_t; From a5bbca614e5ff3204741ed808656a9fde5d7334c Mon Sep 17 00:00:00 2001 From: Bremmers Date: Sun, 5 May 2024 13:47:44 +0200 Subject: [PATCH 34/40] cleanup --- include/clap/ext/draft/midici-profiles.h | 60 ++++++++++++------------ 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/include/clap/ext/draft/midici-profiles.h b/include/clap/ext/draft/midici-profiles.h index 9e3c41b3..018c2d58 100644 --- a/include/clap/ext/draft/midici-profiles.h +++ b/include/clap/ext/draft/midici-profiles.h @@ -17,14 +17,14 @@ // port profiles: channel is 255, num_channels is 0 // enumerating profiles -// clap_plugin_midici_profiles.count()/get() return a list of profile_t structs. Both enabled and available profiles are listed. +// clap_plugin_midici_profiles.count()/get() return a list of clap_profile_t structs. Both enabled and available profiles are listed. // All enabled profiles are listed. Multiple entries will appear if a channel or group profile is enabled on multiple channels or groups. -// If a profile isn't enabled at least one CLAP_MIDICI_PROFILE_DISABLED entry appears in the list, so the host can detect the profile is supported. +// If a profile isn't enabled at least one CLAP_MIDICI_PROFILES_DISABLED entry appears in the list, so the host can detect the profile is supported. // In case of a channel or group profile the host can try to enable it on any channel or group, and the plugin can reject this if it isn't possible. // In detail: -// enabled single channel profiles: one entry per enabled channel. At least one CLAP_MIDICI_PROFILE_DISABLED entry if the profile isn't enabled for any channel. -// enabled multi channel profiles: one entry per enabled block of channels. At least one CLAP_MIDICI_PROFILE_DISABLED entry if the profile isn't enabled for any channel. -// enabled group profiles: one entry per enabled group. At least one CLAP_MIDICI_PROFILE_DISABLED entry if the profile isn't enabled for any group. +// enabled single channel profiles: one entry per enabled channel. At least one CLAP_MIDICI_PROFILES_DISABLED entry if the profile isn't enabled for any channel. +// enabled multi channel profiles: one entry per enabled block of channels. At least one CLAP_MIDICI_PROFILES_DISABLED entry if the profile isn't enabled for any channel. +// enabled group profiles: one entry per enabled group. At least one CLAP_MIDICI_PROFILES_DISABLED entry if the profile isn't enabled for any group. // port profiles: one entry. // Plugins can typically use a simple fixed list. For example: in case of a single-channel profile and 16 channels, clap_plugin_midici_profiles.count() can always return 16. @@ -35,8 +35,8 @@ // 2. enable/disable profiles as needed. // 3. get profile details using clap_plugin_midici_profiles.get_details(). -// Plugins can use CLAP_MIDICI_PROFILE_ALWAYSON for profiles which can't be enabled/disabled by the host. -// Note that a plugin can remove a CLAP_MIDICI_PROFILE_ALWAYSON profile and call clap_host_midici_profiles.changed(). +// Plugins can use CLAP_MIDICI_PROFILES_ALWAYSON for profiles which can't be enabled/disabled by the host. +// Note that a plugin can remove a CLAP_MIDICI_PROFILES_ALWAYSON profile and call clap_host_midici_profiles.changed(). // Some features of this extension can only be used with note ports using the CLAP_NOTE_DIALECT_MIDI2 dialect (groups in particular). @@ -47,49 +47,49 @@ extern "C" { #endif enum { - CLAP_MIDICI_PROFILE_DISABLED = 0, - CLAP_MIDICI_PROFILE_ENABLED = 1, - CLAP_MIDICI_PROFILE_ALWAYSON = 2 + CLAP_MIDICI_PROFILES_DISABLED = 0, + CLAP_MIDICI_PROFILES_ENABLED = 1, + CLAP_MIDICI_PROFILES_ALWAYSON = 2 }; enum { - CLAP_MIDICI_PROFILE_INQUIRY_TARGET_DATA = 255 + CLAP_MIDICI_PROFILES_INQUIRY_TARGET_DATA = 255 }; -typedef struct profile_id { +typedef struct clap_profile_id { uint8_t id; uint8_t bank; uint8_t number; uint8_t version; uint8_t level; -} profile_id_t; +} clap_profile_id_t; -typedef struct profile { - profile_id_t id; - uint8_t channel; // see "destination addressing" paragraph at top of file. - uint16_t num_channels; // see "destination addressing" paragraph at top of file. - uint8_t enabled; // CLAP_MIDICI_PROFILE_* -} profile_t; +typedef struct clap_profile { + clap_profile_id_t profile_id; + uint8_t channel; // see "destination addressing" paragraph at top of file. + uint16_t num_channels; // see "destination addressing" paragraph at top of file. + uint8_t enabled; // CLAP_MIDICI_PROFILES_* +} clap_profile_t; typedef struct clap_plugin_midici_profiles { - // Returns the number of profile_t entries available. + // Returns the number of clap_profile_t entries available. // The "enumerating profiles" paragraph above describes what's supposed to be in the list. // [main-thread] uint32_t(CLAP_ABI *count)(const clap_plugin_t *plugin, uint16_t port_index); - // Get a profile_t by index. + // Get a clap_profile_t by index. // [main-thread] bool(CLAP_ABI *get)(const clap_plugin_t *plugin, uint16_t port_index, uint32_t profile_index, - const struct profile *profile); + clap_profile_t *profile); // Get profile details from profile at channel/num_channels for the specified inquiry_target. // Returns true if data is written to stream correctly. // Returns false if there's no data available for this inquiry_target. // channel and num-channels: see "destination addressing" paragraph at top of file. - // inquiry_target is 0..127. CLAP_MIDICI_PROFILE_INQUIRY_TARGET_DATA can be used to get Profile Specific Data from the plugin. + // inquiry_target is 0..127. CLAP_MIDICI_PROFILES_INQUIRY_TARGET_DATA can be used to get Profile Specific Data from the plugin. // Multiple Profile Specific Data Messages can be written to stream. Each one starts with 0xF0, followed by the actual Profile Specific Data, and ends with 0xF7. // Example: MPE Channel Response Type Notification would be F0 01 F7 // The profile targeted by channel/num_channels should generally be enabled before calling this function. @@ -97,7 +97,7 @@ typedef struct clap_plugin_midici_profiles { // [main-thread] bool(CLAP_ABI *get_details)(const clap_plugin_t *plugin, uint16_t port_index, - const struct profile_id profile, + const clap_profile_id_t profile, uint8_t channel, uint16_t num_channels, uint8_t inquiry_target, @@ -111,7 +111,7 @@ typedef struct clap_plugin_midici_profiles { // [main-thread] bool(CLAP_ABI *set_data)(const clap_plugin_t *plugin, uint16_t port_index, - const profile_id_t profile, + const clap_profile_id_t profile, uint8_t channel, uint16_t num_channels, const uint8_t *buffer, @@ -126,7 +126,7 @@ typedef struct clap_plugin_midici_profiles { // [main-thread] bool(CLAP_ABI *enable)(const clap_plugin_t *plugin, uint16_t port_index, - const profile_id_t profile, + const clap_profile_id_t profile, uint8_t channel, uint16_t num_channels); @@ -137,7 +137,7 @@ typedef struct clap_plugin_midici_profiles { // [main-thread] bool(CLAP_ABI *disable)(const clap_plugin_t *plugin, uint16_t port_index, - const profile_id_t profile, + const clap_profile_id_t profile, uint8_t channel, uint16_t num_channels); } clap_plugin_midici_profiles_t; @@ -148,13 +148,13 @@ typedef struct clap_host_midici_profiles { void(CLAP_ABI *changed)(const clap_host_t *host); // Plugins calls this if host needs to read Profile Specific Data Messages again. - // Host calls get_details(.., port_index, profile, channel, num_channels, CLAP_MIDICI_PROFILE_INQUIRY_TARGET_DATA, ..). + // Host calls get_details(.., port_index, profile, channel, num_channels, CLAP_MIDICI_PROFILES_INQUIRY_TARGET_DATA, ..). // [main-thread] void(CLAP_ABI *datachanged)(const clap_host_t *host, uint16_t port_index, - const profile_id_t profile, + const clap_profile_id_t profile, uint8_t channel, - uint16_t num_channels); + uint16_t num_channels); } clap_host_midici_profiles_t; #ifdef __cplusplus From 6162dcaf008af854a7ff03ddcd3ead260b3f87b4 Mon Sep 17 00:00:00 2001 From: Bremmers Date: Sun, 5 May 2024 14:02:41 +0200 Subject: [PATCH 35/40] more cleanup --- include/clap/ext/draft/midici-profiles.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/include/clap/ext/draft/midici-profiles.h b/include/clap/ext/draft/midici-profiles.h index 018c2d58..c9566417 100644 --- a/include/clap/ext/draft/midici-profiles.h +++ b/include/clap/ext/draft/midici-profiles.h @@ -80,10 +80,10 @@ typedef struct clap_plugin_midici_profiles { // Get a clap_profile_t by index. // [main-thread] - bool(CLAP_ABI *get)(const clap_plugin_t *plugin, - uint16_t port_index, - uint32_t profile_index, - clap_profile_t *profile); + bool(CLAP_ABI *get)(const clap_plugin_t *plugin, + uint16_t port_index, + uint32_t profile_index, + clap_profile_t *profile); // Get profile details from profile at channel/num_channels for the specified inquiry_target. // Returns true if data is written to stream correctly. @@ -97,7 +97,7 @@ typedef struct clap_plugin_midici_profiles { // [main-thread] bool(CLAP_ABI *get_details)(const clap_plugin_t *plugin, uint16_t port_index, - const clap_profile_id_t profile, + const clap_profile_id_t profile_id, uint8_t channel, uint16_t num_channels, uint8_t inquiry_target, @@ -111,7 +111,7 @@ typedef struct clap_plugin_midici_profiles { // [main-thread] bool(CLAP_ABI *set_data)(const clap_plugin_t *plugin, uint16_t port_index, - const clap_profile_id_t profile, + const clap_profile_id_t profile_id, uint8_t channel, uint16_t num_channels, const uint8_t *buffer, @@ -126,7 +126,7 @@ typedef struct clap_plugin_midici_profiles { // [main-thread] bool(CLAP_ABI *enable)(const clap_plugin_t *plugin, uint16_t port_index, - const clap_profile_id_t profile, + const clap_profile_id_t profile_id, uint8_t channel, uint16_t num_channels); @@ -137,7 +137,7 @@ typedef struct clap_plugin_midici_profiles { // [main-thread] bool(CLAP_ABI *disable)(const clap_plugin_t *plugin, uint16_t port_index, - const clap_profile_id_t profile, + const clap_profile_id_t profile_id, uint8_t channel, uint16_t num_channels); } clap_plugin_midici_profiles_t; @@ -152,7 +152,7 @@ typedef struct clap_host_midici_profiles { // [main-thread] void(CLAP_ABI *datachanged)(const clap_host_t *host, uint16_t port_index, - const clap_profile_id_t profile, + const clap_profile_id_t profile_id, uint8_t channel, uint16_t num_channels); } clap_host_midici_profiles_t; From 44aa33267ad0705d440d3dd1516b313cc6bea5cd Mon Sep 17 00:00:00 2001 From: Bremmers Date: Sun, 5 May 2024 16:08:20 +0200 Subject: [PATCH 36/40] feedback from Timo --- include/clap/ext/draft/midici-profiles.h | 62 ++++++++++++------------ 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/include/clap/ext/draft/midici-profiles.h b/include/clap/ext/draft/midici-profiles.h index c9566417..891354fe 100644 --- a/include/clap/ext/draft/midici-profiles.h +++ b/include/clap/ext/draft/midici-profiles.h @@ -76,12 +76,12 @@ typedef struct clap_plugin_midici_profiles { // The "enumerating profiles" paragraph above describes what's supposed to be in the list. // [main-thread] uint32_t(CLAP_ABI *count)(const clap_plugin_t *plugin, - uint16_t port_index); + uint32_t port_index); // Get a clap_profile_t by index. // [main-thread] bool(CLAP_ABI *get)(const clap_plugin_t *plugin, - uint16_t port_index, + uint32_t port_index, uint32_t profile_index, clap_profile_t *profile); @@ -95,13 +95,13 @@ typedef struct clap_plugin_midici_profiles { // The profile targeted by channel/num_channels should generally be enabled before calling this function. // In some cases profile detals like available channels are needed before enabling a profile. Plugins should make sure this is handled correctly. // [main-thread] - bool(CLAP_ABI *get_details)(const clap_plugin_t *plugin, - uint16_t port_index, - const clap_profile_id_t profile_id, - uint8_t channel, - uint16_t num_channels, - uint8_t inquiry_target, - const clap_ostream_t *stream); + bool(CLAP_ABI *get_details)(const clap_plugin_t *plugin, + uint32_t port_index, + const clap_profile_id_t *profile_id, + uint8_t channel, + uint16_t num_channels, + uint8_t inquiry_target, + const clap_ostream_t *stream); // Send Profile Specific Data to profile at channel/num_channels. // Returns true if data was accepted @@ -109,13 +109,13 @@ typedef struct clap_plugin_midici_profiles { // Example: MPE Channel Response Type Notification would be F0 01 F7 // A profile may specify multiple data messages. It's recommended to send the complete 'state' in a single set_data() call. // [main-thread] - bool(CLAP_ABI *set_data)(const clap_plugin_t *plugin, - uint16_t port_index, - const clap_profile_id_t profile_id, - uint8_t channel, - uint16_t num_channels, - const uint8_t *buffer, - uint32_t buffer_size); + bool(CLAP_ABI *set_data)(const clap_plugin_t *plugin, + uint32_t port_index, + const clap_profile_id_t *profile_id, + uint8_t channel, + uint16_t num_channels, + const uint8_t *buffer, + uint32_t buffer_size); // Enables a profile at channel/num_channels. // Returns true if the profile is enabled at channel/num_channels when the function returns. @@ -124,22 +124,22 @@ typedef struct clap_plugin_midici_profiles { // Note for hosts: after calling this function count()/get() may have changed !! // Note for plugins: do not call clap_host_midici_profiles.changed. // [main-thread] - bool(CLAP_ABI *enable)(const clap_plugin_t *plugin, - uint16_t port_index, - const clap_profile_id_t profile_id, - uint8_t channel, - uint16_t num_channels); + bool(CLAP_ABI *enable)(const clap_plugin_t *plugin, + uint32_t port_index, + const clap_profile_id_t *profile_id, + uint8_t channel, + uint16_t num_channels); // Disables a profile at channel/num_channels. // Returns true if the profile isn't enabled at channel/num_channels when the function returns. // Note for hosts: after calling this function count()/get() may have changed !! // Note for plugins: do not call clap_host_midici_profiles.changed. // [main-thread] - bool(CLAP_ABI *disable)(const clap_plugin_t *plugin, - uint16_t port_index, - const clap_profile_id_t profile_id, - uint8_t channel, - uint16_t num_channels); + bool(CLAP_ABI *disable)(const clap_plugin_t *plugin, + uint32_t port_index, + const clap_profile_id_t *profile_id, + uint8_t channel, + uint16_t num_channels); } clap_plugin_midici_profiles_t; typedef struct clap_host_midici_profiles { @@ -150,11 +150,11 @@ typedef struct clap_host_midici_profiles { // Plugins calls this if host needs to read Profile Specific Data Messages again. // Host calls get_details(.., port_index, profile, channel, num_channels, CLAP_MIDICI_PROFILES_INQUIRY_TARGET_DATA, ..). // [main-thread] - void(CLAP_ABI *datachanged)(const clap_host_t *host, - uint16_t port_index, - const clap_profile_id_t profile_id, - uint8_t channel, - uint16_t num_channels); + void(CLAP_ABI *datachanged)(const clap_host_t *host, + uint32_t port_index, + const clap_profile_id_t *profile_id, + uint8_t channel, + uint16_t num_channels); } clap_host_midici_profiles_t; #ifdef __cplusplus From 0ad74a760e6b291dfeb572424646671a0e905923 Mon Sep 17 00:00:00 2001 From: Bremmers Date: Sun, 5 May 2024 19:49:44 +0200 Subject: [PATCH 37/40] enabled() can point at conflicts --- include/clap/ext/draft/midici-profiles.h | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/include/clap/ext/draft/midici-profiles.h b/include/clap/ext/draft/midici-profiles.h index 891354fe..aa2ca85d 100644 --- a/include/clap/ext/draft/midici-profiles.h +++ b/include/clap/ext/draft/midici-profiles.h @@ -56,6 +56,11 @@ enum { CLAP_MIDICI_PROFILES_INQUIRY_TARGET_DATA = 255 }; +enum { + CLAP_MIDICI_PROFILES_ENABLE_SUCCES = -1, + CLAP_MIDICI_PROFILES_ENABLE_FAILED = -2 +}; + typedef struct clap_profile_id { uint8_t id; uint8_t bank; @@ -118,17 +123,20 @@ typedef struct clap_plugin_midici_profiles { uint32_t buffer_size); // Enables a profile at channel/num_channels. - // Returns true if the profile is enabled at channel/num_channels when the function returns. + // Returns CLAP_MIDICI_PROFILES_ENABLE_SUCCES if the profile is enabled at channel/num_channels when the function returns. + // Result >= 0 indicates a conflict with an existing enabled profile. + // The host can call get(.., .., Result, ..), disable this profile and try again. + // Returns CLAP_MIDICI_PROFILES_ENABLE_FAILED if an error other than a conflict occured. // Can be called multiple times to enabled a profile for multiple channels or groups. // channel and num-channels: see "destination addressing" paragraph at top of file. // Note for hosts: after calling this function count()/get() may have changed !! - // Note for plugins: do not call clap_host_midici_profiles.changed. + // Note for plugins: do not call clap_host_midici_profiles.changed. Do not disable profiles. // [main-thread] - bool(CLAP_ABI *enable)(const clap_plugin_t *plugin, - uint32_t port_index, - const clap_profile_id_t *profile_id, - uint8_t channel, - uint16_t num_channels); + int32_t(CLAP_ABI *enable)(const clap_plugin_t *plugin, + uint32_t port_index, + const clap_profile_id_t *profile_id, + uint8_t channel, + uint16_t num_channels); // Disables a profile at channel/num_channels. // Returns true if the profile isn't enabled at channel/num_channels when the function returns. From 6597c68c064ea034e3923bbb9516f2bc0d801750 Mon Sep 17 00:00:00 2001 From: Bremmers Date: Sun, 5 May 2024 20:31:31 +0200 Subject: [PATCH 38/40] changed enumeration rules --- include/clap/ext/draft/midici-profiles.h | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/include/clap/ext/draft/midici-profiles.h b/include/clap/ext/draft/midici-profiles.h index aa2ca85d..f978cc2b 100644 --- a/include/clap/ext/draft/midici-profiles.h +++ b/include/clap/ext/draft/midici-profiles.h @@ -17,17 +17,14 @@ // port profiles: channel is 255, num_channels is 0 // enumerating profiles -// clap_plugin_midici_profiles.count()/get() return a list of clap_profile_t structs. Both enabled and available profiles are listed. -// All enabled profiles are listed. Multiple entries will appear if a channel or group profile is enabled on multiple channels or groups. -// If a profile isn't enabled at least one CLAP_MIDICI_PROFILES_DISABLED entry appears in the list, so the host can detect the profile is supported. -// In case of a channel or group profile the host can try to enable it on any channel or group, and the plugin can reject this if it isn't possible. -// In detail: -// enabled single channel profiles: one entry per enabled channel. At least one CLAP_MIDICI_PROFILES_DISABLED entry if the profile isn't enabled for any channel. -// enabled multi channel profiles: one entry per enabled block of channels. At least one CLAP_MIDICI_PROFILES_DISABLED entry if the profile isn't enabled for any channel. -// enabled group profiles: one entry per enabled group. At least one CLAP_MIDICI_PROFILES_DISABLED entry if the profile isn't enabled for any group. -// port profiles: one entry. - -// Plugins can typically use a simple fixed list. For example: in case of a single-channel profile and 16 channels, clap_plugin_midici_profiles.count() can always return 16. +// clap_plugin_midici_profiles.count()/get() return a list of clap_profile_t structs. Both enabled and disabled profiles are listed. +// All profiles which can potentially be enabled for a destination must be in the list, even if they're mutually exclusive. +// If a conflict occurs clap_plugin_midici_profiles.enable() will return the conflicting profile_index, +// and the host can disable this profile and try again. +// The list doesn't change when profiles are enabled or disabled. The plugin can change the list (if it switches to a different instrument, +// for example). In this case the plugin calls clap_host_midici_profiles.changed(). + +// Plugin implementations can be quite simple. For example: in case of a single-channel profile and 16 channels, clap_plugin_midici_profiles.count() can always return 16. // get() uses the current enabled state for each channel. // A host will typically proceed in this order: From 9798481cfeb5513e4bfa28c8031f5b9fde3d6f7d Mon Sep 17 00:00:00 2001 From: Bremmers Date: Mon, 13 May 2024 14:24:31 +0200 Subject: [PATCH 39/40] added inquiry_target paramater to set_data() --- include/clap/ext/draft/midici-profiles.h | 34 +++++++++++++----------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/include/clap/ext/draft/midici-profiles.h b/include/clap/ext/draft/midici-profiles.h index f978cc2b..046eefa1 100644 --- a/include/clap/ext/draft/midici-profiles.h +++ b/include/clap/ext/draft/midici-profiles.h @@ -87,28 +87,29 @@ typedef struct clap_plugin_midici_profiles { uint32_t profile_index, clap_profile_t *profile); - // Get profile details from profile at channel/num_channels for the specified inquiry_target. + // inquiry_target is 0..127: get profile details from profile at channel/num_channels for the specified inquiry_target. + // inquiry_target is CLAP_MIDICI_PROFILES_INQUIRY_TARGET_DATA: get Profile Specific Data from profile at channel/num_channels. // Returns true if data is written to stream correctly. // Returns false if there's no data available for this inquiry_target. // channel and num-channels: see "destination addressing" paragraph at top of file. - // inquiry_target is 0..127. CLAP_MIDICI_PROFILES_INQUIRY_TARGET_DATA can be used to get Profile Specific Data from the plugin. - // Multiple Profile Specific Data Messages can be written to stream. Each one starts with 0xF0, followed by the actual Profile Specific Data, and ends with 0xF7. - // Example: MPE Channel Response Type Notification would be F0 01 F7 // The profile targeted by channel/num_channels should generally be enabled before calling this function. - // In some cases profile detals like available channels are needed before enabling a profile. Plugins should make sure this is handled correctly. + // In some cases profile details may be needed before enabling a profile. Plugins should make sure this is handled correctly. + // CLAP_MIDICI_PROFILES_INQUIRY_TARGET_DATA: Multiple Profile Specific Data Messages can be written to stream. Each one starts with 0xF0, + // followed by the actual Profile Specific Data, and ends with 0xF7. Example: MPE Channel Response Type Notification would be F0 01 F7. // [main-thread] - bool(CLAP_ABI *get_details)(const clap_plugin_t *plugin, - uint32_t port_index, - const clap_profile_id_t *profile_id, - uint8_t channel, - uint16_t num_channels, - uint8_t inquiry_target, - const clap_ostream_t *stream); + bool(CLAP_ABI *get_data)(const clap_plugin_t *plugin, + uint32_t port_index, + const clap_profile_id_t *profile_id, + uint8_t channel, + uint16_t num_channels, + uint8_t inquiry_target, + const clap_ostream_t *stream); - // Send Profile Specific Data to profile at channel/num_channels. + // inquiry_target is 0..127: Send profile details to profile at channel/num_channels for the specified inquiry_target. + // inquiry_target is CLAP_MIDICI_PROFILES_INQUIRY_TARGET_DATA: Send Profile Specific Data to profile at channel/num_channels. // Returns true if data was accepted - // Multiple Profile Specific Data Messages can be passed in buffer. Each one starts with 0xF0, followed by the actual Profile Specific Data, and ends with 0xF7. - // Example: MPE Channel Response Type Notification would be F0 01 F7 + // CLAP_MIDICI_PROFILES_INQUIRY_TARGET_DATA: Multiple Profile Specific Data Messages can be passed in buffer. Each one starts with 0xF0, + // followed by the actual Profile Specific Data, and ends with 0xF7. Example: MPE Channel Response Type Notification would be F0 01 F7. // A profile may specify multiple data messages. It's recommended to send the complete 'state' in a single set_data() call. // [main-thread] bool(CLAP_ABI *set_data)(const clap_plugin_t *plugin, @@ -116,6 +117,7 @@ typedef struct clap_plugin_midici_profiles { const clap_profile_id_t *profile_id, uint8_t channel, uint16_t num_channels, + uint8_t inquiry_target, const uint8_t *buffer, uint32_t buffer_size); @@ -153,7 +155,7 @@ typedef struct clap_host_midici_profiles { void(CLAP_ABI *changed)(const clap_host_t *host); // Plugins calls this if host needs to read Profile Specific Data Messages again. - // Host calls get_details(.., port_index, profile, channel, num_channels, CLAP_MIDICI_PROFILES_INQUIRY_TARGET_DATA, ..). + // Host calls get_data(.., port_index, profile, channel, num_channels, CLAP_MIDICI_PROFILES_INQUIRY_TARGET_DATA, ..). // [main-thread] void(CLAP_ABI *datachanged)(const clap_host_t *host, uint32_t port_index, From ca2c6d66fd70ca098327cdaceac6b66dc74a698c Mon Sep 17 00:00:00 2001 From: Bremmers Date: Thu, 16 May 2024 12:26:00 +0200 Subject: [PATCH 40/40] clap_host_midici_profiles.datachanged is now called for profile details changes too --- include/clap/ext/draft/midici-profiles.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/clap/ext/draft/midici-profiles.h b/include/clap/ext/draft/midici-profiles.h index 046eefa1..3c5178d2 100644 --- a/include/clap/ext/draft/midici-profiles.h +++ b/include/clap/ext/draft/midici-profiles.h @@ -154,8 +154,8 @@ typedef struct clap_host_midici_profiles { // [main-thread] void(CLAP_ABI *changed)(const clap_host_t *host); - // Plugins calls this if host needs to read Profile Specific Data Messages again. - // Host calls get_data(.., port_index, profile, channel, num_channels, CLAP_MIDICI_PROFILES_INQUIRY_TARGET_DATA, ..). + // Plugins calls this if host needs to read profile details or Profile Specific Data Messages again. + // Host calls get_data(.., port_index, profile, channel, num_channels, .., ..) for the inquiry targets it's interested in. // [main-thread] void(CLAP_ABI *datachanged)(const clap_host_t *host, uint32_t port_index,