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.

1155 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. * Force the engine to resend all patchbay clients, ports and connections again.
  470. * @param external Wherever to show external/hardware ports instead of internal ones.
  471. * Only valid in patchbay engine mode, other modes will ignore this.
  472. */
  473. CARLA_EXPORT bool carla_patchbay_refresh(CarlaHostHandle handle, bool external);
  474. /*!
  475. * Start playback of the engine transport.
  476. */
  477. CARLA_EXPORT void carla_transport_play(CarlaHostHandle handle);
  478. /*!
  479. * Pause the engine transport.
  480. */
  481. CARLA_EXPORT void carla_transport_pause(CarlaHostHandle handle);
  482. /*!
  483. * Set the engine transport bpm.
  484. */
  485. CARLA_EXPORT void carla_transport_bpm(CarlaHostHandle handle, double bpm);
  486. /*!
  487. * Relocate the engine transport to a specific frame.
  488. */
  489. CARLA_EXPORT void carla_transport_relocate(CarlaHostHandle handle, uint64_t frame);
  490. /*!
  491. * Get the current transport frame.
  492. */
  493. CARLA_EXPORT uint64_t carla_get_current_transport_frame(CarlaHostHandle handle);
  494. /*!
  495. * Get the engine transport information.
  496. */
  497. CARLA_EXPORT const CarlaTransportInfo* carla_get_transport_info(CarlaHostHandle handle);
  498. #endif
  499. /*!
  500. * Current number of plugins loaded.
  501. */
  502. CARLA_EXPORT uint32_t carla_get_current_plugin_count(CarlaHostHandle handle);
  503. /*!
  504. * Maximum number of loadable plugins allowed.
  505. * Returns 0 if engine is not started.
  506. */
  507. CARLA_EXPORT uint32_t carla_get_max_plugin_number(CarlaHostHandle handle);
  508. /*!
  509. * Add a new plugin.
  510. * If you don't know the binary type use the BINARY_NATIVE macro.
  511. * @param btype Binary type
  512. * @param ptype Plugin type
  513. * @param filename Filename, if applicable
  514. * @param name Name of the plugin, can be NULL
  515. * @param label Plugin label, if applicable
  516. * @param uniqueId Plugin unique Id, if applicable
  517. * @param extraPtr Extra pointer, defined per plugin type
  518. * @param options Initial plugin options
  519. */
  520. CARLA_EXPORT bool carla_add_plugin(CarlaHostHandle handle,
  521. BinaryType btype, PluginType ptype,
  522. const char* filename, const char* name, const char* label, int64_t uniqueId,
  523. const void* extraPtr, uint options);
  524. /*!
  525. * Remove one plugin.
  526. * @param pluginId Plugin to remove.
  527. */
  528. CARLA_EXPORT bool carla_remove_plugin(CarlaHostHandle handle, uint pluginId);
  529. /*!
  530. * Remove all plugins.
  531. */
  532. CARLA_EXPORT bool carla_remove_all_plugins(CarlaHostHandle handle);
  533. #ifndef BUILD_BRIDGE
  534. /*!
  535. * Rename a plugin.
  536. * Returns the new name, or NULL if the operation failed.
  537. * @param pluginId Plugin to rename
  538. * @param newName New plugin name
  539. */
  540. CARLA_EXPORT bool carla_rename_plugin(CarlaHostHandle handle, uint pluginId, const char* newName);
  541. /*!
  542. * Clone a plugin.
  543. * @param pluginId Plugin to clone
  544. */
  545. CARLA_EXPORT bool carla_clone_plugin(CarlaHostHandle handle, uint pluginId);
  546. /*!
  547. * Prepare replace of a plugin.
  548. * The next call to carla_add_plugin() will use this id, replacing the current plugin.
  549. * @param pluginId Plugin to replace
  550. * @note This function requires carla_add_plugin() to be called afterwards *as soon as possible*.
  551. */
  552. CARLA_EXPORT bool carla_replace_plugin(CarlaHostHandle handle, uint pluginId);
  553. /*!
  554. * Switch two plugins positions.
  555. * @param pluginIdA Plugin A
  556. * @param pluginIdB Plugin B
  557. */
  558. CARLA_EXPORT bool carla_switch_plugins(CarlaHostHandle handle, uint pluginIdA, uint pluginIdB);
  559. #endif
  560. /*!
  561. * Load a plugin state.
  562. * @param pluginId Plugin
  563. * @param filename Path to plugin state
  564. * @see carla_save_plugin_state()
  565. */
  566. CARLA_EXPORT bool carla_load_plugin_state(CarlaHostHandle handle, uint pluginId, const char* filename);
  567. /*!
  568. * Save a plugin state.
  569. * @param pluginId Plugin
  570. * @param filename Path to plugin state
  571. * @see carla_load_plugin_state()
  572. */
  573. CARLA_EXPORT bool carla_save_plugin_state(CarlaHostHandle handle, uint pluginId, const char* filename);
  574. /*!
  575. * Export plugin as LV2.
  576. * @param pluginId Plugin
  577. * @param lv2path Path to lv2 plugin folder
  578. */
  579. CARLA_EXPORT bool carla_export_plugin_lv2(CarlaHostHandle handle, uint pluginId, const char* lv2path);
  580. /*!
  581. * Get information from a plugin.
  582. * @param pluginId Plugin
  583. */
  584. CARLA_EXPORT const CarlaPluginInfo* carla_get_plugin_info(CarlaHostHandle handle, uint pluginId);
  585. /*!
  586. * Get audio port count information from a plugin.
  587. * @param pluginId Plugin
  588. */
  589. CARLA_EXPORT const CarlaPortCountInfo* carla_get_audio_port_count_info(CarlaHostHandle handle, uint pluginId);
  590. /*!
  591. * Get MIDI port count information from a plugin.
  592. * @param pluginId Plugin
  593. */
  594. CARLA_EXPORT const CarlaPortCountInfo* carla_get_midi_port_count_info(CarlaHostHandle handle, uint pluginId);
  595. /*!
  596. * Get parameter count information from a plugin.
  597. * @param pluginId Plugin
  598. */
  599. CARLA_EXPORT const CarlaPortCountInfo* carla_get_parameter_count_info(CarlaHostHandle handle, uint pluginId);
  600. /*!
  601. * Get parameter information from a plugin.
  602. * @param pluginId Plugin
  603. * @param parameterId Parameter index
  604. * @see carla_get_parameter_count()
  605. */
  606. CARLA_EXPORT const CarlaParameterInfo* carla_get_parameter_info(CarlaHostHandle handle,
  607. uint pluginId,
  608. uint32_t parameterId);
  609. /*!
  610. * Get parameter scale point information from a plugin.
  611. * @param pluginId Plugin
  612. * @param parameterId Parameter index
  613. * @param scalePointId Parameter scale-point index
  614. * @see CarlaParameterInfo::scalePointCount
  615. */
  616. CARLA_EXPORT const CarlaScalePointInfo* carla_get_parameter_scalepoint_info(CarlaHostHandle handle,
  617. uint pluginId,
  618. uint32_t parameterId,
  619. uint32_t scalePointId);
  620. /*!
  621. * Get a plugin's parameter data.
  622. * @param pluginId Plugin
  623. * @param parameterId Parameter index
  624. * @see carla_get_parameter_count()
  625. */
  626. CARLA_EXPORT const ParameterData* carla_get_parameter_data(CarlaHostHandle handle,
  627. uint pluginId,
  628. uint32_t parameterId);
  629. /*!
  630. * Get a plugin's parameter ranges.
  631. * @param pluginId Plugin
  632. * @param parameterId Parameter index
  633. * @see carla_get_parameter_count()
  634. */
  635. CARLA_EXPORT const ParameterRanges* carla_get_parameter_ranges(CarlaHostHandle handle,
  636. uint pluginId,
  637. uint32_t parameterId);
  638. /*!
  639. * Get a plugin's MIDI program data.
  640. * @param pluginId Plugin
  641. * @param midiProgramId MIDI Program index
  642. * @see carla_get_midi_program_count()
  643. */
  644. CARLA_EXPORT const MidiProgramData* carla_get_midi_program_data(CarlaHostHandle handle,
  645. uint pluginId,
  646. uint32_t midiProgramId);
  647. /*!
  648. * Get a plugin's custom data, using index.
  649. * @param pluginId Plugin
  650. * @param customDataId Custom data index
  651. * @see carla_get_custom_data_count()
  652. */
  653. CARLA_EXPORT const CustomData* carla_get_custom_data(CarlaHostHandle handle, uint pluginId, uint32_t customDataId);
  654. /*!
  655. * Get a plugin's custom data value, using type and key.
  656. * @param pluginId Plugin
  657. * @param type Custom data type
  658. * @param key Custom data key
  659. * @see carla_get_custom_data_count()
  660. */
  661. CARLA_EXPORT const char* carla_get_custom_data_value(CarlaHostHandle handle,
  662. uint pluginId,
  663. const char* type,
  664. const char* key);
  665. /*!
  666. * Get a plugin's chunk data.
  667. * @param pluginId Plugin
  668. * @see PLUGIN_OPTION_USE_CHUNKS and carla_set_chunk_data()
  669. */
  670. CARLA_EXPORT const char* carla_get_chunk_data(CarlaHostHandle handle, uint pluginId);
  671. /*!
  672. * Get how many parameters a plugin has.
  673. * @param pluginId Plugin
  674. */
  675. CARLA_EXPORT uint32_t carla_get_parameter_count(CarlaHostHandle handle, uint pluginId);
  676. /*!
  677. * Get how many programs a plugin has.
  678. * @param pluginId Plugin
  679. * @see carla_get_program_name()
  680. */
  681. CARLA_EXPORT uint32_t carla_get_program_count(CarlaHostHandle handle, uint pluginId);
  682. /*!
  683. * Get how many MIDI programs a plugin has.
  684. * @param pluginId Plugin
  685. * @see carla_get_midi_program_name() and carla_get_midi_program_data()
  686. */
  687. CARLA_EXPORT uint32_t carla_get_midi_program_count(CarlaHostHandle handle, uint pluginId);
  688. /*!
  689. * Get how many custom data sets a plugin has.
  690. * @param pluginId Plugin
  691. * @see carla_get_custom_data()
  692. */
  693. CARLA_EXPORT uint32_t carla_get_custom_data_count(CarlaHostHandle handle, uint pluginId);
  694. /*!
  695. * Get a plugin's parameter text (custom display of internal values).
  696. * @param pluginId Plugin
  697. * @param parameterId Parameter index
  698. * @see PARAMETER_USES_CUSTOM_TEXT
  699. */
  700. CARLA_EXPORT const char* carla_get_parameter_text(CarlaHostHandle handle, uint pluginId, uint32_t parameterId);
  701. /*!
  702. * Get a plugin's program name.
  703. * @param pluginId Plugin
  704. * @param programId Program index
  705. * @see carla_get_program_count()
  706. */
  707. CARLA_EXPORT const char* carla_get_program_name(CarlaHostHandle handle, uint pluginId, uint32_t programId);
  708. /*!
  709. * Get a plugin's MIDI program name.
  710. * @param pluginId Plugin
  711. * @param midiProgramId MIDI Program index
  712. * @see carla_get_midi_program_count()
  713. */
  714. CARLA_EXPORT const char* carla_get_midi_program_name(CarlaHostHandle handle, uint pluginId, uint32_t midiProgramId);
  715. /*!
  716. * Get a plugin's real name.
  717. * This is the name the plugin uses to identify itself; may not be unique.
  718. * @param pluginId Plugin
  719. */
  720. CARLA_EXPORT const char* carla_get_real_plugin_name(CarlaHostHandle handle, uint pluginId);
  721. /*!
  722. * Get a plugin's program index.
  723. * @param pluginId Plugin
  724. */
  725. CARLA_EXPORT int32_t carla_get_current_program_index(CarlaHostHandle handle, uint pluginId);
  726. /*!
  727. * Get a plugin's midi program index.
  728. * @param pluginId Plugin
  729. */
  730. CARLA_EXPORT int32_t carla_get_current_midi_program_index(CarlaHostHandle handle, uint pluginId);
  731. /*!
  732. * Get a plugin's default parameter value.
  733. * @param pluginId Plugin
  734. * @param parameterId Parameter index
  735. */
  736. CARLA_EXPORT float carla_get_default_parameter_value(CarlaHostHandle handle, uint pluginId, uint32_t parameterId);
  737. /*!
  738. * Get a plugin's current parameter value.
  739. * @param pluginId Plugin
  740. * @param parameterId Parameter index
  741. */
  742. CARLA_EXPORT float carla_get_current_parameter_value(CarlaHostHandle handle, uint pluginId, uint32_t parameterId);
  743. /*!
  744. * Get a plugin's internal parameter value.
  745. * @param pluginId Plugin
  746. * @param parameterId Parameter index, maybe be negative
  747. * @see InternalParameterIndex
  748. */
  749. CARLA_EXPORT float carla_get_internal_parameter_value(CarlaHostHandle handle, uint pluginId, int32_t parameterId);
  750. /*!
  751. * Get a plugin's peak values.
  752. * @param pluginId Plugin
  753. */
  754. CARLA_EXPORT const float* carla_get_peak_values(CarlaHostHandle handle, uint pluginId);
  755. /*!
  756. * Get a plugin's input peak value.
  757. * @param pluginId Plugin
  758. * @param isLeft Wherever to get the left/mono value, otherwise right.
  759. */
  760. CARLA_EXPORT float carla_get_input_peak_value(CarlaHostHandle handle, uint pluginId, bool isLeft);
  761. /*!
  762. * Get a plugin's output peak value.
  763. * @param pluginId Plugin
  764. * @param isLeft Wherever to get the left/mono value, otherwise right.
  765. */
  766. CARLA_EXPORT float carla_get_output_peak_value(CarlaHostHandle handle, uint pluginId, bool isLeft);
  767. /*!
  768. * Render a plugin's inline display.
  769. * @param pluginId Plugin
  770. */
  771. CARLA_EXPORT const CarlaInlineDisplayImageSurface* carla_render_inline_display(CarlaHostHandle handle,
  772. uint pluginId,
  773. uint32_t width,
  774. uint32_t height);
  775. /*!
  776. * Enable or disable a plugin.
  777. * @param pluginId Plugin
  778. * @param onOff New active state
  779. */
  780. CARLA_EXPORT void carla_set_active(CarlaHostHandle handle, uint pluginId, bool onOff);
  781. #ifndef BUILD_BRIDGE
  782. /*!
  783. * Change a plugin's internal dry/wet.
  784. * @param pluginId Plugin
  785. * @param value New dry/wet value
  786. */
  787. CARLA_EXPORT void carla_set_drywet(CarlaHostHandle handle, uint pluginId, float value);
  788. /*!
  789. * Change a plugin's internal volume.
  790. * @param pluginId Plugin
  791. * @param value New volume
  792. */
  793. CARLA_EXPORT void carla_set_volume(CarlaHostHandle handle, uint pluginId, float value);
  794. /*!
  795. * Change a plugin's internal stereo balance, left channel.
  796. * @param pluginId Plugin
  797. * @param value New value
  798. */
  799. CARLA_EXPORT void carla_set_balance_left(CarlaHostHandle handle, uint pluginId, float value);
  800. /*!
  801. * Change a plugin's internal stereo balance, right channel.
  802. * @param pluginId Plugin
  803. * @param value New value
  804. */
  805. CARLA_EXPORT void carla_set_balance_right(CarlaHostHandle handle, uint pluginId, float value);
  806. /*!
  807. * Change a plugin's internal mono panning value.
  808. * @param pluginId Plugin
  809. * @param value New value
  810. */
  811. CARLA_EXPORT void carla_set_panning(CarlaHostHandle handle, uint pluginId, float value);
  812. /*!
  813. * Change a plugin's internal control channel.
  814. * @param pluginId Plugin
  815. * @param channel New channel
  816. */
  817. CARLA_EXPORT void carla_set_ctrl_channel(CarlaHostHandle handle, uint pluginId, int8_t channel);
  818. #endif
  819. /*!
  820. * Enable a plugin's option.
  821. * @param pluginId Plugin
  822. * @param option An option from PluginOptions
  823. * @param yesNo New enabled state
  824. */
  825. CARLA_EXPORT void carla_set_option(CarlaHostHandle handle, uint pluginId, uint option, bool yesNo);
  826. /*!
  827. * Change a plugin's parameter value.
  828. * @param pluginId Plugin
  829. * @param parameterId Parameter index
  830. * @param value New value
  831. */
  832. CARLA_EXPORT void carla_set_parameter_value(CarlaHostHandle handle, uint pluginId, uint32_t parameterId, float value);
  833. #ifndef BUILD_BRIDGE
  834. /*!
  835. * Change a plugin's parameter MIDI channel.
  836. * @param pluginId Plugin
  837. * @param parameterId Parameter index
  838. * @param channel New MIDI channel
  839. */
  840. CARLA_EXPORT void carla_set_parameter_midi_channel(CarlaHostHandle handle,
  841. uint pluginId,
  842. uint32_t parameterId,
  843. uint8_t channel);
  844. /*!
  845. * Change a plugin's parameter mapped control index.
  846. * @param pluginId Plugin
  847. * @param parameterId Parameter index
  848. * @param cc New control index
  849. */
  850. CARLA_EXPORT void carla_set_parameter_mapped_control_index(CarlaHostHandle handle,
  851. uint pluginId,
  852. uint32_t parameterId,
  853. int16_t index);
  854. /*!
  855. * Change a plugin's parameter mapped range.
  856. * @param pluginId Plugin
  857. * @param parameterId Parameter index
  858. * @param minimum New mapped minimum
  859. * @param maximum New mapped maximum
  860. */
  861. CARLA_EXPORT void carla_set_parameter_mapped_range(CarlaHostHandle handle,
  862. uint pluginId,
  863. uint32_t parameterId,
  864. float minimum, float maximum);
  865. /*!
  866. * Change a plugin's parameter in drag/touch mode state.
  867. * Usually happens from a UI when the user is moving a parameter with a mouse or similar input.
  868. * @param pluginId Plugin
  869. * @param parameterId Parameter index
  870. * @param touch New state
  871. */
  872. CARLA_EXPORT void carla_set_parameter_touch(CarlaHostHandle handle,
  873. uint pluginId,
  874. uint32_t parameterId,
  875. bool touch);
  876. #endif
  877. /*!
  878. * Change a plugin's current program.
  879. * @param pluginId Plugin
  880. * @param programId New program
  881. */
  882. CARLA_EXPORT void carla_set_program(CarlaHostHandle handle, uint pluginId, uint32_t programId);
  883. /*!
  884. * Change a plugin's current MIDI program.
  885. * @param pluginId Plugin
  886. * @param midiProgramId New value
  887. */
  888. CARLA_EXPORT void carla_set_midi_program(CarlaHostHandle handle, uint pluginId, uint32_t midiProgramId);
  889. /*!
  890. * Set a plugin's custom data set.
  891. * @param pluginId Plugin
  892. * @param type Type
  893. * @param key Key
  894. * @param value New value
  895. * @see CustomDataTypes and CustomDataKeys
  896. */
  897. CARLA_EXPORT void carla_set_custom_data(CarlaHostHandle handle,
  898. uint pluginId,
  899. const char* type, const char* key, const char* value);
  900. /*!
  901. * Set a plugin's chunk data.
  902. * @param pluginId Plugin
  903. * @param chunkData New chunk data
  904. * @see PLUGIN_OPTION_USE_CHUNKS and carla_get_chunk_data()
  905. */
  906. CARLA_EXPORT void carla_set_chunk_data(CarlaHostHandle handle, uint pluginId, const char* chunkData);
  907. /*!
  908. * Tell a plugin to prepare for save.
  909. * This should be called before saving custom data sets.
  910. * @param pluginId Plugin
  911. */
  912. CARLA_EXPORT void carla_prepare_for_save(CarlaHostHandle handle, uint pluginId);
  913. /*!
  914. * Reset all plugin's parameters.
  915. * @param pluginId Plugin
  916. */
  917. CARLA_EXPORT void carla_reset_parameters(CarlaHostHandle handle, uint pluginId);
  918. /*!
  919. * Randomize all plugin's parameters.
  920. * @param pluginId Plugin
  921. */
  922. CARLA_EXPORT void carla_randomize_parameters(CarlaHostHandle handle, uint pluginId);
  923. #ifndef BUILD_BRIDGE
  924. /*!
  925. * Send a single note of a plugin.
  926. * If velocity is 0, note-off is sent; note-on otherwise.
  927. * @param pluginId Plugin
  928. * @param channel Note channel
  929. * @param note Note pitch
  930. * @param velocity Note velocity
  931. */
  932. CARLA_EXPORT void carla_send_midi_note(CarlaHostHandle handle,
  933. uint pluginId,
  934. uint8_t channel, uint8_t note, uint8_t velocity);
  935. #endif
  936. /*!
  937. * Set a custom format when plugin UI windows created by Carla.
  938. * MUST include one and only one %s, where carla places the plugin name.
  939. * By default this format is "%s (GUI)"
  940. */
  941. CARLA_EXPORT void carla_set_custom_ui_title_format(CarlaHostHandle handle, uint pluginId, const char* format);
  942. /*!
  943. * Tell a plugin to show its own custom UI.
  944. * @param pluginId Plugin
  945. * @param yesNo New UI state, visible or not
  946. * @see PLUGIN_HAS_CUSTOM_UI
  947. */
  948. CARLA_EXPORT void carla_show_custom_ui(CarlaHostHandle handle, uint pluginId, bool yesNo);
  949. /*!
  950. * Get the current engine buffer size.
  951. */
  952. CARLA_EXPORT uint32_t carla_get_buffer_size(CarlaHostHandle handle);
  953. /*!
  954. * Get the current engine sample rate.
  955. */
  956. CARLA_EXPORT double carla_get_sample_rate(CarlaHostHandle handle);
  957. /*!
  958. * Get the last error.
  959. */
  960. CARLA_EXPORT const char* carla_get_last_error(CarlaHostHandle handle);
  961. /*!
  962. * Get the current engine OSC URL (TCP).
  963. */
  964. CARLA_EXPORT const char* carla_get_host_osc_url_tcp(CarlaHostHandle handle);
  965. /*!
  966. * Get the current engine OSC URL (UDP).
  967. */
  968. CARLA_EXPORT const char* carla_get_host_osc_url_udp(CarlaHostHandle handle);
  969. /*!
  970. * Get the absolute filename of this carla library.
  971. */
  972. CARLA_EXPORT const char* carla_get_library_filename(void);
  973. /*!
  974. * Get the folder where this carla library resides.
  975. */
  976. CARLA_EXPORT const char* carla_get_library_folder(void);
  977. /*!
  978. * Initialize NSM (that is, announce ourselves to it).
  979. * Must be called as early as possible in the program's lifecycle.
  980. * Returns true if NSM is available and initialized correctly.
  981. */
  982. CARLA_EXPORT bool carla_nsm_init(CarlaHostHandle handle, uint64_t pid, const char* executableName);
  983. /*!
  984. * Respond to an NSM callback.
  985. */
  986. CARLA_EXPORT void carla_nsm_ready(CarlaHostHandle handle, NsmCallbackOpcode opcode);
  987. /** @} */
  988. #endif /* CARLA_HOST_H_INCLUDED */