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.

CarlaUtils.h 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492
  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::BinaryType;
  22. using CARLA_BACKEND_NAMESPACE::PluginCategory;
  23. using CARLA_BACKEND_NAMESPACE::PluginType;
  24. #endif
  25. /*!
  26. * @defgroup CarlaUtilsAPI Carla Utils API
  27. *
  28. * The Carla Utils API.
  29. *
  30. * This API allows to call advanced features from Python.
  31. * @{
  32. */
  33. /*!
  34. * Information about a cached plugin.
  35. * @see carla_get_cached_plugin_info()
  36. */
  37. typedef struct _CarlaCachedPluginInfo {
  38. /*!
  39. * Wherever the data in this struct is valid.
  40. * For performance reasons, plugins are only checked on request,
  41. * and as such, the count vs number of really valid plugins might not match.
  42. * Use this field to skip on plugins which cannot be loaded in Carla.
  43. */
  44. bool valid;
  45. /*!
  46. * Plugin category.
  47. */
  48. PluginCategory category;
  49. /*!
  50. * Plugin hints.
  51. * @see PluginHints
  52. */
  53. uint hints;
  54. /*!
  55. * Number of audio inputs.
  56. */
  57. uint32_t audioIns;
  58. /*!
  59. * Number of audio outputs.
  60. */
  61. uint32_t audioOuts;
  62. /*!
  63. * Number of CV inputs.
  64. */
  65. uint32_t cvIns;
  66. /*!
  67. * Number of CV outputs.
  68. */
  69. uint32_t cvOuts;
  70. /*!
  71. * Number of MIDI inputs.
  72. */
  73. uint32_t midiIns;
  74. /*!
  75. * Number of MIDI outputs.
  76. */
  77. uint32_t midiOuts;
  78. /*!
  79. * Number of input parameters.
  80. */
  81. uint32_t parameterIns;
  82. /*!
  83. * Number of output parameters.
  84. */
  85. uint32_t parameterOuts;
  86. /*!
  87. * Plugin name.
  88. */
  89. const char* name;
  90. /*!
  91. * Plugin label.
  92. */
  93. const char* label;
  94. /*!
  95. * Plugin author/maker.
  96. */
  97. const char* maker;
  98. /*!
  99. * Plugin copyright/license.
  100. */
  101. const char* copyright;
  102. #ifdef __cplusplus
  103. /*!
  104. * C++ constructor.
  105. */
  106. CARLA_API _CarlaCachedPluginInfo() noexcept;
  107. CARLA_DECLARE_NON_COPYABLE(_CarlaCachedPluginInfo)
  108. #endif
  109. } CarlaCachedPluginInfo;
  110. /* --------------------------------------------------------------------------------------------------------------------
  111. * plugin discovery */
  112. typedef void* CarlaPluginDiscoveryHandle;
  113. /*!
  114. * TODO.
  115. */
  116. typedef struct _CarlaPluginDiscoveryMetadata {
  117. /*!
  118. * Plugin name.
  119. */
  120. const char* name;
  121. /*!
  122. * Plugin author/maker.
  123. */
  124. const char* maker;
  125. /*!
  126. * Plugin category.
  127. */
  128. PluginCategory category;
  129. /*!
  130. * Plugin hints.
  131. * @see PluginHints
  132. */
  133. uint hints;
  134. #ifdef __cplusplus
  135. /*!
  136. * C++ constructor.
  137. */
  138. CARLA_API _CarlaPluginDiscoveryMetadata() noexcept;
  139. CARLA_DECLARE_NON_COPYABLE(_CarlaPluginDiscoveryMetadata)
  140. #endif
  141. } CarlaPluginDiscoveryMetadata;
  142. /*!
  143. * TODO.
  144. */
  145. typedef struct _CarlaPluginDiscoveryIO {
  146. /*!
  147. * Number of audio inputs.
  148. */
  149. uint32_t audioIns;
  150. /*!
  151. * Number of audio outputs.
  152. */
  153. uint32_t audioOuts;
  154. /*!
  155. * Number of CV inputs.
  156. */
  157. uint32_t cvIns;
  158. /*!
  159. * Number of CV outputs.
  160. */
  161. uint32_t cvOuts;
  162. /*!
  163. * Number of MIDI inputs.
  164. */
  165. uint32_t midiIns;
  166. /*!
  167. * Number of MIDI outputs.
  168. */
  169. uint32_t midiOuts;
  170. /*!
  171. * Number of input parameters.
  172. */
  173. uint32_t parameterIns;
  174. /*!
  175. * Number of output parameters.
  176. */
  177. uint32_t parameterOuts;
  178. #ifdef __cplusplus
  179. /*!
  180. * C++ constructor.
  181. */
  182. CARLA_API _CarlaPluginDiscoveryIO() noexcept;
  183. CARLA_DECLARE_NON_COPYABLE(_CarlaPluginDiscoveryIO)
  184. #endif
  185. } CarlaPluginDiscoveryIO;
  186. /*!
  187. * TODO.
  188. */
  189. typedef struct _CarlaPluginDiscoveryInfo {
  190. /*!
  191. * Binary type.
  192. */
  193. BinaryType btype;
  194. /*!
  195. * Plugin type.
  196. */
  197. PluginType ptype;
  198. /*!
  199. * Plugin filename.
  200. */
  201. const char* filename;
  202. /*!
  203. * Plugin label/URI/Id.
  204. */
  205. const char* label;
  206. /*!
  207. * Plugin unique Id.
  208. */
  209. uint64_t uniqueId;
  210. /*!
  211. * Extra information, not required for load plugins.
  212. */
  213. CarlaPluginDiscoveryMetadata metadata;
  214. /*!
  215. * Extra information, not required for load plugins.
  216. */
  217. CarlaPluginDiscoveryIO io;
  218. #ifdef __cplusplus
  219. /*!
  220. * C++ constructor.
  221. */
  222. CARLA_API _CarlaPluginDiscoveryInfo() noexcept;
  223. CARLA_DECLARE_NON_COPYABLE(_CarlaPluginDiscoveryInfo)
  224. #endif
  225. } CarlaPluginDiscoveryInfo;
  226. /*!
  227. * TODO.
  228. */
  229. typedef void (*CarlaPluginDiscoveryCallback)(void* ptr, const CarlaPluginDiscoveryInfo* info);
  230. /*!
  231. */
  232. CARLA_PLUGIN_EXPORT CarlaPluginDiscoveryHandle carla_plugin_discovery_start(const char* discoveryTool,
  233. PluginType ptype,
  234. const char* pluginPath,
  235. CarlaPluginDiscoveryCallback callback,
  236. void* callbackPtr);
  237. /*!
  238. */
  239. CARLA_PLUGIN_EXPORT bool carla_plugin_discovery_idle(CarlaPluginDiscoveryHandle handle);
  240. /*!
  241. */
  242. CARLA_PLUGIN_EXPORT void carla_plugin_discovery_stop(CarlaPluginDiscoveryHandle handle);
  243. /* --------------------------------------------------------------------------------------------------------------------
  244. * cached plugins */
  245. /*!
  246. * Get how many cached plugins are available.
  247. * Internal and LV2 plugin formats are cached and need to be discovered via this function.
  248. * Do not call this for any other plugin formats.
  249. *
  250. * @note if this carla build uses JUCE, then you must call carla_juce_init beforehand
  251. * @note for AU plugins, you cannot call this outside the main thread
  252. */
  253. CARLA_PLUGIN_EXPORT uint carla_get_cached_plugin_count(PluginType ptype, const char* pluginPath);
  254. /*!
  255. * Get information about a cached plugin.
  256. *
  257. * @note if this carla build uses JUCE, then you must call carla_juce_init beforehand
  258. * @note for AU plugins, you cannot call this outside the main thread
  259. */
  260. CARLA_PLUGIN_EXPORT const CarlaCachedPluginInfo* carla_get_cached_plugin_info(PluginType ptype, uint index);
  261. #ifndef CARLA_HOST_H_INCLUDED
  262. /* --------------------------------------------------------------------------------------------------------------------
  263. * information */
  264. /*!
  265. * Get the complete license text of used third-party code and features.
  266. * Returned string is in basic html format.
  267. */
  268. CARLA_PLUGIN_EXPORT const char* carla_get_complete_license_text(void);
  269. /*!
  270. * Get the juce version used in the current Carla build.
  271. */
  272. CARLA_PLUGIN_EXPORT const char* carla_get_juce_version(void);
  273. /*!
  274. * Get the list of supported file extensions in carla_load_file().
  275. */
  276. CARLA_PLUGIN_EXPORT const char* const* carla_get_supported_file_extensions(void);
  277. /*!
  278. * Get the list of supported features in the current Carla build.
  279. */
  280. CARLA_PLUGIN_EXPORT const char* const* carla_get_supported_features(void);
  281. /*!
  282. * Get the absolute filename of this carla library.
  283. */
  284. CARLA_PLUGIN_EXPORT const char* carla_get_library_filename(void);
  285. /*!
  286. * Get the folder where this carla library resides.
  287. */
  288. CARLA_PLUGIN_EXPORT const char* carla_get_library_folder(void);
  289. #endif
  290. /* --------------------------------------------------------------------------------------------------------------------
  291. * JUCE */
  292. /*!
  293. * Initialize data structures and GUI support for JUCE.
  294. * This is only needed when carla builds use JUCE and you call cached-plugin related APIs.
  295. *
  296. * Idle must then be called at somewhat regular intervals, though in practice there is no reason for it yet.
  297. *
  298. * Make sure to call carla_juce_cleanup after you are done with APIs that need JUCE.
  299. */
  300. CARLA_PLUGIN_EXPORT void carla_juce_init(void);
  301. /*!
  302. * Give idle time to JUCE stuff.
  303. * Currently only used for Linux.
  304. */
  305. CARLA_PLUGIN_EXPORT void carla_juce_idle(void);
  306. /*!
  307. * Cleanup the JUCE stuff that was initialized by carla_juce_init.
  308. */
  309. CARLA_PLUGIN_EXPORT void carla_juce_cleanup(void);
  310. /* --------------------------------------------------------------------------------------------------------------------
  311. * pipes */
  312. /*!
  313. * TODO.
  314. */
  315. typedef void* CarlaPipeClientHandle;
  316. /*!
  317. * TODO.
  318. */
  319. typedef void (*CarlaPipeCallbackFunc)(void* ptr, const char* msg);
  320. /*!
  321. * TODO.
  322. */
  323. CARLA_PLUGIN_EXPORT CarlaPipeClientHandle carla_pipe_client_new(const char* argv[], CarlaPipeCallbackFunc callbackFunc, void* callbackPtr);
  324. /*!
  325. * TODO.
  326. */
  327. CARLA_PLUGIN_EXPORT void carla_pipe_client_idle(CarlaPipeClientHandle handle);
  328. /*!
  329. * TODO.
  330. */
  331. CARLA_PLUGIN_EXPORT bool carla_pipe_client_is_running(CarlaPipeClientHandle handle);
  332. /*!
  333. * TODO.
  334. */
  335. CARLA_PLUGIN_EXPORT void carla_pipe_client_lock(CarlaPipeClientHandle handle);
  336. /*!
  337. * TODO.
  338. */
  339. CARLA_PLUGIN_EXPORT void carla_pipe_client_unlock(CarlaPipeClientHandle handle);
  340. /*!
  341. * TODO.
  342. */
  343. CARLA_PLUGIN_EXPORT const char* carla_pipe_client_readlineblock(CarlaPipeClientHandle handle, uint timeout);
  344. /*!
  345. * Extras.
  346. * TODO.
  347. */
  348. CARLA_PLUGIN_EXPORT bool carla_pipe_client_readlineblock_bool(CarlaPipeClientHandle handle, uint timeout);
  349. CARLA_PLUGIN_EXPORT int carla_pipe_client_readlineblock_int(CarlaPipeClientHandle handle, uint timeout);
  350. CARLA_PLUGIN_EXPORT double carla_pipe_client_readlineblock_float(CarlaPipeClientHandle handle, uint timeout);
  351. /*!
  352. * TODO.
  353. */
  354. CARLA_PLUGIN_EXPORT bool carla_pipe_client_write_msg(CarlaPipeClientHandle handle, const char* msg);
  355. /*!
  356. * TODO.
  357. */
  358. CARLA_PLUGIN_EXPORT bool carla_pipe_client_write_and_fix_msg(CarlaPipeClientHandle handle, const char* msg);
  359. /*!
  360. * TODO.
  361. */
  362. CARLA_PLUGIN_EXPORT bool carla_pipe_client_flush(CarlaPipeClientHandle handle);
  363. /*!
  364. * TODO.
  365. */
  366. CARLA_PLUGIN_EXPORT bool carla_pipe_client_flush_and_unlock(CarlaPipeClientHandle handle);
  367. /*!
  368. * TODO.
  369. */
  370. CARLA_PLUGIN_EXPORT void carla_pipe_client_destroy(CarlaPipeClientHandle handle);
  371. /* --------------------------------------------------------------------------------------------------------------------
  372. * system stuff */
  373. /*!
  374. * Flush stdout or stderr.
  375. */
  376. CARLA_PLUGIN_EXPORT void carla_fflush(bool err);
  377. /*!
  378. * Print the string @a string to stdout or stderr.
  379. */
  380. CARLA_PLUGIN_EXPORT void carla_fputs(bool err, const char* string);
  381. /*!
  382. * Set the current process name to @a name.
  383. */
  384. CARLA_PLUGIN_EXPORT void carla_set_process_name(const char* name);
  385. /* --------------------------------------------------------------------------------------------------------------------
  386. * window control */
  387. /*!
  388. * Get the global/desktop scale factor.
  389. */
  390. CARLA_PLUGIN_EXPORT double carla_get_desktop_scale_factor(void);
  391. CARLA_PLUGIN_EXPORT int carla_cocoa_get_window(void* nsViewPtr);
  392. CARLA_PLUGIN_EXPORT void carla_cocoa_set_transient_window_for(void* nsViewChild, void* nsViewParent);
  393. CARLA_PLUGIN_EXPORT void carla_x11_reparent_window(uintptr_t winId1, uintptr_t winId2);
  394. CARLA_PLUGIN_EXPORT void carla_x11_move_window(uintptr_t winId, int x, int y);
  395. CARLA_PLUGIN_EXPORT int* carla_x11_get_window_pos(uintptr_t winId);
  396. /* ----------------------------------------------------------------------------------------------------------------- */
  397. /** @} */
  398. #endif /* CARLA_UTILS_H_INCLUDED */