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.

daz-ui.h 6.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. /*
  2. * DAZ - Digital Audio with Zero dependencies
  3. * Copyright (C) 2013 Filipe Coelho <falktx@falktx.com>
  4. * Copyright (C) 2013 Harry van Haaren <harryhaaren@gmail.com>
  5. * Copyright (C) 2013 Jonathan Moore Liles <male@tuxfamily.org>
  6. *
  7. * Permission to use, copy, modify, and/or distribute this software for any purpose with
  8. * or without fee is hereby granted, provided that the above copyright notice and this
  9. * permission notice appear in all copies.
  10. *
  11. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
  12. * TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
  13. * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  14. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
  15. * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  16. * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  17. */
  18. #ifndef DAZ_UI_H_INCLUDED
  19. #define DAZ_UI_H_INCLUDED
  20. #include "daz-common.h"
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. /*!
  25. * @defgroup DAZPluginAPI
  26. * @{
  27. */
  28. /*!
  29. * @defgroup UiFeatures UI Features
  30. *
  31. * A list of UI features or hints.
  32. *
  33. * Custom features are allowed, as long as they are lowercase and contain ASCII characters only.
  34. * The host can decide if it can load the UI or not based on this information.
  35. *
  36. * Multiple features can be set by using ":" in between them.
  37. * @{
  38. */
  39. /*!
  40. * Supports sample rate changes on-the-fly.
  41. *
  42. * If unset, the host will re-initiate the UI when the sample rate changes.
  43. */
  44. #define UI_FEATURE_SAMPLE_RATE_CHANGES ":sample_rate_changes"
  45. /*!
  46. * Uses open_file() and/or save_file() functions.
  47. */
  48. #define UI_FEATURE_OPEN_SAVE ":open_save"
  49. /*!
  50. * Uses send_plugin_msg() function.
  51. */
  52. #define UI_FEATURE_SEND_MSG ":send_msg"
  53. /** @} */
  54. /*!
  55. * @defgroup HostDispatcherOpcodes Host Dispatcher Opcodes
  56. *
  57. * Opcodes dispatched by the UI to report and request information from the host.
  58. *
  59. * The opcodes are mapped into MappedValue by the host.
  60. * @see HostDescriptor::dispatcher()
  61. * @{
  62. */
  63. /*!
  64. * Tell the host the UI can't be shown, uses nothing.
  65. */
  66. #define HOST_OPCODE_UI_UNAVAILABLE "ui_unavailable"
  67. /** @} */
  68. /*!
  69. * @defgroup UiDispatcherOpcodes UI Dispatcher Opcodes
  70. *
  71. * Opcodes dispatched by the host to report changes to the UI.
  72. *
  73. * The opcodes are mapped into MappedValue by the host.
  74. * @see UiDescriptor::dispatcher()
  75. * @{
  76. */
  77. /*!
  78. * Message received, uses value as size, ptr for contents.
  79. */
  80. #define UI_OPCODE_MSG_RECEIVED "msg_received"
  81. /*!
  82. * Audio sample rate changed, uses opt, returns 1 if supported.
  83. *
  84. * @see UiHostDescriptor::sample_rate
  85. */
  86. #define UI_OPCODE_SAMPLE_RATE_CHANGED "sample_rate_changed"
  87. /*!
  88. * Offline mode changed, uses value (0=off, 1=on).
  89. *
  90. * @see UiHostDescriptor::is_offline
  91. */
  92. #define UI_OPCODE_OFFLINE_CHANGED "offline_changed"
  93. /*!
  94. * UI title changed, uses ptr.
  95. *
  96. * @see UiHostDescriptor::ui_title
  97. */
  98. #define UI_OPCODE_TITLE_CHANGED "ui_title_thanged"
  99. /** @} */
  100. /*!
  101. * Opaque UI handle.
  102. */
  103. typedef void* UiHandle;
  104. /*!
  105. * Opaque UI host handle.
  106. */
  107. typedef void* UiHostHandle;
  108. /*!
  109. * UiHostDescriptor
  110. */
  111. typedef struct {
  112. /*!
  113. * Opaque UI host handle.
  114. */
  115. UiHostHandle handle;
  116. /*!
  117. * Full filepath to the UI *.daz bundle.
  118. */
  119. const char* bundle_dir;
  120. /*!
  121. * Host desired UI title.
  122. */
  123. const char* ui_title;
  124. /*!
  125. * Current audio sample rate.
  126. */
  127. double sample_rate;
  128. /*!
  129. * Wherever the host is currently processing offline.
  130. */
  131. bool is_offline;
  132. /* probably better if only allowed during instantiate() */
  133. mapped_value_t (*map_value)(UiHostHandle handle, const char* valueStr);
  134. const char* (*unmap_value)(UiHostHandle handle, mapped_value_t value);
  135. /*!
  136. * Inform the host about a parameter change.
  137. */
  138. void (*parameter_changed)(UiHostHandle handle, uint32_t index, float value);
  139. /*!
  140. * Inform the host about a/the MIDI program change.
  141. *
  142. * @note: Only synths make use the of @a channel argument.
  143. */
  144. void (*midi_program_changed)(UiHostHandle handle, uint8_t channel, uint32_t bank, uint32_t program);
  145. /*!
  146. * Inform the host the UI has been closed.
  147. *
  148. * After calling this the UI should not do any operation and simply wait
  149. * until the host calls UiDescriptor::cleanup().
  150. */
  151. void (*closed)(UiHostHandle handle);
  152. /* TODO: add some msgbox call */
  153. /* ui must set "opensave" feature to use these */
  154. const char* (*open_file)(UiHostHandle handle, bool isDir, const char* title, const char* filter);
  155. const char* (*save_file)(UiHostHandle handle, bool isDir, const char* title, const char* filter);
  156. /* ui must set "sendmsg" feature to use this */
  157. bool (*send_plugin_msg)(UiHostHandle handle, const void* data, size_t size);
  158. /* uses HostDispatcherOpcodes */
  159. intptr_t (*dispatcher)(UiHostHandle handle, mapped_value_t opcode, int32_t index, intptr_t value, void* ptr, float opt);
  160. } UiHostDescriptor;
  161. /*!
  162. * UiDescriptor
  163. */
  164. typedef struct {
  165. const int api; /*!< Must be set to DAZ_API_VERSION. */
  166. const char* const features; /*!< Features. @see UiFeatures */
  167. const char* const author; /*!< Author this UI applies to. */
  168. const char* const label; /*!< Label this UI applies to, can only contain letters, numbers and "_". May be null, in which case represents all UIs for @a maker. */
  169. UiHandle (*instantiate)(const UiHostDescriptor* host);
  170. void (*cleanup)(UiHandle handle);
  171. void (*show)(UiHandle handle, bool show);
  172. void (*idle)(UiHandle handle);
  173. void (*set_parameter)(UiHandle handle, uint32_t index, float value);
  174. void (*set_midi_program)(UiHandle handle, uint8_t channel, uint32_t bank, uint32_t program);
  175. void (*set_state)(UiHandle handle, const char* state);
  176. /* uses UiDispatcherOpcodes */
  177. intptr_t (*dispatcher)(UiHandle handle, mapped_value_t opcode, int32_t index, intptr_t value, void* ptr, float opt);
  178. } UiDescriptor;
  179. /*!
  180. * UI entry point function used by the UI.
  181. */
  182. DAZ_SYMBOL_EXPORT
  183. const UiDescriptor* daz_get_ui_descriptor(uint32_t index);
  184. /*!
  185. * UI entry point function used by the host.
  186. */
  187. typedef const UiDescriptor* (*daz_get_ui_descriptor_fn)(uint32_t index);
  188. /** @} */
  189. #ifdef __cplusplus
  190. } /* extern "C" */
  191. #endif
  192. #endif /* DAZ_UI_H_INCLUDED */