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.

166 lines
5.2KB

  1. /*
  2. * travesty, pure C VST3-compatible interface
  3. * Copyright (C) 2021-2023 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 "view.h"
  20. #include "align_push.h"
  21. /**
  22. * component handler
  23. */
  24. enum {
  25. V3_RESTART_RELOAD_COMPONENT = 1 << 0,
  26. V3_RESTART_IO_CHANGED = 1 << 1,
  27. V3_RESTART_PARAM_VALUES_CHANGED = 1 << 2,
  28. V3_RESTART_LATENCY_CHANGED = 1 << 3,
  29. V3_RESTART_PARAM_TITLES_CHANGED = 1 << 4,
  30. V3_RESTART_MIDI_CC_ASSIGNMENT_CHANGED = 1 << 5,
  31. V3_RESTART_NOTE_EXPRESSION_CHANGED = 1 << 6,
  32. V3_RESTART_IO_TITLES_CHANGED = 1 << 7,
  33. V3_RESTART_PREFETCHABLE_SUPPORT_CHANGED = 1 << 8,
  34. V3_RESTART_ROUTING_INFO_CHANGED = 1 << 9
  35. };
  36. struct v3_component_handler {
  37. #ifndef __cplusplus
  38. struct v3_funknown;
  39. #endif
  40. v3_result (V3_API* begin_edit)(void* self, v3_param_id);
  41. v3_result (V3_API* perform_edit)(void* self, v3_param_id, double value_normalised);
  42. v3_result (V3_API* end_edit)(void* self, v3_param_id);
  43. v3_result (V3_API* restart_component)(void* self, int32_t flags);
  44. };
  45. static constexpr const v3_tuid v3_component_handler_iid =
  46. V3_ID(0x93A0BEA3, 0x0BD045DB, 0x8E890B0C, 0xC1E46AC6);
  47. struct v3_component_handler2 {
  48. #ifndef __cplusplus
  49. struct v3_funknown;
  50. #endif
  51. v3_result (V3_API* set_dirty)(void* self, v3_bool state);
  52. v3_result (V3_API* request_open_editor)(void* self, const char* name);
  53. v3_result (V3_API* start_group_edit)(void* self);
  54. v3_result (V3_API* finish_group_edit)(void* self);
  55. };
  56. static constexpr const v3_tuid v3_component_handler2_iid =
  57. V3_ID(0xF040B4B3, 0xA36045EC, 0xABCDC045, 0xB4D5A2CC);
  58. /**
  59. * edit controller
  60. */
  61. enum {
  62. V3_PARAM_CAN_AUTOMATE = 1 << 0,
  63. V3_PARAM_READ_ONLY = 1 << 1,
  64. V3_PARAM_WRAP_AROUND = 1 << 2,
  65. V3_PARAM_IS_LIST = 1 << 3,
  66. V3_PARAM_IS_HIDDEN = 1 << 4,
  67. V3_PARAM_PROGRAM_CHANGE = 1 << 15,
  68. V3_PARAM_IS_BYPASS = 1 << 16
  69. };
  70. struct v3_param_info {
  71. v3_param_id param_id;
  72. v3_str_128 title;
  73. v3_str_128 short_title;
  74. v3_str_128 units;
  75. int32_t step_count;
  76. double default_normalised_value;
  77. int32_t unit_id;
  78. int32_t flags;
  79. };
  80. struct v3_edit_controller {
  81. #ifndef __cplusplus
  82. struct v3_plugin_base;
  83. #endif
  84. v3_result (V3_API* set_component_state)(void* self, struct v3_bstream**);
  85. v3_result (V3_API* set_state)(void* self, struct v3_bstream**);
  86. v3_result (V3_API* get_state)(void* self, struct v3_bstream**);
  87. int32_t (V3_API* get_parameter_count)(void* self);
  88. v3_result (V3_API* get_parameter_info)(void* self, int32_t param_idx, struct v3_param_info*);
  89. v3_result (V3_API* get_parameter_string_for_value)(void* self, v3_param_id, double normalised, v3_str_128 output);
  90. v3_result (V3_API* get_parameter_value_for_string)(void* self, v3_param_id, int16_t* input, double* output);
  91. double (V3_API* normalised_parameter_to_plain)(void* self, v3_param_id, double normalised);
  92. double (V3_API* plain_parameter_to_normalised)(void* self, v3_param_id, double plain);
  93. double (V3_API* get_parameter_normalised)(void* self, v3_param_id);
  94. v3_result (V3_API* set_parameter_normalised)(void* self, v3_param_id, double normalised);
  95. v3_result (V3_API* set_component_handler)(void* self, struct v3_component_handler**);
  96. struct v3_plugin_view** (V3_API* create_view)(void* self, const char* name);
  97. };
  98. static constexpr const v3_tuid v3_edit_controller_iid =
  99. V3_ID(0xDCD7BBE3, 0x7742448D, 0xA874AACC, 0x979C759E);
  100. /**
  101. * midi mapping
  102. */
  103. struct v3_midi_mapping {
  104. #ifndef __cplusplus
  105. struct v3_funknown;
  106. #endif
  107. v3_result (V3_API* get_midi_controller_assignment)(void* self, int32_t bus, int16_t channel, int16_t cc, v3_param_id* id);
  108. };
  109. static constexpr const v3_tuid v3_midi_mapping_iid =
  110. V3_ID(0xDF0FF9F7, 0x49B74669, 0xB63AB732, 0x7ADBF5E5);
  111. #ifdef __cplusplus
  112. /**
  113. * C++ variants
  114. */
  115. struct v3_component_handler_cpp : v3_funknown {
  116. v3_component_handler comp;
  117. };
  118. struct v3_component_handler2_cpp : v3_funknown {
  119. v3_component_handler2 comp2;
  120. };
  121. struct v3_edit_controller_cpp : v3_funknown {
  122. v3_plugin_base base;
  123. v3_edit_controller ctrl;
  124. };
  125. struct v3_midi_mapping_cpp : v3_funknown {
  126. v3_midi_mapping map;
  127. };
  128. template<> inline
  129. constexpr v3_edit_controller* v3_cpp_obj(v3_edit_controller** obj)
  130. {
  131. /**
  132. * this ugly piece of code is required due to C++ assuming `reinterpret_cast` by default,
  133. * but we need everything to be `static_cast` for it to be `constexpr` compatible.
  134. */
  135. return static_cast<v3_edit_controller*>(
  136. static_cast<void*>(static_cast<uint8_t*>(static_cast<void*>(*obj)) + sizeof(void*)*5));
  137. }
  138. #endif
  139. #include "align_pop.h"