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.

1146 lines
32KB

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