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.

328 lines
8.4KB

  1. /*
  2. * Carla Plugin Host
  3. * Copyright (C) 2011-2022 Filipe Coelho <falktx@falktx.com>
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License as
  7. * published by the Free Software Foundation; either version 2 of
  8. * the License, or any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * For a full copy of the GNU General Public License see the doc/GPL.txt file.
  16. */
  17. #ifndef CARLA_UTILS_H_INCLUDED
  18. #define CARLA_UTILS_H_INCLUDED
  19. #include "CarlaBackend.h"
  20. #ifdef __cplusplus
  21. using CARLA_BACKEND_NAMESPACE::PluginCategory;
  22. using CARLA_BACKEND_NAMESPACE::PluginType;
  23. #endif
  24. /*!
  25. * @defgroup CarlaUtilsAPI Carla Utils API
  26. *
  27. * The Carla Utils API.
  28. *
  29. * This API allows to call advanced features from Python.
  30. * @{
  31. */
  32. /*!
  33. * TODO.
  34. */
  35. typedef void* CarlaPipeClientHandle;
  36. /*!
  37. * TODO.
  38. */
  39. typedef void (*CarlaPipeCallbackFunc)(void* ptr, const char* msg);
  40. /*!
  41. * Information about a cached plugin.
  42. * @see carla_get_cached_plugin_info()
  43. */
  44. typedef struct _CarlaCachedPluginInfo {
  45. /*!
  46. * Wherever the data in this struct is valid.
  47. * For performance reasons, plugins are only checked on request,
  48. * and as such, the count vs number of really valid plugins might not match.
  49. * Use this field to skip on plugins which cannot be loaded in Carla.
  50. */
  51. bool valid;
  52. /*!
  53. * Plugin category.
  54. */
  55. PluginCategory category;
  56. /*!
  57. * Plugin hints.
  58. * @see PluginHints
  59. */
  60. uint hints;
  61. /*!
  62. * Number of audio inputs.
  63. */
  64. uint32_t audioIns;
  65. /*!
  66. * Number of audio outputs.
  67. */
  68. uint32_t audioOuts;
  69. /*!
  70. * Number of CV inputs.
  71. */
  72. uint32_t cvIns;
  73. /*!
  74. * Number of CV outputs.
  75. */
  76. uint32_t cvOuts;
  77. /*!
  78. * Number of MIDI inputs.
  79. */
  80. uint32_t midiIns;
  81. /*!
  82. * Number of MIDI outputs.
  83. */
  84. uint32_t midiOuts;
  85. /*!
  86. * Number of input parameters.
  87. */
  88. uint32_t parameterIns;
  89. /*!
  90. * Number of output parameters.
  91. */
  92. uint32_t parameterOuts;
  93. /*!
  94. * Plugin name.
  95. */
  96. const char* name;
  97. /*!
  98. * Plugin label.
  99. */
  100. const char* label;
  101. /*!
  102. * Plugin author/maker.
  103. */
  104. const char* maker;
  105. /*!
  106. * Plugin copyright/license.
  107. */
  108. const char* copyright;
  109. #ifdef __cplusplus
  110. /*!
  111. * C++ constructor.
  112. */
  113. CARLA_API _CarlaCachedPluginInfo() noexcept;
  114. CARLA_DECLARE_NON_COPY_STRUCT(_CarlaCachedPluginInfo)
  115. #endif
  116. } CarlaCachedPluginInfo;
  117. /* --------------------------------------------------------------------------------------------------------------------
  118. * cached plugins */
  119. /*!
  120. * Get how many cached plugins are available.
  121. * Internal and LV2 plugin formats are cached and need to be discovered via this function.
  122. * Do not call this for any other plugin formats.
  123. *
  124. * @note if this carla build uses JUCE, then you must call carla_juce_init beforehand
  125. * @note for AU plugins, you cannot call this outside the main thread
  126. */
  127. CARLA_PLUGIN_EXPORT uint carla_get_cached_plugin_count(PluginType ptype, const char* pluginPath);
  128. /*!
  129. * Get information about a cached plugin.
  130. *
  131. * @note if this carla build uses JUCE, then you must call carla_juce_init beforehand
  132. * @note for AU plugins, you cannot call this outside the main thread
  133. */
  134. CARLA_PLUGIN_EXPORT const CarlaCachedPluginInfo* carla_get_cached_plugin_info(PluginType ptype, uint index);
  135. #ifndef CARLA_HOST_H_INCLUDED
  136. /* --------------------------------------------------------------------------------------------------------------------
  137. * information */
  138. /*!
  139. * Get the complete license text of used third-party code and features.
  140. * Returned string is in basic html format.
  141. */
  142. CARLA_PLUGIN_EXPORT const char* carla_get_complete_license_text(void);
  143. /*!
  144. * Get the juce version used in the current Carla build.
  145. */
  146. CARLA_PLUGIN_EXPORT const char* carla_get_juce_version(void);
  147. /*!
  148. * Get the list of supported file extensions in carla_load_file().
  149. */
  150. CARLA_PLUGIN_EXPORT const char* const* carla_get_supported_file_extensions(void);
  151. /*!
  152. * Get the list of supported features in the current Carla build.
  153. */
  154. CARLA_PLUGIN_EXPORT const char* const* carla_get_supported_features(void);
  155. /*!
  156. * Get the absolute filename of this carla library.
  157. */
  158. CARLA_PLUGIN_EXPORT const char* carla_get_library_filename(void);
  159. /*!
  160. * Get the folder where this carla library resides.
  161. */
  162. CARLA_PLUGIN_EXPORT const char* carla_get_library_folder(void);
  163. #endif
  164. /* --------------------------------------------------------------------------------------------------------------------
  165. * JUCE */
  166. /*!
  167. * Initialize data structures and GUI support for JUCE.
  168. * This is only needed when carla builds use JUCE and you call cached-plugin related APIs.
  169. *
  170. * Idle must then be called at somewhat regular intervals, though in practice there is no reason for it yet.
  171. *
  172. * Make sure to call carla_juce_cleanup after you are done with APIs that need JUCE.
  173. */
  174. CARLA_PLUGIN_EXPORT void carla_juce_init(void);
  175. /*!
  176. * Give idle time to JUCE stuff.
  177. * Currently only used for Linux.
  178. */
  179. CARLA_PLUGIN_EXPORT void carla_juce_idle(void);
  180. /*!
  181. * Cleanup the JUCE stuff that was initialized by carla_juce_init.
  182. */
  183. CARLA_PLUGIN_EXPORT void carla_juce_cleanup(void);
  184. /* --------------------------------------------------------------------------------------------------------------------
  185. * pipes */
  186. /*!
  187. * TODO.
  188. */
  189. CARLA_PLUGIN_EXPORT CarlaPipeClientHandle carla_pipe_client_new(const char* argv[], CarlaPipeCallbackFunc callbackFunc, void* callbackPtr);
  190. /*!
  191. * TODO.
  192. */
  193. CARLA_PLUGIN_EXPORT void carla_pipe_client_idle(CarlaPipeClientHandle handle);
  194. /*!
  195. * TODO.
  196. */
  197. CARLA_PLUGIN_EXPORT bool carla_pipe_client_is_running(CarlaPipeClientHandle handle);
  198. /*!
  199. * TODO.
  200. */
  201. CARLA_PLUGIN_EXPORT void carla_pipe_client_lock(CarlaPipeClientHandle handle);
  202. /*!
  203. * TODO.
  204. */
  205. CARLA_PLUGIN_EXPORT void carla_pipe_client_unlock(CarlaPipeClientHandle handle);
  206. /*!
  207. * TODO.
  208. */
  209. CARLA_PLUGIN_EXPORT const char* carla_pipe_client_readlineblock(CarlaPipeClientHandle handle, uint timeout);
  210. /*!
  211. * Extras.
  212. * TODO.
  213. */
  214. CARLA_PLUGIN_EXPORT bool carla_pipe_client_readlineblock_bool(CarlaPipeClientHandle handle, uint timeout);
  215. CARLA_PLUGIN_EXPORT int carla_pipe_client_readlineblock_int(CarlaPipeClientHandle handle, uint timeout);
  216. CARLA_PLUGIN_EXPORT double carla_pipe_client_readlineblock_float(CarlaPipeClientHandle handle, uint timeout);
  217. /*!
  218. * TODO.
  219. */
  220. CARLA_PLUGIN_EXPORT bool carla_pipe_client_write_msg(CarlaPipeClientHandle handle, const char* msg);
  221. /*!
  222. * TODO.
  223. */
  224. CARLA_PLUGIN_EXPORT bool carla_pipe_client_write_and_fix_msg(CarlaPipeClientHandle handle, const char* msg);
  225. /*!
  226. * TODO.
  227. */
  228. CARLA_PLUGIN_EXPORT bool carla_pipe_client_flush(CarlaPipeClientHandle handle);
  229. /*!
  230. * TODO.
  231. */
  232. CARLA_PLUGIN_EXPORT bool carla_pipe_client_flush_and_unlock(CarlaPipeClientHandle handle);
  233. /*!
  234. * TODO.
  235. */
  236. CARLA_PLUGIN_EXPORT void carla_pipe_client_destroy(CarlaPipeClientHandle handle);
  237. /* --------------------------------------------------------------------------------------------------------------------
  238. * system stuff */
  239. /*!
  240. * Flush stdout or stderr.
  241. */
  242. CARLA_PLUGIN_EXPORT void carla_fflush(bool err);
  243. /*!
  244. * Print the string @a string to stdout or stderr.
  245. */
  246. CARLA_PLUGIN_EXPORT void carla_fputs(bool err, const char* string);
  247. /*!
  248. * Set the current process name to @a name.
  249. */
  250. CARLA_PLUGIN_EXPORT void carla_set_process_name(const char* name);
  251. /* --------------------------------------------------------------------------------------------------------------------
  252. * window control */
  253. /*!
  254. * Get the global/desktop scale factor.
  255. */
  256. CARLA_PLUGIN_EXPORT double carla_get_desktop_scale_factor(void);
  257. CARLA_PLUGIN_EXPORT int carla_cocoa_get_window(void* nsViewPtr);
  258. CARLA_PLUGIN_EXPORT void carla_cocoa_set_transient_window_for(void* nsViewChild, void* nsViewParent);
  259. CARLA_PLUGIN_EXPORT void carla_x11_reparent_window(uintptr_t winId1, uintptr_t winId2);
  260. CARLA_PLUGIN_EXPORT void carla_x11_move_window(uintptr_t winId, int x, int y);
  261. CARLA_PLUGIN_EXPORT int* carla_x11_get_window_pos(uintptr_t winId);
  262. /* ----------------------------------------------------------------------------------------------------------------- */
  263. /** @} */
  264. #endif /* CARLA_UTILS_H_INCLUDED */