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.

1181 lines
34KB

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