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.

1079 lines
27KB

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