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.

1081 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. #ifndef BUILD_BRIDGE
  360. /*!
  361. * Get information about the currently running engine driver device.
  362. */
  363. CARLA_EXPORT const CarlaRuntimeEngineDriverDeviceInfo* carla_get_runtime_engine_driver_device_info();
  364. /*!
  365. * Dynamically change buffer size and/or sample rate while engine is running.
  366. * @see ENGINE_DRIVER_DEVICE_VARIABLE_BUFFER_SIZE
  367. * @see ENGINE_DRIVER_DEVICE_VARIABLE_SAMPLE_RATE
  368. */
  369. CARLA_EXPORT bool carla_set_engine_buffer_size_and_sample_rate(uint bufferSize, double sampleRate);
  370. /*!
  371. * Show the custom control panel for the current engine device.
  372. * @see ENGINE_DRIVER_DEVICE_HAS_CONTROL_PANEL
  373. */
  374. CARLA_EXPORT bool carla_show_engine_device_control_panel();
  375. #endif
  376. /*!
  377. * Clear the xrun count on the engine, so that the next time carla_get_runtime_engine_info() is called, it returns 0.
  378. */
  379. CARLA_EXPORT void carla_clear_engine_xruns();
  380. /*!
  381. * Tell the engine to stop the current cancelable action.
  382. * @see ENGINE_CALLBACK_CANCELABLE_ACTION
  383. */
  384. CARLA_EXPORT void carla_cancel_engine_action();
  385. /*!
  386. * Tell the engine it's about to close.
  387. * This is used to prevent the engine thread(s) from reactivating.
  388. * Returns true if there's no pending engine events.
  389. */
  390. CARLA_EXPORT bool carla_set_engine_about_to_close();
  391. /*!
  392. * Set the engine callback function.
  393. * @param func Callback function
  394. * @param ptr Callback pointer
  395. */
  396. CARLA_EXPORT void carla_set_engine_callback(EngineCallbackFunc func, void* ptr);
  397. #ifndef BUILD_BRIDGE
  398. /*!
  399. * Set an engine option.
  400. * @param option Option
  401. * @param value Value as number
  402. * @param valueStr Value as string
  403. */
  404. CARLA_EXPORT void carla_set_engine_option(EngineOption option, int value, const char* valueStr);
  405. #endif
  406. /*!
  407. * Set the file callback function.
  408. * @param func Callback function
  409. * @param ptr Callback pointer
  410. */
  411. CARLA_EXPORT void carla_set_file_callback(FileCallbackFunc func, void* ptr);
  412. /*!
  413. * Load a file of any type.
  414. * This will try to load a generic file as a plugin,
  415. * either by direct handling (SF2 and SFZ) or by using an internal plugin (like Audio and MIDI).
  416. * @see carla_get_supported_file_extensions()
  417. */
  418. CARLA_EXPORT bool carla_load_file(const char* filename);
  419. /*!
  420. * Load a Carla project file.
  421. * @note Currently loaded plugins are not removed; call carla_remove_all_plugins() first if needed.
  422. */
  423. CARLA_EXPORT bool carla_load_project(const char* filename);
  424. /*!
  425. * Save current project to a file.
  426. */
  427. CARLA_EXPORT bool carla_save_project(const char* filename);
  428. #ifndef BUILD_BRIDGE
  429. /*!
  430. * Clear the currently set project filename.
  431. */
  432. CARLA_EXPORT void carla_clear_project_filename();
  433. /*!
  434. * Connect two patchbay ports.
  435. * @param groupIdA Output group
  436. * @param portIdA Output port
  437. * @param groupIdB Input group
  438. * @param portIdB Input port
  439. * @see ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED
  440. */
  441. CARLA_EXPORT bool carla_patchbay_connect(bool external, uint groupIdA, uint portIdA, uint groupIdB, uint portIdB);
  442. /*!
  443. * Disconnect two patchbay ports.
  444. * @param connectionId Connection Id
  445. * @see ENGINE_CALLBACK_PATCHBAY_CONNECTION_REMOVED
  446. */
  447. CARLA_EXPORT bool carla_patchbay_disconnect(bool external, uint connectionId);
  448. /*!
  449. * Force the engine to resend all patchbay clients, ports and connections again.
  450. * @param external Wherever to show external/hardware ports instead of internal ones.
  451. * Only valid in patchbay engine mode, other modes will ignore this.
  452. */
  453. CARLA_EXPORT bool carla_patchbay_refresh(bool external);
  454. /*!
  455. * Start playback of the engine transport.
  456. */
  457. CARLA_EXPORT void carla_transport_play();
  458. /*!
  459. * Pause the engine transport.
  460. */
  461. CARLA_EXPORT void carla_transport_pause();
  462. /*!
  463. * Set the engine transport bpm.
  464. */
  465. CARLA_EXPORT void carla_transport_bpm(double bpm);
  466. /*!
  467. * Relocate the engine transport to a specific frame.
  468. */
  469. CARLA_EXPORT void carla_transport_relocate(uint64_t frame);
  470. /*!
  471. * Get the current transport frame.
  472. */
  473. CARLA_EXPORT uint64_t carla_get_current_transport_frame();
  474. /*!
  475. * Get the engine transport information.
  476. */
  477. CARLA_EXPORT const CarlaTransportInfo* carla_get_transport_info();
  478. #endif
  479. /*!
  480. * Current number of plugins loaded.
  481. */
  482. CARLA_EXPORT uint32_t carla_get_current_plugin_count();
  483. /*!
  484. * Maximum number of loadable plugins allowed.
  485. * Returns 0 if engine is not started.
  486. */
  487. CARLA_EXPORT uint32_t carla_get_max_plugin_number();
  488. /*!
  489. * Add a new plugin.
  490. * If you don't know the binary type use the BINARY_NATIVE macro.
  491. * @param btype Binary type
  492. * @param ptype Plugin type
  493. * @param filename Filename, if applicable
  494. * @param name Name of the plugin, can be NULL
  495. * @param label Plugin label, if applicable
  496. * @param uniqueId Plugin unique Id, if applicable
  497. * @param extraPtr Extra pointer, defined per plugin type
  498. * @param options Initial plugin options
  499. */
  500. CARLA_EXPORT bool carla_add_plugin(BinaryType btype, PluginType ptype,
  501. const char* filename, const char* name, const char* label, int64_t uniqueId,
  502. const void* extraPtr, uint options);
  503. /*!
  504. * Remove one plugin.
  505. * @param pluginId Plugin to remove.
  506. */
  507. CARLA_EXPORT bool carla_remove_plugin(uint pluginId);
  508. /*!
  509. * Remove all plugins.
  510. */
  511. CARLA_EXPORT bool carla_remove_all_plugins();
  512. #ifndef BUILD_BRIDGE
  513. /*!
  514. * Rename a plugin.
  515. * Returns the new name, or NULL if the operation failed.
  516. * @param pluginId Plugin to rename
  517. * @param newName New plugin name
  518. */
  519. CARLA_EXPORT bool carla_rename_plugin(uint pluginId, const char* newName);
  520. /*!
  521. * Clone a plugin.
  522. * @param pluginId Plugin to clone
  523. */
  524. CARLA_EXPORT bool carla_clone_plugin(uint pluginId);
  525. /*!
  526. * Prepare replace of a plugin.
  527. * The next call to carla_add_plugin() will use this id, replacing the current plugin.
  528. * @param pluginId Plugin to replace
  529. * @note This function requires carla_add_plugin() to be called afterwards *as soon as possible*.
  530. */
  531. CARLA_EXPORT bool carla_replace_plugin(uint pluginId);
  532. /*!
  533. * Switch two plugins positions.
  534. * @param pluginIdA Plugin A
  535. * @param pluginIdB Plugin B
  536. */
  537. CARLA_EXPORT bool carla_switch_plugins(uint pluginIdA, uint pluginIdB);
  538. #endif
  539. /*!
  540. * Load a plugin state.
  541. * @param pluginId Plugin
  542. * @param filename Path to plugin state
  543. * @see carla_save_plugin_state()
  544. */
  545. CARLA_EXPORT bool carla_load_plugin_state(uint pluginId, const char* filename);
  546. /*!
  547. * Save a plugin state.
  548. * @param pluginId Plugin
  549. * @param filename Path to plugin state
  550. * @see carla_load_plugin_state()
  551. */
  552. CARLA_EXPORT bool carla_save_plugin_state(uint pluginId, const char* filename);
  553. /*!
  554. * Export plugin as LV2.
  555. * @param pluginId Plugin
  556. * @param lv2path Path to lv2 plugin folder
  557. */
  558. CARLA_EXPORT bool carla_export_plugin_lv2(uint pluginId, const char* lv2path);
  559. /*!
  560. * Get information from a plugin.
  561. * @param pluginId Plugin
  562. */
  563. CARLA_EXPORT const CarlaPluginInfo* carla_get_plugin_info(uint pluginId);
  564. /*!
  565. * Get audio port count information from a plugin.
  566. * @param pluginId Plugin
  567. */
  568. CARLA_EXPORT const CarlaPortCountInfo* carla_get_audio_port_count_info(uint pluginId);
  569. /*!
  570. * Get MIDI port count information from a plugin.
  571. * @param pluginId Plugin
  572. */
  573. CARLA_EXPORT const CarlaPortCountInfo* carla_get_midi_port_count_info(uint pluginId);
  574. /*!
  575. * Get parameter count information from a plugin.
  576. * @param pluginId Plugin
  577. */
  578. CARLA_EXPORT const CarlaPortCountInfo* carla_get_parameter_count_info(uint pluginId);
  579. /*!
  580. * Get parameter information from a plugin.
  581. * @param pluginId Plugin
  582. * @param parameterId Parameter index
  583. * @see carla_get_parameter_count()
  584. */
  585. CARLA_EXPORT const CarlaParameterInfo* carla_get_parameter_info(uint pluginId, uint32_t parameterId);
  586. /*!
  587. * Get parameter scale point information from a plugin.
  588. * @param pluginId Plugin
  589. * @param parameterId Parameter index
  590. * @param scalePointId Parameter scale-point index
  591. * @see CarlaParameterInfo::scalePointCount
  592. */
  593. CARLA_EXPORT const CarlaScalePointInfo* carla_get_parameter_scalepoint_info(uint pluginId, uint32_t parameterId, uint32_t scalePointId);
  594. /*!
  595. * Get a plugin's parameter data.
  596. * @param pluginId Plugin
  597. * @param parameterId Parameter index
  598. * @see carla_get_parameter_count()
  599. */
  600. CARLA_EXPORT const ParameterData* carla_get_parameter_data(uint pluginId, uint32_t parameterId);
  601. /*!
  602. * Get a plugin's parameter ranges.
  603. * @param pluginId Plugin
  604. * @param parameterId Parameter index
  605. * @see carla_get_parameter_count()
  606. */
  607. CARLA_EXPORT const ParameterRanges* carla_get_parameter_ranges(uint pluginId, uint32_t parameterId);
  608. /*!
  609. * Get a plugin's MIDI program data.
  610. * @param pluginId Plugin
  611. * @param midiProgramId MIDI Program index
  612. * @see carla_get_midi_program_count()
  613. */
  614. CARLA_EXPORT const MidiProgramData* carla_get_midi_program_data(uint pluginId, uint32_t midiProgramId);
  615. /*!
  616. * Get a plugin's custom data, using index.
  617. * @param pluginId Plugin
  618. * @param customDataId Custom data index
  619. * @see carla_get_custom_data_count()
  620. */
  621. CARLA_EXPORT const CustomData* carla_get_custom_data(uint pluginId, uint32_t customDataId);
  622. /*!
  623. * Get a plugin's custom data value, using type and key.
  624. * @param pluginId Plugin
  625. * @param type Custom data type
  626. * @param key Custom data key
  627. * @see carla_get_custom_data_count()
  628. */
  629. CARLA_EXPORT const char* carla_get_custom_data_value(uint pluginId, const char* type, const char* key);
  630. /*!
  631. * Get a plugin's chunk data.
  632. * @param pluginId Plugin
  633. * @see PLUGIN_OPTION_USE_CHUNKS and carla_set_chunk_data()
  634. */
  635. CARLA_EXPORT const char* carla_get_chunk_data(uint pluginId);
  636. /*!
  637. * Get how many parameters a plugin has.
  638. * @param pluginId Plugin
  639. */
  640. CARLA_EXPORT uint32_t carla_get_parameter_count(uint pluginId);
  641. /*!
  642. * Get how many programs a plugin has.
  643. * @param pluginId Plugin
  644. * @see carla_get_program_name()
  645. */
  646. CARLA_EXPORT uint32_t carla_get_program_count(uint pluginId);
  647. /*!
  648. * Get how many MIDI programs a plugin has.
  649. * @param pluginId Plugin
  650. * @see carla_get_midi_program_name() and carla_get_midi_program_data()
  651. */
  652. CARLA_EXPORT uint32_t carla_get_midi_program_count(uint pluginId);
  653. /*!
  654. * Get how many custom data sets a plugin has.
  655. * @param pluginId Plugin
  656. * @see carla_get_custom_data()
  657. */
  658. CARLA_EXPORT uint32_t carla_get_custom_data_count(uint pluginId);
  659. /*!
  660. * Get a plugin's parameter text (custom display of internal values).
  661. * @param pluginId Plugin
  662. * @param parameterId Parameter index
  663. * @see PARAMETER_USES_CUSTOM_TEXT
  664. */
  665. CARLA_EXPORT const char* carla_get_parameter_text(uint pluginId, uint32_t parameterId);
  666. /*!
  667. * Get a plugin's program name.
  668. * @param pluginId Plugin
  669. * @param programId Program index
  670. * @see carla_get_program_count()
  671. */
  672. CARLA_EXPORT const char* carla_get_program_name(uint pluginId, uint32_t programId);
  673. /*!
  674. * Get a plugin's MIDI program name.
  675. * @param pluginId Plugin
  676. * @param midiProgramId MIDI Program index
  677. * @see carla_get_midi_program_count()
  678. */
  679. CARLA_EXPORT const char* carla_get_midi_program_name(uint pluginId, uint32_t midiProgramId);
  680. /*!
  681. * Get a plugin's real name.
  682. * This is the name the plugin uses to identify itself; may not be unique.
  683. * @param pluginId Plugin
  684. */
  685. CARLA_EXPORT const char* carla_get_real_plugin_name(uint pluginId);
  686. /*!
  687. * Get a plugin's program index.
  688. * @param pluginId Plugin
  689. */
  690. CARLA_EXPORT int32_t carla_get_current_program_index(uint pluginId);
  691. /*!
  692. * Get a plugin's midi program index.
  693. * @param pluginId Plugin
  694. */
  695. CARLA_EXPORT int32_t carla_get_current_midi_program_index(uint pluginId);
  696. /*!
  697. * Get a plugin's default parameter value.
  698. * @param pluginId Plugin
  699. * @param parameterId Parameter index
  700. */
  701. CARLA_EXPORT float carla_get_default_parameter_value(uint pluginId, uint32_t parameterId);
  702. /*!
  703. * Get a plugin's current parameter value.
  704. * @param pluginId Plugin
  705. * @param parameterId Parameter index
  706. */
  707. CARLA_EXPORT float carla_get_current_parameter_value(uint pluginId, uint32_t parameterId);
  708. /*!
  709. * Get a plugin's internal parameter value.
  710. * @param pluginId Plugin
  711. * @param parameterId Parameter index, maybe be negative
  712. * @see InternalParameterIndex
  713. */
  714. CARLA_EXPORT float carla_get_internal_parameter_value(uint pluginId, int32_t parameterId);
  715. /*!
  716. * Get a plugin's peak values.
  717. * @param pluginId Plugin
  718. */
  719. CARLA_EXPORT const float* carla_get_peak_values(uint pluginId);
  720. /*!
  721. * Get a plugin's input peak value.
  722. * @param pluginId Plugin
  723. * @param isLeft Wherever to get the left/mono value, otherwise right.
  724. */
  725. CARLA_EXPORT float carla_get_input_peak_value(uint pluginId, bool isLeft);
  726. /*!
  727. * Get a plugin's output peak value.
  728. * @param pluginId Plugin
  729. * @param isLeft Wherever to get the left/mono value, otherwise right.
  730. */
  731. CARLA_EXPORT float carla_get_output_peak_value(uint pluginId, bool isLeft);
  732. /*!
  733. * Render a plugin's inline display.
  734. * @param pluginId Plugin
  735. */
  736. CARLA_EXPORT const CarlaInlineDisplayImageSurface* carla_render_inline_display(uint pluginId, uint32_t width, uint32_t height);
  737. /*!
  738. * Enable or disable a plugin.
  739. * @param pluginId Plugin
  740. * @param onOff New active state
  741. */
  742. CARLA_EXPORT void carla_set_active(uint pluginId, bool onOff);
  743. #ifndef BUILD_BRIDGE
  744. /*!
  745. * Change a plugin's internal dry/wet.
  746. * @param pluginId Plugin
  747. * @param value New dry/wet value
  748. */
  749. CARLA_EXPORT void carla_set_drywet(uint pluginId, float value);
  750. /*!
  751. * Change a plugin's internal volume.
  752. * @param pluginId Plugin
  753. * @param value New volume
  754. */
  755. CARLA_EXPORT void carla_set_volume(uint pluginId, float value);
  756. /*!
  757. * Change a plugin's internal stereo balance, left channel.
  758. * @param pluginId Plugin
  759. * @param value New value
  760. */
  761. CARLA_EXPORT void carla_set_balance_left(uint pluginId, float value);
  762. /*!
  763. * Change a plugin's internal stereo balance, right channel.
  764. * @param pluginId Plugin
  765. * @param value New value
  766. */
  767. CARLA_EXPORT void carla_set_balance_right(uint pluginId, float value);
  768. /*!
  769. * Change a plugin's internal mono panning value.
  770. * @param pluginId Plugin
  771. * @param value New value
  772. */
  773. CARLA_EXPORT void carla_set_panning(uint pluginId, float value);
  774. /*!
  775. * Change a plugin's internal control channel.
  776. * @param pluginId Plugin
  777. * @param channel New channel
  778. */
  779. CARLA_EXPORT void carla_set_ctrl_channel(uint pluginId, int8_t channel);
  780. #endif
  781. /*!
  782. * Enable a plugin's option.
  783. * @param pluginId Plugin
  784. * @param option An option from PluginOptions
  785. * @param yesNo New enabled state
  786. */
  787. CARLA_EXPORT void carla_set_option(uint pluginId, uint option, bool yesNo);
  788. /*!
  789. * Change a plugin's parameter value.
  790. * @param pluginId Plugin
  791. * @param parameterId Parameter index
  792. * @param value New value
  793. */
  794. CARLA_EXPORT void carla_set_parameter_value(uint pluginId, uint32_t parameterId, float value);
  795. #ifndef BUILD_BRIDGE
  796. /*!
  797. * Change a plugin's parameter MIDI channel.
  798. * @param pluginId Plugin
  799. * @param parameterId Parameter index
  800. * @param channel New MIDI channel
  801. */
  802. CARLA_EXPORT void carla_set_parameter_midi_channel(uint pluginId, uint32_t parameterId, uint8_t channel);
  803. /*!
  804. * Change a plugin's parameter MIDI cc.
  805. * @param pluginId Plugin
  806. * @param parameterId Parameter index
  807. * @param cc New MIDI cc
  808. */
  809. CARLA_EXPORT void carla_set_parameter_midi_cc(uint pluginId, uint32_t parameterId, int16_t cc);
  810. /*!
  811. * Change a plugin's parameter in drag/touch mode state.
  812. * Usually happens from a UI when the user is moving a parameter with a mouse or similar input.
  813. * @param pluginId Plugin
  814. * @param parameterId Parameter index
  815. * @param touch New state
  816. */
  817. CARLA_EXPORT void carla_set_parameter_touch(uint pluginId, uint32_t parameterId, bool touch);
  818. #endif
  819. /*!
  820. * Change a plugin's current program.
  821. * @param pluginId Plugin
  822. * @param programId New program
  823. */
  824. CARLA_EXPORT void carla_set_program(uint pluginId, uint32_t programId);
  825. /*!
  826. * Change a plugin's current MIDI program.
  827. * @param pluginId Plugin
  828. * @param midiProgramId New value
  829. */
  830. CARLA_EXPORT void carla_set_midi_program(uint pluginId, uint32_t midiProgramId);
  831. /*!
  832. * Set a plugin's custom data set.
  833. * @param pluginId Plugin
  834. * @param type Type
  835. * @param key Key
  836. * @param value New value
  837. * @see CustomDataTypes and CustomDataKeys
  838. */
  839. CARLA_EXPORT void carla_set_custom_data(uint pluginId, const char* type, const char* key, const char* value);
  840. /*!
  841. * Set a plugin's chunk data.
  842. * @param pluginId Plugin
  843. * @param chunkData New chunk data
  844. * @see PLUGIN_OPTION_USE_CHUNKS and carla_get_chunk_data()
  845. */
  846. CARLA_EXPORT void carla_set_chunk_data(uint pluginId, const char* chunkData);
  847. /*!
  848. * Tell a plugin to prepare for save.
  849. * This should be called before saving custom data sets.
  850. * @param pluginId Plugin
  851. */
  852. CARLA_EXPORT void carla_prepare_for_save(uint pluginId);
  853. /*!
  854. * Reset all plugin's parameters.
  855. * @param pluginId Plugin
  856. */
  857. CARLA_EXPORT void carla_reset_parameters(uint pluginId);
  858. /*!
  859. * Randomize all plugin's parameters.
  860. * @param pluginId Plugin
  861. */
  862. CARLA_EXPORT void carla_randomize_parameters(uint pluginId);
  863. #ifndef BUILD_BRIDGE
  864. /*!
  865. * Send a single note of a plugin.
  866. * If velocity is 0, note-off is sent; note-on otherwise.
  867. * @param pluginId Plugin
  868. * @param channel Note channel
  869. * @param note Note pitch
  870. * @param velocity Note velocity
  871. */
  872. CARLA_EXPORT void carla_send_midi_note(uint pluginId, uint8_t channel, uint8_t note, uint8_t velocity);
  873. #endif
  874. /*!
  875. * Tell a plugin to show its own custom UI.
  876. * @param pluginId Plugin
  877. * @param yesNo New UI state, visible or not
  878. * @see PLUGIN_HAS_CUSTOM_UI
  879. */
  880. CARLA_EXPORT void carla_show_custom_ui(uint pluginId, bool yesNo);
  881. /*!
  882. * Get the current engine buffer size.
  883. */
  884. CARLA_EXPORT uint32_t carla_get_buffer_size();
  885. /*!
  886. * Get the current engine sample rate.
  887. */
  888. CARLA_EXPORT double carla_get_sample_rate();
  889. /*!
  890. * Get the last error.
  891. */
  892. CARLA_EXPORT const char* carla_get_last_error();
  893. /*!
  894. * Get the current engine OSC URL (TCP).
  895. */
  896. CARLA_EXPORT const char* carla_get_host_osc_url_tcp();
  897. /*!
  898. * Get the current engine OSC URL (UDP).
  899. */
  900. CARLA_EXPORT const char* carla_get_host_osc_url_udp();
  901. /*!
  902. * Get the absolute filename of this carla library.
  903. */
  904. CARLA_EXPORT const char* carla_get_library_filename();
  905. /*!
  906. * Get the folder where this carla library resides.
  907. */
  908. CARLA_EXPORT const char* carla_get_library_folder();
  909. /*!
  910. * Initialize NSM (that is, announce ourselves to it).
  911. * Must be called as early as possible in the program's lifecycle.
  912. * Returns true if NSM is available and initialized correctly.
  913. */
  914. CARLA_EXPORT bool carla_nsm_init(int pid, const char* executableName);
  915. /*!
  916. * Respond to an NSM callback.
  917. */
  918. CARLA_EXPORT void carla_nsm_ready(NsmCallbackOpcode opcode);
  919. /** @} */
  920. #endif /* CARLA_HOST_H_INCLUDED */