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.

edit_controller.h 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /*
  2. * travesty, pure C VST3-compatible interface
  3. * Copyright (C) 2021 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. struct v3_funknown;
  38. v3_result (V3_API* begin_edit)(void* self, v3_param_id);
  39. v3_result (V3_API* perform_edit)(void* self, v3_param_id, double value_normalised);
  40. v3_result (V3_API* end_edit)(void* self, v3_param_id);
  41. v3_result (V3_API* restart_component)(void* self, int32_t flags);
  42. };
  43. static constexpr const v3_tuid v3_component_handler_iid =
  44. V3_ID(0x93A0BEA3, 0x0BD045DB, 0x8E890B0C, 0xC1E46AC6);
  45. /**
  46. * edit controller
  47. */
  48. enum {
  49. V3_PARAM_CAN_AUTOMATE = 1 << 0,
  50. V3_PARAM_READ_ONLY = 1 << 1,
  51. V3_PARAM_WRAP_AROUND = 1 << 2,
  52. V3_PARAM_IS_LIST = 1 << 3,
  53. V3_PARAM_IS_HIDDEN = 1 << 4,
  54. V3_PARAM_PROGRAM_CHANGE = 1 << 15,
  55. V3_PARAM_IS_BYPASS = 1 << 16
  56. };
  57. struct v3_param_info {
  58. v3_param_id param_id;
  59. v3_str_128 title;
  60. v3_str_128 short_title;
  61. v3_str_128 units;
  62. int32_t step_count;
  63. double default_normalised_value;
  64. int32_t unit_id;
  65. int32_t flags;
  66. };
  67. struct v3_edit_controller {
  68. struct v3_plugin_base;
  69. v3_result (V3_API* set_component_state)(void* self, struct v3_bstream*);
  70. v3_result (V3_API* set_state)(void* self, struct v3_bstream*);
  71. v3_result (V3_API* get_state)(void* self, struct v3_bstream*);
  72. int32_t (V3_API* get_parameter_count)(void* self);
  73. v3_result (V3_API* get_parameter_info)(void* self, int32_t param_idx, struct v3_param_info*);
  74. v3_result (V3_API* get_parameter_string_for_value)(void* self, v3_param_id, double normalised, v3_str_128 output);
  75. v3_result (V3_API* get_parameter_value_for_string)(void* self, v3_param_id, int16_t* input, double* output);
  76. double (V3_API* normalised_parameter_to_plain)(void* self, v3_param_id, double normalised);
  77. double (V3_API* plain_parameter_to_normalised)(void* self, v3_param_id, double plain);
  78. double (V3_API* get_parameter_normalised)(void* self, v3_param_id);
  79. v3_result (V3_API* set_parameter_normalised)(void* self, v3_param_id, double normalised);
  80. v3_result (V3_API* set_component_handler)(void* self, struct v3_component_handler**);
  81. struct v3_plugin_view** (V3_API* create_view)(void* self, const char* name);
  82. };
  83. static constexpr const v3_tuid v3_edit_controller_iid =
  84. V3_ID(0xDCD7BBE3, 0x7742448D, 0xA874AACC, 0x979C759E);
  85. /**
  86. * midi mapping
  87. */
  88. struct v3_midi_mapping {
  89. struct v3_funknown;
  90. v3_result (V3_API* get_midi_controller_assignment)(void* self, int32_t bus, int16_t channel, int16_t cc, v3_param_id* id);
  91. };
  92. static constexpr const v3_tuid v3_midi_mapping_iid =
  93. V3_ID(0xDF0FF9F7, 0x49B74669, 0xB63AB732, 0x7ADBF5E5);
  94. #ifdef __cplusplus
  95. /**
  96. * C++ variants
  97. */
  98. struct v3_edit_controller_cpp : v3_funknown {
  99. v3_plugin_base base;
  100. v3_edit_controller ctrl;
  101. };
  102. struct v3_midi_mapping_cpp : v3_funknown {
  103. v3_midi_mapping map;
  104. };
  105. template<> inline
  106. constexpr v3_edit_controller* v3_cpp_obj(v3_edit_controller** obj)
  107. {
  108. /**
  109. * this ugly piece of code is required due to C++ assuming `reinterpret_cast` by default,
  110. * but we need everything to be `static_cast` for it to be `constexpr` compatible.
  111. */
  112. return static_cast<v3_edit_controller*>(
  113. static_cast<void*>(static_cast<uint8_t*>(static_cast<void*>(*obj)) + sizeof(void*)*5));
  114. }
  115. #endif
  116. #include "align_pop.h"