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.

493 lines
12KB

  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 */