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.

1154 lines
33KB

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