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.

1186 lines
34KB

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