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.

1205 lines
35KB

  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_HOST_H_INCLUDED
  18. #define CARLA_HOST_H_INCLUDED
  19. #include "CarlaBackend.h"
  20. #ifdef __cplusplus
  21. using CARLA_BACKEND_NAMESPACE::BinaryType;
  22. using CARLA_BACKEND_NAMESPACE::PluginType;
  23. using CARLA_BACKEND_NAMESPACE::PluginCategory;
  24. using CARLA_BACKEND_NAMESPACE::InternalParameterIndex;
  25. using CARLA_BACKEND_NAMESPACE::EngineCallbackOpcode;
  26. using CARLA_BACKEND_NAMESPACE::NsmCallbackOpcode;
  27. using CARLA_BACKEND_NAMESPACE::EngineOption;
  28. using CARLA_BACKEND_NAMESPACE::EngineProcessMode;
  29. using CARLA_BACKEND_NAMESPACE::EngineTransportMode;
  30. using CARLA_BACKEND_NAMESPACE::FileCallbackOpcode;
  31. using CARLA_BACKEND_NAMESPACE::EngineCallbackFunc;
  32. using CARLA_BACKEND_NAMESPACE::FileCallbackFunc;
  33. using CARLA_BACKEND_NAMESPACE::ParameterData;
  34. using CARLA_BACKEND_NAMESPACE::ParameterRanges;
  35. using CARLA_BACKEND_NAMESPACE::MidiProgramData;
  36. using CARLA_BACKEND_NAMESPACE::CustomData;
  37. using CARLA_BACKEND_NAMESPACE::EngineDriverDeviceInfo;
  38. using CARLA_BACKEND_NAMESPACE::CarlaEngine;
  39. using CARLA_BACKEND_NAMESPACE::CarlaEngineClient;
  40. using CARLA_BACKEND_NAMESPACE::CarlaPlugin;
  41. #endif
  42. /*!
  43. * @defgroup CarlaHostAPI Carla Host API
  44. *
  45. * The Carla Host API.
  46. *
  47. * This API makes it possible to use the Carla Backend in a standalone host application..
  48. *
  49. * None of the returned values in this API calls need to be deleted or free'd.
  50. * When a function fails (returns false or NULL), use carla_get_last_error() to find out what went wrong.
  51. * @{
  52. */
  53. /* ------------------------------------------------------------------------------------------------------------
  54. * Carla Host API (C stuff) */
  55. /*!
  56. * Information about a loaded plugin.
  57. * @see carla_get_plugin_info()
  58. */
  59. typedef struct _CarlaPluginInfo {
  60. /*!
  61. * Plugin type.
  62. */
  63. PluginType type;
  64. /*!
  65. * Plugin category.
  66. */
  67. PluginCategory category;
  68. /*!
  69. * Plugin hints.
  70. * @see PluginHints
  71. */
  72. uint hints;
  73. /*!
  74. * Plugin options available for the user to change.
  75. * @see PluginOptions
  76. */
  77. uint optionsAvailable;
  78. /*!
  79. * Plugin options currently enabled.
  80. * Some options are enabled but not available, which means they will always be on.
  81. * @see PluginOptions
  82. */
  83. uint optionsEnabled;
  84. /*!
  85. * Plugin filename.
  86. * This can be the plugin binary or resource file.
  87. */
  88. const char* filename;
  89. /*!
  90. * Plugin name.
  91. * This name is unique within a Carla instance.
  92. * @see carla_get_real_plugin_name()
  93. */
  94. const char* name;
  95. /*!
  96. * Plugin label or URI.
  97. */
  98. const char* label;
  99. /*!
  100. * Plugin author/maker.
  101. */
  102. const char* maker;
  103. /*!
  104. * Plugin copyright/license.
  105. */
  106. const char* copyright;
  107. /*!
  108. * Icon name for this plugin, in lowercase.
  109. * Default is "plugin".
  110. */
  111. const char* iconName;
  112. /*!
  113. * Plugin unique Id.
  114. * This Id is dependent on the plugin type and may sometimes be 0.
  115. */
  116. int64_t uniqueId;
  117. #ifdef __cplusplus
  118. /*!
  119. * C++ constructor and destructor.
  120. */
  121. CARLA_API _CarlaPluginInfo() noexcept;
  122. CARLA_API ~_CarlaPluginInfo() noexcept;
  123. CARLA_DECLARE_NON_COPYABLE(_CarlaPluginInfo)
  124. #endif
  125. } CarlaPluginInfo;
  126. /*!
  127. * Port count information, used for Audio and MIDI ports and parameters.
  128. * @see carla_get_audio_port_count_info()
  129. * @see carla_get_midi_port_count_info()
  130. * @see carla_get_parameter_count_info()
  131. */
  132. typedef struct _CarlaPortCountInfo {
  133. /*!
  134. * Number of inputs.
  135. */
  136. uint32_t ins;
  137. /*!
  138. * Number of outputs.
  139. */
  140. uint32_t outs;
  141. } CarlaPortCountInfo;
  142. /*!
  143. * Parameter information.
  144. * @see carla_get_parameter_info()
  145. */
  146. typedef struct _CarlaParameterInfo {
  147. /*!
  148. * Parameter name.
  149. */
  150. const char* name;
  151. /*!
  152. * Parameter symbol.
  153. */
  154. const char* symbol;
  155. /*!
  156. * Parameter unit.
  157. */
  158. const char* unit;
  159. /*!
  160. * Parameter comment / documentation.
  161. */
  162. const char* comment;
  163. /*!
  164. * Parameter group name, prefixed by a unique symbol and ":".
  165. */
  166. const char* groupName;
  167. /*!
  168. * Number of scale points.
  169. * @see CarlaScalePointInfo
  170. */
  171. uint32_t scalePointCount;
  172. #ifdef __cplusplus
  173. /*!
  174. * C++ constructor and destructor.
  175. */
  176. CARLA_API _CarlaParameterInfo() noexcept;
  177. CARLA_API ~_CarlaParameterInfo() noexcept;
  178. CARLA_DECLARE_NON_COPYABLE(_CarlaParameterInfo)
  179. #endif
  180. } CarlaParameterInfo;
  181. /*!
  182. * Parameter scale point information.
  183. * @see carla_get_parameter_scalepoint_info()
  184. */
  185. typedef struct _CarlaScalePointInfo {
  186. /*!
  187. * Scale point value.
  188. */
  189. float value;
  190. /*!
  191. * Scale point label.
  192. */
  193. const char* label;
  194. #ifdef __cplusplus
  195. /*!
  196. * C++ constructor and destructor.
  197. */
  198. CARLA_API _CarlaScalePointInfo() noexcept;
  199. CARLA_API ~_CarlaScalePointInfo() noexcept;
  200. CARLA_DECLARE_NON_COPYABLE(_CarlaScalePointInfo)
  201. #endif
  202. } CarlaScalePointInfo;
  203. /*!
  204. * Transport information.
  205. * @see carla_get_transport_info()
  206. */
  207. typedef struct _CarlaTransportInfo {
  208. /*!
  209. * Wherever transport is playing.
  210. */
  211. bool playing;
  212. /*!
  213. * Current transport frame.
  214. */
  215. uint64_t frame;
  216. /*!
  217. * Bar.
  218. */
  219. int32_t bar;
  220. /*!
  221. * Beat.
  222. */
  223. int32_t beat;
  224. /*!
  225. * Tick.
  226. */
  227. int32_t tick;
  228. /*!
  229. * Beats per minute.
  230. */
  231. double bpm;
  232. #ifdef __cplusplus
  233. /*!
  234. * C++ constructor.
  235. */
  236. CARLA_API _CarlaTransportInfo() noexcept;
  237. /*!
  238. * Clear struct contents.
  239. */
  240. CARLA_API void clear() noexcept;
  241. #endif
  242. } CarlaTransportInfo;
  243. /*!
  244. * Runtime engine information.
  245. */
  246. typedef struct _CarlaRuntimeEngineInfo {
  247. /*!
  248. * DSP load.
  249. */
  250. float load;
  251. /*!
  252. * Number of xruns.
  253. */
  254. uint32_t xruns;
  255. } CarlaRuntimeEngineInfo;
  256. /*!
  257. * Runtime engine driver device information.
  258. */
  259. typedef struct {
  260. /*!
  261. * Name of the driver device.
  262. */
  263. const char* name;
  264. /*!
  265. * This driver device hints.
  266. * @see EngineDriverHints
  267. */
  268. uint hints;
  269. /*!
  270. * Current buffer size.
  271. */
  272. uint bufferSize;
  273. /*!
  274. * Available buffer sizes.
  275. * Terminated with 0.
  276. */
  277. const uint32_t* bufferSizes;
  278. /*!
  279. * Current sample rate.
  280. */
  281. double sampleRate;
  282. /*!
  283. * Available sample rates.
  284. * Terminated with 0.0.
  285. */
  286. const double* sampleRates;
  287. } CarlaRuntimeEngineDriverDeviceInfo;
  288. /*!
  289. * Image data for LV2 inline display API.
  290. * raw image pixmap format is ARGB32,
  291. */
  292. typedef struct {
  293. unsigned char* data;
  294. int width;
  295. int height;
  296. int stride;
  297. } CarlaInlineDisplayImageSurface;
  298. /*! Opaque data type for CarlaHost API calls */
  299. typedef struct _CarlaHostHandle* CarlaHostHandle;
  300. /* ------------------------------------------------------------------------------------------------------------
  301. * Carla Host API (C functions) */
  302. /*!
  303. * Get how many engine drivers are available.
  304. */
  305. CARLA_API_EXPORT uint carla_get_engine_driver_count(void);
  306. /*!
  307. * Get an engine driver name.
  308. * @param index Driver index
  309. */
  310. CARLA_API_EXPORT const char* carla_get_engine_driver_name(uint index);
  311. /*!
  312. * Get the device names of an engine driver.
  313. * @param index Driver index
  314. */
  315. CARLA_API_EXPORT const char* const* carla_get_engine_driver_device_names(uint index);
  316. /*!
  317. * Get information about a device driver.
  318. * @param index Driver index
  319. * @param name Device name
  320. */
  321. CARLA_API_EXPORT const EngineDriverDeviceInfo* carla_get_engine_driver_device_info(uint index, const char* name);
  322. /*!
  323. * Show a device custom control panel.
  324. * @see ENGINE_DRIVER_DEVICE_HAS_CONTROL_PANEL
  325. * @param index Driver index
  326. * @param name Device name
  327. */
  328. CARLA_API_EXPORT bool carla_show_engine_driver_device_control_panel(uint index, const char* name);
  329. /*!
  330. * Create a global host handle for standalone application usage.
  331. */
  332. CARLA_API_EXPORT CarlaHostHandle carla_standalone_host_init(void);
  333. #ifdef __cplusplus
  334. /*!
  335. * Get the currently used engine, may be NULL.
  336. * @note C++ only
  337. */
  338. CARLA_API_EXPORT CarlaEngine* carla_get_engine_from_handle(CarlaHostHandle handle);
  339. #endif
  340. /*!
  341. * Initialize the engine.
  342. * Make sure to call carla_engine_idle() at regular intervals afterwards.
  343. * @param driverName Driver to use
  344. * @param clientName Engine master client name
  345. */
  346. CARLA_API_EXPORT bool carla_engine_init(CarlaHostHandle handle, const char* driverName, const char* clientName);
  347. #ifdef BUILD_BRIDGE
  348. /*!
  349. * Initialize the engine in bridged mode.
  350. */
  351. CARLA_API_EXPORT bool carla_engine_init_bridge(CarlaHostHandle handle,
  352. const char audioBaseName[6+1],
  353. const char rtClientBaseName[6+1],
  354. const char nonRtClientBaseName[6+1],
  355. const char nonRtServerBaseName[6+1],
  356. const char* clientName);
  357. #endif
  358. /*!
  359. * Close the engine.
  360. * This function always closes the engine even if it returns false.
  361. * In other words, even when something goes wrong when closing the engine it still be closed nonetheless.
  362. */
  363. CARLA_API_EXPORT bool carla_engine_close(CarlaHostHandle handle);
  364. /*!
  365. * Idle the engine.
  366. * Do not call this if the engine is not running.
  367. */
  368. CARLA_API_EXPORT void carla_engine_idle(CarlaHostHandle handle);
  369. /*!
  370. * Check if the engine is running.
  371. */
  372. CARLA_API_EXPORT bool carla_is_engine_running(CarlaHostHandle handle);
  373. /*!
  374. * Get information about the currently running engine.
  375. */
  376. CARLA_API_EXPORT const CarlaRuntimeEngineInfo* carla_get_runtime_engine_info(CarlaHostHandle handle);
  377. #ifndef BUILD_BRIDGE
  378. /*!
  379. * Get information about the currently running engine driver device.
  380. */
  381. CARLA_API_EXPORT const CarlaRuntimeEngineDriverDeviceInfo* carla_get_runtime_engine_driver_device_info(CarlaHostHandle handle);
  382. /*!
  383. * Dynamically change buffer size and/or sample rate while engine is running.
  384. * @see ENGINE_DRIVER_DEVICE_VARIABLE_BUFFER_SIZE
  385. * @see ENGINE_DRIVER_DEVICE_VARIABLE_SAMPLE_RATE
  386. */
  387. CARLA_API_EXPORT bool carla_set_engine_buffer_size_and_sample_rate(CarlaHostHandle handle,
  388. uint bufferSize, double sampleRate);
  389. /*!
  390. * Show the custom control panel for the current engine device.
  391. * @see ENGINE_DRIVER_DEVICE_HAS_CONTROL_PANEL
  392. */
  393. CARLA_API_EXPORT bool carla_show_engine_device_control_panel(CarlaHostHandle handle);
  394. #endif
  395. /*!
  396. * Clear the xrun count on the engine, so that the next time carla_get_runtime_engine_info() is called, it returns 0.
  397. */
  398. CARLA_API_EXPORT void carla_clear_engine_xruns(CarlaHostHandle handle);
  399. /*!
  400. * Tell the engine to stop the current cancelable action.
  401. * @see ENGINE_CALLBACK_CANCELABLE_ACTION
  402. */
  403. CARLA_API_EXPORT void carla_cancel_engine_action(CarlaHostHandle handle);
  404. /*!
  405. * Tell the engine it's about to close.
  406. * This is used to prevent the engine thread(s) from reactivating.
  407. * Returns true if there's no pending engine events.
  408. */
  409. CARLA_API_EXPORT bool carla_set_engine_about_to_close(CarlaHostHandle handle);
  410. /*!
  411. * Set the engine callback function.
  412. * @param func Callback function
  413. * @param ptr Callback pointer
  414. */
  415. CARLA_API_EXPORT void carla_set_engine_callback(CarlaHostHandle handle, EngineCallbackFunc func, void* ptr);
  416. /*!
  417. * Set an engine option.
  418. * @param option Option
  419. * @param value Value as number
  420. * @param valueStr Value as string
  421. */
  422. CARLA_API_EXPORT void carla_set_engine_option(CarlaHostHandle handle,
  423. EngineOption option, int value, const char* valueStr);
  424. /*!
  425. * Set the file callback function.
  426. * @param func Callback function
  427. * @param ptr Callback pointer
  428. */
  429. CARLA_API_EXPORT void carla_set_file_callback(CarlaHostHandle handle, FileCallbackFunc func, void* ptr);
  430. /*!
  431. * Load a file of any type.
  432. * This will try to load a generic file as a plugin,
  433. * either by direct handling (SF2 and SFZ) or by using an internal plugin (like Audio and MIDI).
  434. * @see carla_get_supported_file_extensions()
  435. */
  436. CARLA_API_EXPORT bool carla_load_file(CarlaHostHandle handle, const char* filename);
  437. /*!
  438. * Load a Carla project file.
  439. * @note Currently loaded plugins are not removed; call carla_remove_all_plugins() first if needed.
  440. */
  441. CARLA_API_EXPORT bool carla_load_project(CarlaHostHandle handle, const char* filename);
  442. /*!
  443. * Save current project to a file.
  444. */
  445. CARLA_API_EXPORT bool carla_save_project(CarlaHostHandle handle, const char* filename);
  446. #ifndef BUILD_BRIDGE
  447. /*!
  448. * Get the currently set project folder.
  449. * @note Valid for both standalone and plugin versions.
  450. */
  451. CARLA_API_EXPORT const char* carla_get_current_project_folder(CarlaHostHandle handle);
  452. /*!
  453. * Get the currently set project filename.
  454. * @note Valid only for standalone version.
  455. */
  456. CARLA_API_EXPORT const char* carla_get_current_project_filename(CarlaHostHandle handle);
  457. /*!
  458. * Clear the currently set project filename.
  459. */
  460. CARLA_API_EXPORT void carla_clear_project_filename(CarlaHostHandle handle);
  461. /*!
  462. * Connect two patchbay ports.
  463. * @param groupIdA Output (source) group
  464. * @param portIdA Output (source) port
  465. * @param groupIdB Input (target) group
  466. * @param portIdB Input (target) port
  467. * @note The group corresponds to the client Id received in the engine callback
  468. * for ENGINE_CALLBACK_PATCHBAY_PORT_ADDED.
  469. * @see ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED
  470. */
  471. CARLA_API_EXPORT bool carla_patchbay_connect(CarlaHostHandle handle,
  472. bool external, uint groupIdA, uint portIdA, uint groupIdB, uint portIdB);
  473. /*!
  474. * Disconnect two patchbay ports.
  475. * @param connectionId Connection Id
  476. * @see ENGINE_CALLBACK_PATCHBAY_CONNECTION_REMOVED
  477. */
  478. CARLA_API_EXPORT bool carla_patchbay_disconnect(CarlaHostHandle handle, bool external, uint connectionId);
  479. /*!
  480. * Set the position of a group.
  481. * This is purely cached and saved in the project file, Carla backend does nothing with the value.
  482. * When loading a project, callbacks are used to inform of the previously saved positions.
  483. * @see ENGINE_CALLBACK_PATCHBAY_CLIENT_POSITION_CHANGED
  484. */
  485. CARLA_API_EXPORT bool carla_patchbay_set_group_pos(CarlaHostHandle handle,
  486. bool external, uint groupId, int x1, int y1, int x2, int y2);
  487. /*!
  488. * Force the engine to resend all patchbay clients, ports and connections again.
  489. * @param external Wherever to show external/hardware ports instead of internal ones.
  490. * Only valid in patchbay engine mode, other modes will ignore this.
  491. */
  492. CARLA_API_EXPORT bool carla_patchbay_refresh(CarlaHostHandle handle, bool external);
  493. /*!
  494. * Start playback of the engine transport.
  495. */
  496. CARLA_API_EXPORT void carla_transport_play(CarlaHostHandle handle);
  497. /*!
  498. * Pause the engine transport.
  499. */
  500. CARLA_API_EXPORT void carla_transport_pause(CarlaHostHandle handle);
  501. /*!
  502. * Set the engine transport bpm.
  503. */
  504. CARLA_API_EXPORT void carla_transport_bpm(CarlaHostHandle handle, double bpm);
  505. /*!
  506. * Relocate the engine transport to a specific frame.
  507. */
  508. CARLA_API_EXPORT void carla_transport_relocate(CarlaHostHandle handle, uint64_t frame);
  509. /*!
  510. * Get the current transport frame.
  511. */
  512. CARLA_API_EXPORT uint64_t carla_get_current_transport_frame(CarlaHostHandle handle);
  513. /*!
  514. * Get the engine transport information.
  515. */
  516. CARLA_API_EXPORT const CarlaTransportInfo* carla_get_transport_info(CarlaHostHandle handle);
  517. #endif
  518. /*!
  519. * Current number of plugins loaded.
  520. */
  521. CARLA_API_EXPORT uint32_t carla_get_current_plugin_count(CarlaHostHandle handle);
  522. /*!
  523. * Maximum number of loadable plugins allowed.
  524. * Returns 0 if engine is not started.
  525. */
  526. CARLA_API_EXPORT uint32_t carla_get_max_plugin_number(CarlaHostHandle handle);
  527. /*!
  528. * Add a new plugin.
  529. * If you don't know the binary type use the BINARY_NATIVE macro.
  530. * @param btype Binary type
  531. * @param ptype Plugin type
  532. * @param filename Filename, if applicable
  533. * @param name Name of the plugin, can be NULL
  534. * @param label Plugin label, if applicable
  535. * @param uniqueId Plugin unique Id, if applicable
  536. * @param extraPtr Extra pointer, defined per plugin type
  537. * @param options Initial plugin options
  538. */
  539. CARLA_API_EXPORT bool carla_add_plugin(CarlaHostHandle handle,
  540. BinaryType btype, PluginType ptype,
  541. const char* filename, const char* name, const char* label, int64_t uniqueId,
  542. const void* extraPtr, uint options);
  543. /*!
  544. * Remove one plugin.
  545. * @param pluginId Plugin to remove.
  546. */
  547. CARLA_API_EXPORT bool carla_remove_plugin(CarlaHostHandle handle, uint pluginId);
  548. /*!
  549. * Remove all plugins.
  550. */
  551. CARLA_API_EXPORT bool carla_remove_all_plugins(CarlaHostHandle handle);
  552. #ifndef BUILD_BRIDGE
  553. /*!
  554. * Rename a plugin.
  555. * Returns the new name, or NULL if the operation failed.
  556. * @param pluginId Plugin to rename
  557. * @param newName New plugin name
  558. */
  559. CARLA_API_EXPORT bool carla_rename_plugin(CarlaHostHandle handle, uint pluginId, const char* newName);
  560. /*!
  561. * Clone a plugin.
  562. * @param pluginId Plugin to clone
  563. */
  564. CARLA_API_EXPORT bool carla_clone_plugin(CarlaHostHandle handle, uint pluginId);
  565. /*!
  566. * Prepare replace of a plugin.
  567. * The next call to carla_add_plugin() will use this id, replacing the current plugin.
  568. * @param pluginId Plugin to replace
  569. * @note This function requires carla_add_plugin() to be called afterwards *as soon as possible*.
  570. */
  571. CARLA_API_EXPORT bool carla_replace_plugin(CarlaHostHandle handle, uint pluginId);
  572. /*!
  573. * Switch two plugins positions.
  574. * @param pluginIdA Plugin A
  575. * @param pluginIdB Plugin B
  576. */
  577. CARLA_API_EXPORT bool carla_switch_plugins(CarlaHostHandle handle, uint pluginIdA, uint pluginIdB);
  578. #endif
  579. /*!
  580. * Load a plugin state.
  581. * @param pluginId Plugin
  582. * @param filename Path to plugin state
  583. * @see carla_save_plugin_state()
  584. */
  585. CARLA_API_EXPORT bool carla_load_plugin_state(CarlaHostHandle handle, uint pluginId, const char* filename);
  586. /*!
  587. * Save a plugin state.
  588. * @param pluginId Plugin
  589. * @param filename Path to plugin state
  590. * @see carla_load_plugin_state()
  591. */
  592. CARLA_API_EXPORT bool carla_save_plugin_state(CarlaHostHandle handle, uint pluginId, const char* filename);
  593. /*!
  594. * Export plugin as LV2.
  595. * @param pluginId Plugin
  596. * @param lv2path Path to lv2 plugin folder
  597. */
  598. CARLA_API_EXPORT bool carla_export_plugin_lv2(CarlaHostHandle handle, uint pluginId, const char* lv2path);
  599. /*!
  600. * Get information from a plugin.
  601. * @param pluginId Plugin
  602. */
  603. CARLA_API_EXPORT const CarlaPluginInfo* carla_get_plugin_info(CarlaHostHandle handle, uint pluginId);
  604. /*!
  605. * Get audio port count information from a plugin.
  606. * @param pluginId Plugin
  607. */
  608. CARLA_API_EXPORT const CarlaPortCountInfo* carla_get_audio_port_count_info(CarlaHostHandle handle, uint pluginId);
  609. /*!
  610. * Get MIDI port count information from a plugin.
  611. * @param pluginId Plugin
  612. */
  613. CARLA_API_EXPORT const CarlaPortCountInfo* carla_get_midi_port_count_info(CarlaHostHandle handle, uint pluginId);
  614. /*!
  615. * Get parameter count information from a plugin.
  616. * @param pluginId Plugin
  617. */
  618. CARLA_API_EXPORT const CarlaPortCountInfo* carla_get_parameter_count_info(CarlaHostHandle handle, uint pluginId);
  619. /*!
  620. * Get hints about an audio port.
  621. * @param pluginId Plugin
  622. * @param isOutput Whether port is output, input otherwise
  623. * @param portIndex Port index, related to input or output
  624. */
  625. CARLA_API_EXPORT uint carla_get_audio_port_hints(CarlaHostHandle handle, uint pluginId, bool isOutput, uint32_t portIndex);
  626. /*!
  627. * Get parameter information from a plugin.
  628. * @param pluginId Plugin
  629. * @param parameterId Parameter index
  630. * @see carla_get_parameter_count()
  631. */
  632. CARLA_API_EXPORT const CarlaParameterInfo* carla_get_parameter_info(CarlaHostHandle handle,
  633. uint pluginId,
  634. uint32_t parameterId);
  635. /*!
  636. * Get parameter scale point information from a plugin.
  637. * @param pluginId Plugin
  638. * @param parameterId Parameter index
  639. * @param scalePointId Parameter scale-point index
  640. * @see CarlaParameterInfo::scalePointCount
  641. */
  642. CARLA_API_EXPORT const CarlaScalePointInfo* carla_get_parameter_scalepoint_info(CarlaHostHandle handle,
  643. uint pluginId,
  644. uint32_t parameterId,
  645. uint32_t scalePointId);
  646. /*!
  647. * Get a plugin's parameter data.
  648. * @param pluginId Plugin
  649. * @param parameterId Parameter index
  650. * @see carla_get_parameter_count()
  651. */
  652. CARLA_API_EXPORT const ParameterData* carla_get_parameter_data(CarlaHostHandle handle,
  653. uint pluginId, uint32_t parameterId);
  654. /*!
  655. * Get a plugin's parameter ranges.
  656. * @param pluginId Plugin
  657. * @param parameterId Parameter index
  658. * @see carla_get_parameter_count()
  659. */
  660. CARLA_API_EXPORT const ParameterRanges* carla_get_parameter_ranges(CarlaHostHandle handle,
  661. uint pluginId, uint32_t parameterId);
  662. /*!
  663. * Get a plugin's MIDI program data.
  664. * @param pluginId Plugin
  665. * @param midiProgramId MIDI Program index
  666. * @see carla_get_midi_program_count()
  667. */
  668. CARLA_API_EXPORT const MidiProgramData* carla_get_midi_program_data(CarlaHostHandle handle,
  669. uint pluginId, uint32_t midiProgramId);
  670. /*!
  671. * Get a plugin's custom data, using index.
  672. * @param pluginId Plugin
  673. * @param customDataId Custom data index
  674. * @see carla_get_custom_data_count()
  675. */
  676. CARLA_API_EXPORT const CustomData* carla_get_custom_data(CarlaHostHandle handle, uint pluginId, uint32_t customDataId);
  677. /*!
  678. * Get a plugin's custom data value, using type and key.
  679. * @param pluginId Plugin
  680. * @param type Custom data type
  681. * @param key Custom data key
  682. * @see carla_get_custom_data_count()
  683. */
  684. CARLA_API_EXPORT const char* carla_get_custom_data_value(CarlaHostHandle handle,
  685. uint pluginId, const char* type, const char* key);
  686. /*!
  687. * Get a plugin's chunk data.
  688. * @param pluginId Plugin
  689. * @see PLUGIN_OPTION_USE_CHUNKS and carla_set_chunk_data()
  690. */
  691. CARLA_API_EXPORT const char* carla_get_chunk_data(CarlaHostHandle handle, uint pluginId);
  692. /*!
  693. * Get how many parameters a plugin has.
  694. * @param pluginId Plugin
  695. */
  696. CARLA_API_EXPORT uint32_t carla_get_parameter_count(CarlaHostHandle handle, uint pluginId);
  697. /*!
  698. * Get how many programs a plugin has.
  699. * @param pluginId Plugin
  700. * @see carla_get_program_name()
  701. */
  702. CARLA_API_EXPORT uint32_t carla_get_program_count(CarlaHostHandle handle, uint pluginId);
  703. /*!
  704. * Get how many MIDI programs a plugin has.
  705. * @param pluginId Plugin
  706. * @see carla_get_midi_program_name() and carla_get_midi_program_data()
  707. */
  708. CARLA_API_EXPORT uint32_t carla_get_midi_program_count(CarlaHostHandle handle, uint pluginId);
  709. /*!
  710. * Get how many custom data sets a plugin has.
  711. * @param pluginId Plugin
  712. * @see carla_get_custom_data()
  713. */
  714. CARLA_API_EXPORT uint32_t carla_get_custom_data_count(CarlaHostHandle handle, uint pluginId);
  715. /*!
  716. * Get a plugin's parameter text (custom display of internal values).
  717. * @param pluginId Plugin
  718. * @param parameterId Parameter index
  719. * @see PARAMETER_USES_CUSTOM_TEXT
  720. */
  721. CARLA_API_EXPORT const char* carla_get_parameter_text(CarlaHostHandle handle, uint pluginId, uint32_t parameterId);
  722. /*!
  723. * Get a plugin's program name.
  724. * @param pluginId Plugin
  725. * @param programId Program index
  726. * @see carla_get_program_count()
  727. */
  728. CARLA_API_EXPORT const char* carla_get_program_name(CarlaHostHandle handle, uint pluginId, uint32_t programId);
  729. /*!
  730. * Get a plugin's MIDI program name.
  731. * @param pluginId Plugin
  732. * @param midiProgramId MIDI Program index
  733. * @see carla_get_midi_program_count()
  734. */
  735. CARLA_API_EXPORT const char* carla_get_midi_program_name(CarlaHostHandle handle, uint pluginId, uint32_t midiProgramId);
  736. /*!
  737. * Get a plugin's real name.
  738. * This is the name the plugin uses to identify itself; may not be unique.
  739. * @param pluginId Plugin
  740. */
  741. CARLA_API_EXPORT const char* carla_get_real_plugin_name(CarlaHostHandle handle, uint pluginId);
  742. /*!
  743. * Get a plugin's program index.
  744. * @param pluginId Plugin
  745. */
  746. CARLA_API_EXPORT int32_t carla_get_current_program_index(CarlaHostHandle handle, uint pluginId);
  747. /*!
  748. * Get a plugin's midi program index.
  749. * @param pluginId Plugin
  750. */
  751. CARLA_API_EXPORT int32_t carla_get_current_midi_program_index(CarlaHostHandle handle, uint pluginId);
  752. /*!
  753. * Get a plugin's default parameter value.
  754. * @param pluginId Plugin
  755. * @param parameterId Parameter index
  756. */
  757. CARLA_API_EXPORT float carla_get_default_parameter_value(CarlaHostHandle handle, uint pluginId, uint32_t parameterId);
  758. /*!
  759. * Get a plugin's current parameter value.
  760. * @param pluginId Plugin
  761. * @param parameterId Parameter index
  762. */
  763. CARLA_API_EXPORT float carla_get_current_parameter_value(CarlaHostHandle handle, uint pluginId, uint32_t parameterId);
  764. /*!
  765. * Get a plugin's internal parameter value.
  766. * @param pluginId Plugin
  767. * @param parameterId Parameter index, maybe be negative
  768. * @see InternalParameterIndex
  769. */
  770. CARLA_API_EXPORT float carla_get_internal_parameter_value(CarlaHostHandle handle, uint pluginId, int32_t parameterId);
  771. /*!
  772. * Get a plugin's internal latency, in samples.
  773. * @param pluginId Plugin
  774. * @see InternalParameterIndex
  775. */
  776. CARLA_API_EXPORT uint32_t carla_get_plugin_latency(CarlaHostHandle handle, uint pluginId);
  777. /*!
  778. * Get a plugin's peak values.
  779. * @param pluginId Plugin
  780. */
  781. CARLA_API_EXPORT const float* carla_get_peak_values(CarlaHostHandle handle, uint pluginId);
  782. /*!
  783. * Get a plugin's input peak value.
  784. * @param pluginId Plugin
  785. * @param isLeft Wherever to get the left/mono value, otherwise right.
  786. */
  787. CARLA_API_EXPORT float carla_get_input_peak_value(CarlaHostHandle handle, uint pluginId, bool isLeft);
  788. /*!
  789. * Get a plugin's output peak value.
  790. * @param pluginId Plugin
  791. * @param isLeft Wherever to get the left/mono value, otherwise right.
  792. */
  793. CARLA_API_EXPORT float carla_get_output_peak_value(CarlaHostHandle handle, uint pluginId, bool isLeft);
  794. /*!
  795. * Render a plugin's inline display.
  796. * @param pluginId Plugin
  797. */
  798. CARLA_API_EXPORT const CarlaInlineDisplayImageSurface* carla_render_inline_display(CarlaHostHandle handle,
  799. uint pluginId,
  800. uint32_t width,
  801. uint32_t height);
  802. /*!
  803. * Enable or disable a plugin.
  804. * @param pluginId Plugin
  805. * @param onOff New active state
  806. */
  807. CARLA_API_EXPORT void carla_set_active(CarlaHostHandle handle, uint pluginId, bool onOff);
  808. #ifndef BUILD_BRIDGE
  809. /*!
  810. * Change a plugin's internal dry/wet.
  811. * @param pluginId Plugin
  812. * @param value New dry/wet value
  813. */
  814. CARLA_API_EXPORT void carla_set_drywet(CarlaHostHandle handle, uint pluginId, float value);
  815. /*!
  816. * Change a plugin's internal volume.
  817. * @param pluginId Plugin
  818. * @param value New volume
  819. */
  820. CARLA_API_EXPORT void carla_set_volume(CarlaHostHandle handle, uint pluginId, float value);
  821. /*!
  822. * Change a plugin's internal stereo balance, left channel.
  823. * @param pluginId Plugin
  824. * @param value New value
  825. */
  826. CARLA_API_EXPORT void carla_set_balance_left(CarlaHostHandle handle, uint pluginId, float value);
  827. /*!
  828. * Change a plugin's internal stereo balance, right channel.
  829. * @param pluginId Plugin
  830. * @param value New value
  831. */
  832. CARLA_API_EXPORT void carla_set_balance_right(CarlaHostHandle handle, uint pluginId, float value);
  833. /*!
  834. * Change a plugin's internal mono panning value.
  835. * @param pluginId Plugin
  836. * @param value New value
  837. */
  838. CARLA_API_EXPORT void carla_set_panning(CarlaHostHandle handle, uint pluginId, float value);
  839. /*!
  840. * Change a plugin's internal control channel.
  841. * @param pluginId Plugin
  842. * @param channel New channel
  843. */
  844. CARLA_API_EXPORT void carla_set_ctrl_channel(CarlaHostHandle handle, uint pluginId, int8_t channel);
  845. #endif
  846. /*!
  847. * Enable a plugin's option.
  848. * @param pluginId Plugin
  849. * @param option An option from PluginOptions
  850. * @param yesNo New enabled state
  851. */
  852. CARLA_API_EXPORT void carla_set_option(CarlaHostHandle handle, uint pluginId, uint option, bool yesNo);
  853. /*!
  854. * Change a plugin's parameter value.
  855. * @param pluginId Plugin
  856. * @param parameterId Parameter index
  857. * @param value New value
  858. */
  859. CARLA_API_EXPORT void carla_set_parameter_value(CarlaHostHandle handle, uint pluginId, uint32_t parameterId, float value);
  860. #ifndef BUILD_BRIDGE
  861. /*!
  862. * Change a plugin's parameter MIDI channel.
  863. * @param pluginId Plugin
  864. * @param parameterId Parameter index
  865. * @param channel New MIDI channel
  866. */
  867. CARLA_API_EXPORT void carla_set_parameter_midi_channel(CarlaHostHandle handle,
  868. uint pluginId, uint32_t parameterId, uint8_t channel);
  869. /*!
  870. * Change a plugin's parameter mapped control index.
  871. * @param pluginId Plugin
  872. * @param parameterId Parameter index
  873. * @param cc New control index
  874. */
  875. CARLA_API_EXPORT void carla_set_parameter_mapped_control_index(CarlaHostHandle handle,
  876. uint pluginId, uint32_t parameterId, int16_t index);
  877. /*!
  878. * Change a plugin's parameter mapped range.
  879. * @param pluginId Plugin
  880. * @param parameterId Parameter index
  881. * @param minimum New mapped minimum
  882. * @param maximum New mapped maximum
  883. */
  884. CARLA_API_EXPORT void carla_set_parameter_mapped_range(CarlaHostHandle handle,
  885. uint pluginId, uint32_t parameterId, float minimum, float maximum);
  886. /*!
  887. * Change a plugin's parameter in drag/touch mode state.
  888. * Usually happens from a UI when the user is moving a parameter with a mouse or similar input.
  889. * @param pluginId Plugin
  890. * @param parameterId Parameter index
  891. * @param touch New state
  892. */
  893. CARLA_API_EXPORT void carla_set_parameter_touch(CarlaHostHandle handle,
  894. uint pluginId, uint32_t parameterId, bool touch);
  895. #endif
  896. /*!
  897. * Change a plugin's current program.
  898. * @param pluginId Plugin
  899. * @param programId New program
  900. */
  901. CARLA_API_EXPORT void carla_set_program(CarlaHostHandle handle, uint pluginId, uint32_t programId);
  902. /*!
  903. * Change a plugin's current MIDI program.
  904. * @param pluginId Plugin
  905. * @param midiProgramId New value
  906. */
  907. CARLA_API_EXPORT void carla_set_midi_program(CarlaHostHandle handle, uint pluginId, uint32_t midiProgramId);
  908. /*!
  909. * Set a plugin's custom data set.
  910. * @param pluginId Plugin
  911. * @param type Type
  912. * @param key Key
  913. * @param value New value
  914. * @see CustomDataTypes and CustomDataKeys
  915. */
  916. CARLA_API_EXPORT void carla_set_custom_data(CarlaHostHandle handle,
  917. uint pluginId, const char* type, const char* key, const char* value);
  918. /*!
  919. * Set a plugin's chunk data.
  920. * @param pluginId Plugin
  921. * @param chunkData New chunk data
  922. * @see PLUGIN_OPTION_USE_CHUNKS and carla_get_chunk_data()
  923. */
  924. CARLA_API_EXPORT void carla_set_chunk_data(CarlaHostHandle handle, uint pluginId, const char* chunkData);
  925. /*!
  926. * Tell a plugin to prepare for save.
  927. * This should be called before saving custom data sets.
  928. * @param pluginId Plugin
  929. */
  930. CARLA_API_EXPORT void carla_prepare_for_save(CarlaHostHandle handle, uint pluginId);
  931. /*!
  932. * Reset all plugin's parameters.
  933. * @param pluginId Plugin
  934. */
  935. CARLA_API_EXPORT void carla_reset_parameters(CarlaHostHandle handle, uint pluginId);
  936. /*!
  937. * Randomize all plugin's parameters.
  938. * @param pluginId Plugin
  939. */
  940. CARLA_API_EXPORT void carla_randomize_parameters(CarlaHostHandle handle, uint pluginId);
  941. #ifndef BUILD_BRIDGE
  942. /*!
  943. * Send a single note of a plugin.
  944. * If velocity is 0, note-off is sent; note-on otherwise.
  945. * @param pluginId Plugin
  946. * @param channel Note channel
  947. * @param note Note pitch
  948. * @param velocity Note velocity
  949. */
  950. CARLA_API_EXPORT void carla_send_midi_note(CarlaHostHandle handle,
  951. uint pluginId, uint8_t channel, uint8_t note, uint8_t velocity);
  952. #endif
  953. /*!
  954. * Set a custom title for the plugin UI window created by Carla.
  955. */
  956. CARLA_API_EXPORT void carla_set_custom_ui_title(CarlaHostHandle handle, uint pluginId, const char* title);
  957. /*!
  958. * Tell a plugin to show its own custom UI.
  959. * @param pluginId Plugin
  960. * @param yesNo New UI state, visible or not
  961. * @see PLUGIN_HAS_CUSTOM_UI
  962. */
  963. CARLA_API_EXPORT void carla_show_custom_ui(CarlaHostHandle handle, uint pluginId, bool yesNo);
  964. /*!
  965. * Embed the plugin's custom UI to the system pointer @a ptr.
  966. * This function is always called from the main thread.
  967. * @note This is very experimental and subject to change at this point
  968. */
  969. CARLA_API_EXPORT void* carla_embed_custom_ui(CarlaHostHandle handle, uint pluginId, void* ptr);
  970. /*!
  971. * Get the current engine buffer size.
  972. */
  973. CARLA_API_EXPORT uint32_t carla_get_buffer_size(CarlaHostHandle handle);
  974. /*!
  975. * Get the current engine sample rate.
  976. */
  977. CARLA_API_EXPORT double carla_get_sample_rate(CarlaHostHandle handle);
  978. /*!
  979. * Get the last error.
  980. */
  981. CARLA_API_EXPORT const char* carla_get_last_error(CarlaHostHandle handle);
  982. /*!
  983. * Get the current engine OSC URL (TCP).
  984. */
  985. CARLA_API_EXPORT const char* carla_get_host_osc_url_tcp(CarlaHostHandle handle);
  986. /*!
  987. * Get the current engine OSC URL (UDP).
  988. */
  989. CARLA_API_EXPORT const char* carla_get_host_osc_url_udp(CarlaHostHandle handle);
  990. /*!
  991. * Initialize NSM (that is, announce ourselves to it).
  992. * Must be called as early as possible in the program's lifecycle.
  993. * Returns true if NSM is available and initialized correctly.
  994. */
  995. CARLA_API_EXPORT bool carla_nsm_init(CarlaHostHandle handle, uint64_t pid, const char* executableName);
  996. /*!
  997. * Respond to an NSM callback.
  998. */
  999. CARLA_API_EXPORT void carla_nsm_ready(CarlaHostHandle handle, NsmCallbackOpcode opcode);
  1000. #ifndef CARLA_UTILS_H_INCLUDED
  1001. /*!
  1002. * Get the complete license text of used third-party code and features.
  1003. * Returned string is in basic html format.
  1004. */
  1005. CARLA_API_EXPORT const char* carla_get_complete_license_text(void);
  1006. /*!
  1007. * Get the juce version used in the current Carla build.
  1008. */
  1009. CARLA_API_EXPORT const char* carla_get_juce_version(void);
  1010. /*!
  1011. * Get the list of supported file extensions in carla_load_file().
  1012. */
  1013. CARLA_API_EXPORT const char* const* carla_get_supported_file_extensions(void);
  1014. /*!
  1015. * Get the list of supported features in the current Carla build.
  1016. */
  1017. CARLA_API_EXPORT const char* const* carla_get_supported_features(void);
  1018. /*!
  1019. * Get the absolute filename of this carla library.
  1020. */
  1021. CARLA_API_EXPORT const char* carla_get_library_filename(void);
  1022. /*!
  1023. * Get the folder where this carla library resides.
  1024. */
  1025. CARLA_API_EXPORT const char* carla_get_library_folder(void);
  1026. #endif
  1027. /** @} */
  1028. #endif /* CARLA_HOST_H_INCLUDED */