clap

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

commit 923c31c211b3c3c11e58a1cf1c467423a29d251a
parent 09b7b8dab5cfe63c37960e4688735c065a255adc
Author: Alexandre Bique <bique.alexandre@gmail.com>
Date:   Mon, 12 Dec 2022 12:42:13 +0100

Merge pull request #220 from abique/audio-port-activation

Audio port activation
Diffstat:
Ainclude/clap/ext/draft/audio-ports-activation.h | 46++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 46 insertions(+), 0 deletions(-)

diff --git a/include/clap/ext/draft/audio-ports-activation.h b/include/clap/ext/draft/audio-ports-activation.h @@ -0,0 +1,46 @@ +#pragma once + +#include "../../plugin.h" + +/// @page Audio Ports Activation +/// +/// This extension provides a way for the host to activate and de-activate audio ports. +/// Deactivating a port provides the following benefits: +/// - the plugin knows ahead of time that a given input is not present and can choose +/// an optimized computation path +/// - the plugin knows that an output is not consumed by the host, and doesn't need to +/// compute it +/// +/// Audio ports can only be activated or deactivated when the plugin is deactivated, unless +/// can_activate_while_processing() returns true. +/// +/// Audio buffers must still be provided if the audio port is deactivated. +/// In such case, they shall be filled with 0 (or whatever is the neutral value in your context) +/// and the constant_mask shall be set. +/// +/// Audio ports are initially in the active state. +/// Audio ports state should not be saved in the plugin state, so the host must restore the +/// audio ports state after creating the plugin instance. +/// +/// Audio ports state is invalidated by clap_plugin_audio_ports_config.select() and +/// clap_host_audio_ports.rescan(CLAP_AUDIO_PORTS_RESCAN_LIST). + +static CLAP_CONSTEXPR const char CLAP_EXT_AUDIO_PORTS_ACTIVATION[] = "clap.audio-ports-activation/draft-0"; + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct clap_plugin_audio_ports_activation { + // returns true if the plugin supports activation/deactivation while processing. + // [main-thread] + bool(CLAP_ABI *can_activate_while_processing)(const clap_plugin_t *plugin); + + // activate the given port + // [main-thread] + uint32_t(CLAP_ABI *set_active)(const clap_plugin_t *plugin, bool is_input, uint32_t port_index, bool is_active); +} clap_plugin_audio_ports_activation_t; + +#ifdef __cplusplus +} +#endif