audio-ports.h (4108B)
1 #pragma once 2 3 #include "../plugin.h" 4 #include "../string-sizes.h" 5 6 /// @page Audio Ports 7 /// 8 /// This extension provides a way for the plugin to describe its current audio ports. 9 /// 10 /// If the plugin does not implement this extension, it won't have audio ports. 11 /// 12 /// 32 bits support is required for both host and plugins. 64 bits audio is optional. 13 /// 14 /// The plugin is only allowed to change its ports configuration while it is deactivated. 15 16 static CLAP_CONSTEXPR const char CLAP_EXT_AUDIO_PORTS[] = "clap.audio-ports"; 17 static CLAP_CONSTEXPR const char CLAP_PORT_MONO[] = "mono"; 18 static CLAP_CONSTEXPR const char CLAP_PORT_STEREO[] = "stereo"; 19 20 #ifdef __cplusplus 21 extern "C" { 22 #endif 23 24 enum { 25 // This port is the main audio input or output. 26 // There can be only one main input and main output. 27 // Main port must be at index 0. 28 CLAP_AUDIO_PORT_IS_MAIN = 1 << 0, 29 30 // This port can be used with 64 bits audio 31 CLAP_AUDIO_PORT_SUPPORTS_64BITS = 1 << 1, 32 33 // 64 bits audio is preferred with this port 34 CLAP_AUDIO_PORT_PREFERS_64BITS = 1 << 2, 35 36 // This port must be used with the same sample size as all the other ports which have this flag. 37 // In other words if all ports have this flag then the plugin may either be used entirely with 38 // 64 bits audio or 32 bits audio, but it can't be mixed. 39 CLAP_AUDIO_PORT_REQUIRES_COMMON_SAMPLE_SIZE = 1 << 3, 40 }; 41 42 typedef struct clap_audio_port_info { 43 // id identifies a port and must be stable. 44 // id may overlap between input and output ports. 45 clap_id id; 46 char name[CLAP_NAME_SIZE]; // displayable name 47 48 uint32_t flags; 49 uint32_t channel_count; 50 51 // If null or empty then it is unspecified (arbitrary audio). 52 // This field can be compared against: 53 // - CLAP_PORT_MONO 54 // - CLAP_PORT_STEREO 55 // - CLAP_PORT_SURROUND (defined in the surround extension) 56 // - CLAP_PORT_AMBISONIC (defined in the ambisonic extension) 57 // 58 // An extension can provide its own port type and way to inspect the channels. 59 const char *port_type; 60 61 // in-place processing: allow the host to use the same buffer for input and output 62 // if supported set the pair port id. 63 // if not supported set to CLAP_INVALID_ID 64 clap_id in_place_pair; 65 } clap_audio_port_info_t; 66 67 // The audio ports scan has to be done while the plugin is deactivated. 68 typedef struct clap_plugin_audio_ports { 69 // Number of ports, for either input or output 70 // [main-thread] 71 uint32_t(CLAP_ABI *count)(const clap_plugin_t *plugin, bool is_input); 72 73 // Get info about an audio port. 74 // Returns true on success and stores the result into info. 75 // [main-thread] 76 bool(CLAP_ABI *get)(const clap_plugin_t *plugin, 77 uint32_t index, 78 bool is_input, 79 clap_audio_port_info_t *info); 80 } clap_plugin_audio_ports_t; 81 82 enum { 83 // The ports name did change, the host can scan them right away. 84 CLAP_AUDIO_PORTS_RESCAN_NAMES = 1 << 0, 85 86 // [!active] The flags did change 87 CLAP_AUDIO_PORTS_RESCAN_FLAGS = 1 << 1, 88 89 // [!active] The channel_count did change 90 CLAP_AUDIO_PORTS_RESCAN_CHANNEL_COUNT = 1 << 2, 91 92 // [!active] The port type did change 93 CLAP_AUDIO_PORTS_RESCAN_PORT_TYPE = 1 << 3, 94 95 // [!active] The in-place pair did change, this requires. 96 CLAP_AUDIO_PORTS_RESCAN_IN_PLACE_PAIR = 1 << 4, 97 98 // [!active] The list of ports have changed: entries have been removed/added. 99 CLAP_AUDIO_PORTS_RESCAN_LIST = 1 << 5, 100 }; 101 102 typedef struct clap_host_audio_ports { 103 // Checks if the host allows a plugin to change a given aspect of the audio ports definition. 104 // [main-thread] 105 bool(CLAP_ABI *is_rescan_flag_supported)(const clap_host_t *host, uint32_t flag); 106 107 // Rescan the full list of audio ports according to the flags. 108 // It is illegal to ask the host to rescan with a flag that is not supported. 109 // Certain flags require the plugin to be de-activated. 110 // [main-thread] 111 void(CLAP_ABI *rescan)(const clap_host_t *host, uint32_t flags); 112 } clap_host_audio_ports_t; 113 114 #ifdef __cplusplus 115 } 116 #endif