Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

117 lines
4.0KB

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