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.

136 lines
3.3KB

  1. /*
  2. * travesty, pure C VST3-compatible interface
  3. * Copyright (C) 2021-2022 Filipe Coelho <falktx@falktx.com>
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for any purpose with
  6. * or without fee is hereby granted, provided that the above copyright notice and this
  7. * permission notice appear in all copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
  10. * TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
  11. * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  12. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
  13. * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  14. * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #pragma once
  17. #include "base.h"
  18. #include "bstream.h"
  19. #include "align_push.h"
  20. /**
  21. * buses
  22. */
  23. enum v3_media_types {
  24. V3_AUDIO = 0,
  25. V3_EVENT
  26. };
  27. static inline
  28. const char* v3_media_type_str(int32_t type)
  29. {
  30. switch (type)
  31. {
  32. case V3_AUDIO:
  33. return "V3_AUDIO";
  34. case V3_EVENT:
  35. return "V3_EVENT";
  36. default:
  37. return "[unknown]";
  38. }
  39. }
  40. enum v3_bus_direction {
  41. V3_INPUT = 0,
  42. V3_OUTPUT
  43. };
  44. static inline
  45. const char* v3_bus_direction_str(int32_t d)
  46. {
  47. switch (d)
  48. {
  49. case V3_INPUT:
  50. return "V3_INPUT";
  51. case V3_OUTPUT:
  52. return "V3_OUTPUT";
  53. default:
  54. return "[unknown]";
  55. }
  56. }
  57. enum v3_bus_types {
  58. V3_MAIN = 0,
  59. V3_AUX
  60. };
  61. enum v3_bus_flags {
  62. V3_DEFAULT_ACTIVE = 1 << 0,
  63. V3_IS_CONTROL_VOLTAGE = 1 << 1
  64. };
  65. struct v3_bus_info {
  66. int32_t media_type;
  67. int32_t direction;
  68. int32_t channel_count;
  69. v3_str_128 bus_name;
  70. int32_t bus_type;
  71. uint32_t flags;
  72. };
  73. /**
  74. * component
  75. */
  76. struct v3_routing_info;
  77. struct v3_component {
  78. #ifndef __cplusplus
  79. struct v3_plugin_base;
  80. #endif
  81. v3_result (V3_API *get_controller_class_id)(void* self, v3_tuid class_id);
  82. v3_result (V3_API *set_io_mode)(void* self, int32_t io_mode);
  83. int32_t (V3_API *get_bus_count)(void* self, int32_t media_type, int32_t bus_direction);
  84. v3_result (V3_API *get_bus_info)(void* self, int32_t media_type, int32_t bus_direction,
  85. int32_t bus_idx, struct v3_bus_info* bus_info);
  86. v3_result (V3_API *get_routing_info)(void* self, struct v3_routing_info* input, struct v3_routing_info* output);
  87. v3_result (V3_API *activate_bus)(void* self, int32_t media_type, int32_t bus_direction,
  88. int32_t bus_idx, v3_bool state);
  89. v3_result (V3_API *set_active)(void* self, v3_bool state);
  90. v3_result (V3_API *set_state)(void* self, struct v3_bstream **);
  91. v3_result (V3_API *get_state)(void* self, struct v3_bstream **);
  92. };
  93. static constexpr const v3_tuid v3_component_iid =
  94. V3_ID(0xE831FF31, 0xF2D54301, 0x928EBBEE, 0x25697802);
  95. #ifdef __cplusplus
  96. /**
  97. * C++ variants
  98. */
  99. struct v3_component_cpp : v3_funknown {
  100. v3_plugin_base base;
  101. v3_component comp;
  102. };
  103. template<> inline
  104. constexpr v3_component* v3_cpp_obj(v3_component** obj)
  105. {
  106. /**
  107. * this ugly piece of code is required due to C++ assuming `reinterpret_cast` by default,
  108. * but we need everything to be `static_cast` for it to be `constexpr` compatible.
  109. */
  110. return static_cast<v3_component*>(
  111. static_cast<void*>(static_cast<uint8_t*>(static_cast<void*>(*obj)) + sizeof(void*)*5));
  112. }
  113. #endif
  114. #include "align_pop.h"