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.

1163 lines
33KB

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