clap

CLAP Audio Plugin API
Log | Files | Refs | README | LICENSE

commit 111858ded845bdbfd86eaf7e95b0d88115ed722e
parent f6d86a7e7c9cd3da233cb9ffa8e54396000ecabf
Author: Alexandre Bique <bique.alexandre@gmail.com>
Date:   Tue, 23 May 2023 17:20:39 +0200

Rework audio ports configuration and surround / ambisonic

Diffstat:
Minclude/clap/ext/draft/ambisonic.h | 19++++++++++++-------
Minclude/clap/ext/draft/configurable-audio-ports.h | 30+++++++++---------------------
Minclude/clap/ext/draft/surround.h | 18+++++++++---------
3 files changed, 30 insertions(+), 37 deletions(-)

diff --git a/include/clap/ext/draft/ambisonic.h b/include/clap/ext/draft/ambisonic.h @@ -4,7 +4,7 @@ // This extension can be used to specify the channel mapping used by the plugin. -static CLAP_CONSTEXPR const char CLAP_EXT_AMBISONIC[] = "clap.ambisonic.draft/2"; +static CLAP_CONSTEXPR const char CLAP_EXT_AMBISONIC[] = "clap.ambisonic.draft/3"; static CLAP_CONSTEXPR const char CLAP_PORT_AMBISONIC[] = "ambisonic"; @@ -28,21 +28,26 @@ enum { CLAP_AMBISONIC_NORMALIZATION_N2D = 4, }; -typedef struct clap_ambisonic_info { +typedef struct clap_ambisonic_config { uint32_t ordering; uint32_t normalization; -} clap_ambisonic_info_t; +} clap_ambisonic_config_t; typedef struct clap_plugin_ambisonic { + // Returns true if the given configuration is supported. + // [main-thread] + bool(CLAP_ABI *is_config_supported)(const clap_plugin_t *plugin, + const clap_ambisonic_config_t *config); + // Returns true on success // // config_id: the configuration id, see clap_plugin_audio_ports_config. // If config_id is CLAP_INVALID_ID, then this function queries the current port info. // [main-thread] - bool(CLAP_ABI *get_info)(const clap_plugin_t *plugin, - bool is_input, - uint32_t port_index, - clap_ambisonic_info_t *info); + bool(CLAP_ABI *get_config)(const clap_plugin_t *plugin, + bool is_input, + uint32_t port_index, + clap_ambisonic_config_t *config); } clap_plugin_ambisonic_t; diff --git a/include/clap/ext/draft/configurable-audio-ports.h b/include/clap/ext/draft/configurable-audio-ports.h @@ -9,13 +9,9 @@ extern "C" { // This extension lets the host configure the plugin's input and output audio ports. // This is a "push" approach to audio ports configuration. static CLAP_CONSTEXPR const char CLAP_EXT_CONFIGURABLE_AUDIO_PORTS[] = - "clap.configurable-audio-ports.draft0"; + "clap.configurable-audio-ports.draft1"; typedef struct clap_audio_port_configuration_request { - // When true, allows the plugin to pick a similar port configuration instead - // if the requested one can't be applied. - bool is_best_effort; - // Identifies the port by is_input and port_index bool is_input; uint32_t port_index; @@ -30,27 +26,19 @@ typedef struct clap_audio_port_configuration_request { // - CLAP_PORT_MONO: (discard) // - CLAP_PORT_STEREO: (discard) // - CLAP_PORT_SURROUND: const uint8_t *channel_map - // - CLAP_PORT_AMBISONIC: const clap_ambisonic_info_t *info + // - CLAP_PORT_AMBISONIC: const clap_ambisonic_config_t *info const void *port_details; } clap_audio_port_configuration_request_t; typedef struct clap_plugin_configurable_audio_ports { - // Some ports may not be configurable, or simply the result of another port configuration. - // For example if you have a simple delay plugin, then the output port must have the exact - // same type as the input port; in that example, we consider the output port type to be a - // function (identity) of the input port type. - // [main-thread && !active] - bool(CLAP_ABI *is_port_configurable)(const clap_plugin_t *plugin, - bool is_input, - uint32_t port_index); - - // Submit a bunch of configuration requests which will atomically be applied together, - // or discarded together. + // If is_dry_run is true, then checks if the configuration can be applied. + // If is_dry_run is true, then applies the configuration. + // Returns true if applied. // [main-thread && !active] - bool(CLAP_ABI *request_configuration)( - const clap_plugin_t *plugin, - const struct clap_audio_port_configuration_request *requests, - uint32_t request_count); + bool(CLAP_ABI *apply_configuration)(const clap_plugin_t *plugin, + const struct clap_audio_port_configuration_request *requests, + uint32_t request_count, + bool is_dry_run); } clap_plugin_configurable_audio_ports_t; #ifdef __cplusplus diff --git a/include/clap/ext/draft/surround.h b/include/clap/ext/draft/surround.h @@ -24,7 +24,7 @@ // 3. host calls clap_plugin_surround->get_channel_map() // 4. host activates the plugin and can start processing audio -static CLAP_CONSTEXPR const char CLAP_EXT_SURROUND[] = "clap.surround.draft/3"; +static CLAP_CONSTEXPR const char CLAP_EXT_SURROUND[] = "clap.surround.draft/4"; static CLAP_CONSTEXPR const char CLAP_PORT_SURROUND[] = "surround"; @@ -54,21 +54,21 @@ enum { }; typedef struct clap_plugin_surround { - // Stores into the channel_map array, the surround identifier of each channel. + // Checks if a given channel mask is supported. + // The channel mask is a bitmask, for example: + // (1 << CLAP_SURROUND_FL) | (1 << CLAP_SURROUND_FR) | ... + // [main-thread] + bool(CLAP_ABI *is_channel_mask_supported)(const clap_plugin_t *plugin, uint64_t channel_mask); + + // Stores the surround identifier of each channel into the channel_map array. // Returns the number of elements stored in channel_map. - // - // config_id: the configuration id, see clap_plugin_audio_ports_config. - // If config_id is CLAP_INVALID_ID, then this function queries the current port info. + // channel_map_capacity should be greater or equal to the channel count of the given port. // [main-thread] uint32_t(CLAP_ABI *get_channel_map)(const clap_plugin_t *plugin, bool is_input, uint32_t port_index, uint8_t *channel_map, uint32_t channel_map_capacity); - - // Informs the plugin that the host preferred channel map has changed. - // [main-thread] - void(CLAP_ABI *changed)(const clap_plugin_t *plugin); } clap_plugin_surround_t; typedef struct clap_host_surround {