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.

1335 lines
29KB

  1. /*
  2. * Carla Backend API
  3. * Copyright (C) 2011-2013 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_BACKEND_H_INCLUDED
  18. #define CARLA_BACKEND_H_INCLUDED
  19. #include "CarlaDefines.h"
  20. #ifdef CARLA_PROPER_CPP11_SUPPORT
  21. # include <cstdint>
  22. #else
  23. # include <stdint.h>
  24. #endif
  25. #define STR_MAX 0xFF
  26. #ifdef __cplusplus
  27. # define CARLA_BACKEND_START_NAMESPACE namespace CarlaBackend {
  28. # define CARLA_BACKEND_END_NAMESPACE }
  29. # define CARLA_BACKEND_USE_NAMESPACE using namespace CarlaBackend;
  30. /* Start namespace */
  31. CARLA_BACKEND_START_NAMESPACE
  32. #endif
  33. /*!
  34. * @defgroup CarlaBackendAPI Carla Backend API
  35. *
  36. * The Carla Backend API.
  37. *
  38. * These are the base definitions for everything in the Carla backend code.
  39. * @{
  40. */
  41. // ------------------------------------------------------------------------------------------------------------
  42. // Carla Backend API (base definitions)
  43. /*!
  44. * Maximum default number of loadable plugins.
  45. */
  46. const unsigned int MAX_DEFAULT_PLUGINS = 99;
  47. /*!
  48. * Maximum number of loadable plugins in rack mode.
  49. */
  50. const unsigned int MAX_RACK_PLUGINS = 16;
  51. /*!
  52. * Maximum number of loadable plugins in patchbay mode.
  53. */
  54. const unsigned int MAX_PATCHBAY_PLUGINS = 255;
  55. /*!
  56. * Maximum default number of parameters allowed.
  57. * @see ENGINE_OPTION_MAX_PARAMETERS
  58. */
  59. const unsigned int MAX_DEFAULT_PARAMETERS = 200;
  60. // ------------------------------------------------------------------------------------------------------------
  61. // Engine Driver Device Hints
  62. /*!
  63. * @defgroup EngineDriverHints Engine Driver Device Hints
  64. *
  65. * Various engine driver device hints.
  66. * @see CarlaEngine::getHints(), CarlaEngine::getDriverDeviceInfo() and carla_get_engine_driver_device_info()
  67. * @{
  68. */
  69. /*!
  70. * Engine driver device has custom control-panel.
  71. */
  72. const unsigned int ENGINE_DRIVER_DEVICE_HAS_CONTROL_PANEL = 0x1;
  73. /*!
  74. * Engine driver device can change buffer-size on the fly.
  75. * @see ENGINE_OPTION_AUDIO_BUFFER_SIZE
  76. */
  77. const unsigned int ENGINE_DRIVER_DEVICE_VARIABLE_BUFFER_SIZE = 0x2;
  78. /*!
  79. * Engine driver device can change sample-rate on the fly.
  80. * @see ENGINE_OPTION_AUDIO_SAMPLE_RATE
  81. */
  82. const unsigned int ENGINE_DRIVER_DEVICE_VARIABLE_SAMPLE_RATE = 0x4;
  83. /** @} */
  84. // ------------------------------------------------------------------------------------------------------------
  85. // Plugin Hints
  86. /*!
  87. * @defgroup PluginHints Plugin Hints
  88. *
  89. * Various plugin hints.
  90. * @see CarlaPlugin::getHints() and carla_get_plugin_info()
  91. * @{
  92. */
  93. /*!
  94. * Plugin is a bridge.\n
  95. * This hint is required because "bridge" itself is not a plugin type.
  96. */
  97. const unsigned int PLUGIN_IS_BRIDGE = 0x01;
  98. /*!
  99. * Plugin is hard real-time safe.
  100. */
  101. const unsigned int PLUGIN_IS_RTSAFE = 0x02;
  102. /*!
  103. * Plugin is a synth (produces sound).
  104. */
  105. const unsigned int PLUGIN_IS_SYNTH = 0x04;
  106. /*!
  107. * Plugin has its own custom UI.
  108. * @see CarlaPlugin::showCustomUI() and carla_show_custom_ui()
  109. */
  110. const unsigned int PLUGIN_HAS_CUSTOM_UI = 0x08;
  111. /*!
  112. * Plugin can use internal Dry/Wet control.
  113. */
  114. const unsigned int PLUGIN_CAN_DRYWET = 0x10;
  115. /*!
  116. * Plugin can use internal Volume control.
  117. */
  118. const unsigned int PLUGIN_CAN_VOLUME = 0x20;
  119. /*!
  120. * Plugin can use internal (Stereo) Balance controls.
  121. */
  122. const unsigned int PLUGIN_CAN_BALANCE = 0x40;
  123. /*!
  124. * Plugin can use internal (Mono) Panning control.
  125. */
  126. const unsigned int PLUGIN_CAN_PANNING = 0x80;
  127. /** @} */
  128. // ------------------------------------------------------------------------------------------------------------
  129. // Plugin Options
  130. /*!
  131. * @defgroup PluginOptions Plugin Options
  132. *
  133. * Various plugin options.
  134. * @see CarlaPlugin::getOptionsAvailable(), CarlaPlugin::getOptionsEnabled(), carla_get_plugin_info() and carla_set_option()
  135. * @{
  136. */
  137. /*!
  138. * Use constant/fixed-size audio buffers.
  139. */
  140. const unsigned int PLUGIN_OPTION_FIXED_BUFFERS = 0x001;
  141. /*!
  142. * Force mono plugin as stereo.
  143. */
  144. const unsigned int PLUGIN_OPTION_FORCE_STEREO = 0x002;
  145. /*!
  146. * Map MIDI programs to plugin programs.
  147. */
  148. const unsigned int PLUGIN_OPTION_MAP_PROGRAM_CHANGES = 0x004;
  149. /*!
  150. * Use chunks to save and restore data.
  151. */
  152. const unsigned int PLUGIN_OPTION_USE_CHUNKS = 0x008;
  153. /*!
  154. * Send MIDI control change events.
  155. */
  156. const unsigned int PLUGIN_OPTION_SEND_CONTROL_CHANGES = 0x010;
  157. /*!
  158. * Send MIDI channel pressure events.
  159. */
  160. const unsigned int PLUGIN_OPTION_SEND_CHANNEL_PRESSURE = 0x020;
  161. /*!
  162. * Send MIDI note after-touch events.
  163. */
  164. const unsigned int PLUGIN_OPTION_SEND_NOTE_AFTERTOUCH = 0x040;
  165. /*!
  166. * Send MIDI pitch-bend events.
  167. */
  168. const unsigned int PLUGIN_OPTION_SEND_PITCHBEND = 0x080;
  169. /*!
  170. * Send MIDI all-sounds/notes-off events, single note-offs otherwise.
  171. */
  172. const unsigned int PLUGIN_OPTION_SEND_ALL_SOUND_OFF = 0x100;
  173. /** @} */
  174. // ------------------------------------------------------------------------------------------------------------
  175. // Parameter Hints
  176. /*!
  177. * @defgroup ParameterHints Parameter Hints
  178. *
  179. * Various parameter hints.
  180. * @see CarlaPlugin::getParameterData() and carla_get_parameter_data()
  181. * @{
  182. */
  183. /*!
  184. * Parameter is input.\n
  185. * When this hint is not set, parameter is assumed to be output.
  186. */
  187. const unsigned int PARAMETER_IS_INPUT = 0x001;
  188. /*!
  189. * Parameter value is boolean.
  190. * It's always at either minimum or maximum value.
  191. */
  192. const unsigned int PARAMETER_IS_BOOLEAN = 0x002;
  193. /*!
  194. * Parameter value is integer.
  195. */
  196. const unsigned int PARAMETER_IS_INTEGER = 0x004;
  197. /*!
  198. * Parameter value is logarithmic.
  199. */
  200. const unsigned int PARAMETER_IS_LOGARITHMIC = 0x008;
  201. /*!
  202. * Parameter is enabled.
  203. * It can be viewed, changed and stored.
  204. */
  205. const unsigned int PARAMETER_IS_ENABLED = 0x010;
  206. /*!
  207. * Parameter is automable (real-time safe).
  208. */
  209. const unsigned int PARAMETER_IS_AUTOMABLE = 0x020;
  210. /*!
  211. * Parameter is read-only.
  212. * It cannot be changed.
  213. */
  214. const unsigned int PARAMETER_IS_READ_ONLY = 0x040;
  215. /*!
  216. * Parameter needs sample rate to work.
  217. * Value and ranges are multiplied by sample rate on usage and divided by sample rate on save.
  218. */
  219. const unsigned int PARAMETER_USES_SAMPLERATE = 0x100;
  220. /*!
  221. * Parameter uses scale points to define internal values in a meaningful way.
  222. */
  223. const unsigned int PARAMETER_USES_SCALEPOINTS = 0x200;
  224. /*!
  225. * Parameter uses custom text for displaying its value.
  226. * @see CarlaPlugin::getParameterText() and carla_get_parameter_text()
  227. */
  228. const unsigned int PARAMETER_USES_CUSTOM_TEXT = 0x400;
  229. /** @} */
  230. // ------------------------------------------------------------------------------------------------------------
  231. // Patchbay Port Hints
  232. /*!
  233. * @defgroup PatchbayPortHints Patchbay Port Hints
  234. *
  235. * Various patchbay port hints.
  236. * @{
  237. */
  238. /*!
  239. * Patchbay port is input.\n
  240. * When this hint is not set, port is assumed to be output.
  241. */
  242. const unsigned int PATCHBAY_PORT_IS_INPUT = 0x1;
  243. /*!
  244. * Patchbay port is of Audio type.
  245. */
  246. const unsigned int PATCHBAY_PORT_TYPE_AUDIO = 0x2;
  247. /*!
  248. * Patchbay port is of CV type (Control Voltage).
  249. */
  250. const unsigned int PATCHBAY_PORT_TYPE_CV = 0x4;
  251. /*!
  252. * Patchbay port is of MIDI type.
  253. */
  254. const unsigned int PATCHBAY_PORT_TYPE_MIDI = 0x8;
  255. /** @} */
  256. // ------------------------------------------------------------------------------------------------------------
  257. // Custom Data Types
  258. /*!
  259. * @defgroup CustomDataTypes Custom Data Types
  260. *
  261. * These types define how the value in the CustomData struct is stored.
  262. * @see CustomData::type
  263. * @{
  264. */
  265. /*!
  266. * Boolean string type URI.\n
  267. * Only "true" and "false" are valid values.
  268. */
  269. const char* const CUSTOM_DATA_TYPE_BOOLEAN = "http://kxstudio.sf.net/ns/carla/boolean";
  270. /*!
  271. * Chunk type URI.
  272. */
  273. const char* const CUSTOM_DATA_TYPE_CHUNK = "http://kxstudio.sf.net/ns/carla/chunk";
  274. /*!
  275. * String type URI.
  276. */
  277. const char* const CUSTOM_DATA_TYPE_STRING = "http://kxstudio.sf.net/ns/carla/string";
  278. /** @} */
  279. // ------------------------------------------------------------------------------------------------------------
  280. // Custom Data Keys
  281. /*!
  282. * @defgroup CustomDataKeys Custom Data Keys
  283. *
  284. * Pre-defined keys used internally in Carla.
  285. * @see CustomData::key
  286. * @{
  287. */
  288. /*!
  289. * Plugin options key.
  290. */
  291. const char* const CUSTOM_DATA_KEY_PLUGIN_OPTIONS = "CarlaPluginOptions";
  292. /*!
  293. * UI position key.
  294. */
  295. const char* const CUSTOM_DATA_KEY_UI_POSITION = "CarlaUiPosition";
  296. /*!
  297. * UI size key.
  298. */
  299. const char* const CUSTOM_DATA_KEY_UI_SIZE = "CarlaUiSize";
  300. /*!
  301. * UI visible key.
  302. */
  303. const char* const CUSTOM_DATA_KEY_UI_VISIBLE = "CarlaUiVisible";
  304. /** @} */
  305. // ------------------------------------------------------------------------------------------------------------
  306. // Binary Type
  307. /*!
  308. * The binary type of a plugin.
  309. */
  310. typedef enum {
  311. /*!
  312. * Null binary type.
  313. */
  314. BINARY_NONE = 0,
  315. /*!
  316. * POSIX 32bit binary.
  317. */
  318. BINARY_POSIX32 = 1,
  319. /*!
  320. * POSIX 64bit binary.
  321. */
  322. BINARY_POSIX64 = 2,
  323. /*!
  324. * Windows 32bit binary.
  325. */
  326. BINARY_WIN32 = 3,
  327. /*!
  328. * Windows 64bit binary.
  329. */
  330. BINARY_WIN64 = 4,
  331. /*!
  332. * Other binary type.
  333. */
  334. BINARY_OTHER = 5
  335. } BinaryType;
  336. // ------------------------------------------------------------------------------------------------------------
  337. // Plugin Type
  338. /*!
  339. * Plugin type.
  340. * Some files are handled as if they were plugins.
  341. */
  342. typedef enum {
  343. /*!
  344. * Null plugin type.
  345. */
  346. PLUGIN_NONE = 0,
  347. /*!
  348. * Internal plugin.
  349. */
  350. PLUGIN_INTERNAL = 1,
  351. /*!
  352. * LADSPA plugin.
  353. */
  354. PLUGIN_LADSPA = 2,
  355. /*!
  356. * DSSI plugin.
  357. */
  358. PLUGIN_DSSI = 3,
  359. /*!
  360. * LV2 plugin.
  361. */
  362. PLUGIN_LV2 = 4,
  363. /*!
  364. * VST plugin.
  365. */
  366. PLUGIN_VST = 5,
  367. /*!
  368. * AU plugin.
  369. * @note MacOS only
  370. */
  371. PLUGIN_AU = 6,
  372. /*!
  373. * Csound file.
  374. */
  375. PLUGIN_CSOUND = 7,
  376. /*!
  377. * GIG file.
  378. */
  379. PLUGIN_GIG = 8,
  380. /*!
  381. * SF2 file (also known as SoundFont).
  382. */
  383. PLUGIN_SF2 = 9,
  384. /*!
  385. * SFZ file.
  386. */
  387. PLUGIN_SFZ = 10
  388. } PluginType;
  389. // ------------------------------------------------------------------------------------------------------------
  390. // Plugin Category
  391. /*!
  392. * Plugin category, which describes the functionality of a plugin.
  393. */
  394. typedef enum {
  395. /*!
  396. * Null plugin category.
  397. */
  398. PLUGIN_CATEGORY_NONE = 0,
  399. /*!
  400. * A synthesizer or generator.
  401. */
  402. PLUGIN_CATEGORY_SYNTH = 1,
  403. /*!
  404. * A delay or reverb.
  405. */
  406. PLUGIN_CATEGORY_DELAY = 2,
  407. /*!
  408. * An equalizer.
  409. */
  410. PLUGIN_CATEGORY_EQ = 3,
  411. /*!
  412. * A filter.
  413. */
  414. PLUGIN_CATEGORY_FILTER = 4,
  415. /*!
  416. * A distortion plugin.
  417. */
  418. PLUGIN_CATEGORY_DISTORTION = 5,
  419. /*!
  420. * A 'dynamic' plugin (amplifier, compressor, gate, etc).
  421. */
  422. PLUGIN_CATEGORY_DYNAMICS = 6,
  423. /*!
  424. * A 'modulator' plugin (chorus, flanger, phaser, etc).
  425. */
  426. PLUGIN_CATEGORY_MODULATOR = 7,
  427. /*!
  428. * An 'utility' plugin (analyzer, converter, mixer, etc).
  429. */
  430. PLUGIN_CATEGORY_UTILITY = 8,
  431. /*!
  432. * Miscellaneous plugin (used to check if the plugin has a category).
  433. */
  434. PLUGIN_CATEGORY_OTHER = 9
  435. } PluginCategory;
  436. // ------------------------------------------------------------------------------------------------------------
  437. // Internal Parameter Index
  438. /*!
  439. * Special parameters used internally in Carla.\n
  440. * Plugins do not know about their existence.
  441. */
  442. typedef enum {
  443. /*!
  444. * Null parameter.
  445. */
  446. PARAMETER_NULL = -1,
  447. /*!
  448. * Active parameter, boolean type.\n
  449. * Default is 'false'.
  450. */
  451. PARAMETER_ACTIVE = -2,
  452. /*!
  453. * Dry/Wet parameter.\n
  454. * Range 0.0...1.0; default is 1.0.
  455. */
  456. PARAMETER_DRYWET = -3,
  457. /*!
  458. * Volume parameter.\n
  459. * Range 0.0...1.27; default is 1.0.
  460. */
  461. PARAMETER_VOLUME = -4,
  462. /*!
  463. * Stereo Balance-Left parameter.\n
  464. * Range -1.0...1.0; default is -1.0.
  465. */
  466. PARAMETER_BALANCE_LEFT = -5,
  467. /*!
  468. * Stereo Balance-Right parameter.\n
  469. * Range -1.0...1.0; default is 1.0.
  470. */
  471. PARAMETER_BALANCE_RIGHT = -6,
  472. /*!
  473. * Mono Panning parameter.\n
  474. * Range -1.0...1.0; default is 0.0.
  475. */
  476. PARAMETER_PANNING = -7,
  477. /*!
  478. * MIDI Control channel, integer type.\n
  479. * Range -1...15 (-1 = off).
  480. */
  481. PARAMETER_CTRL_CHANNEL = -8,
  482. /*!
  483. * Max value, defined only for convenience.
  484. */
  485. PARAMETER_MAX = -9
  486. } InternalParameterIndex;
  487. // ------------------------------------------------------------------------------------------------------------
  488. // Engine Callback Opcode
  489. /*!
  490. * Engine callback opcodes.\n
  491. * Front-ends must never block indefinitely during a callback.
  492. * @see EngineCallbackFunc, CarlaEngine::setCallback() and carla_set_engine_callback()
  493. */
  494. typedef enum {
  495. /*!
  496. * Debug.\n
  497. * This opcode is undefined and used only for testing purposes.
  498. */
  499. ENGINE_CALLBACK_DEBUG = 0,
  500. /*!
  501. * A plugin has been added.
  502. * @param pluginId Plugin Id
  503. * @param valueStr Plugin name
  504. */
  505. ENGINE_CALLBACK_PLUGIN_ADDED = 1,
  506. /*!
  507. * A plugin has been removed.
  508. * @param pluginId Plugin Id
  509. */
  510. ENGINE_CALLBACK_PLUGIN_REMOVED = 2,
  511. /*!
  512. * A plugin has been renamed.
  513. * @param pluginId Plugin Id
  514. * @param valueStr New plugin name
  515. */
  516. ENGINE_CALLBACK_PLUGIN_RENAMED = 3,
  517. /*!
  518. * A plugin has become unavailable.
  519. * @param pluginId Plugin Id
  520. * @param valueStr Related error string
  521. */
  522. ENGINE_CALLBACK_PLUGIN_UNAVAILABLE = 4,
  523. /*!
  524. * A parameter value has changed.
  525. * @param pluginId Plugin Id
  526. * @param value1 Parameter index
  527. * @param value3 New parameter value
  528. */
  529. ENGINE_CALLBACK_PARAMETER_VALUE_CHANGED = 5,
  530. /*!
  531. * A parameter default has changed.
  532. * @param pluginId Plugin Id
  533. * @param value1 Parameter index
  534. * @param value3 New default value
  535. */
  536. ENGINE_CALLBACK_PARAMETER_DEFAULT_CHANGED = 6,
  537. /*!
  538. * A parameter's MIDI CC has changed.
  539. * @param pluginId Plugin Id
  540. * @param value1 Parameter index
  541. * @param value2 New MIDI CC
  542. */
  543. ENGINE_CALLBACK_PARAMETER_MIDI_CC_CHANGED = 7,
  544. /*!
  545. * A parameter's MIDI channel has changed.
  546. * @param pluginId Plugin Id
  547. * @param value1 Parameter index
  548. * @param value2 New MIDI channel
  549. */
  550. ENGINE_CALLBACK_PARAMETER_MIDI_CHANNEL_CHANGED = 8,
  551. /*!
  552. * The current program of a plugin has changed.
  553. * @param pluginId Plugin Id
  554. * @param value1 New program index
  555. */
  556. ENGINE_CALLBACK_PROGRAM_CHANGED = 9,
  557. /*!
  558. * The current MIDI program of a plugin has changed.
  559. * @param pluginId Plugin Id
  560. * @param value1 New MIDI bank
  561. * @param value2 New MIDI program
  562. */
  563. ENGINE_CALLBACK_MIDI_PROGRAM_CHANGED = 10,
  564. /*!
  565. * A plugin's custom UI state has changed.
  566. * @param pluginId Plugin Id
  567. * @param value1 New state, as follows:\n
  568. * 0: UI is now hidden\n
  569. * 1: UI is now visible\n
  570. * -1: UI has crashed and should not be shown again
  571. */
  572. ENGINE_CALLBACK_UI_STATE_CHANGED = 11,
  573. /*!
  574. * A note has been pressed.
  575. * @param pluginId Plugin Id
  576. * @param value1 Channel
  577. * @param value2 Note
  578. * @param value3 Velocity
  579. */
  580. ENGINE_CALLBACK_NOTE_ON = 12,
  581. /*!
  582. * A note has been released.
  583. * @param pluginId Plugin Id
  584. * @param value1 Channel
  585. * @param value2 Note
  586. */
  587. ENGINE_CALLBACK_NOTE_OFF = 13,
  588. /*!
  589. * A plugin needs update.
  590. * @param pluginId Plugin Id
  591. */
  592. ENGINE_CALLBACK_UPDATE = 14,
  593. /*!
  594. * A plugin's data/information has changed.
  595. * @param pluginId Plugin Id
  596. */
  597. ENGINE_CALLBACK_RELOAD_INFO = 15,
  598. /*!
  599. * A plugin's parameters have changed.
  600. * @param pluginId Plugin Id
  601. */
  602. ENGINE_CALLBACK_RELOAD_PARAMETERS = 16,
  603. /*!
  604. * A plugin's programs have changed.
  605. * @param pluginId Plugin Id
  606. */
  607. ENGINE_CALLBACK_RELOAD_PROGRAMS = 17,
  608. /*!
  609. * A plugin state has changed.
  610. * @param pluginId Plugin Id
  611. */
  612. ENGINE_CALLBACK_RELOAD_ALL = 18,
  613. /*!
  614. * A patchbay client has been added.
  615. * @param pluginId Client Id
  616. * @param valueStr Client name and icon, as "name:icon"
  617. */
  618. ENGINE_CALLBACK_PATCHBAY_CLIENT_ADDED = 19,
  619. /*!
  620. * A patchbay client has been removed.
  621. * @param pluginId Client Id
  622. */
  623. ENGINE_CALLBACK_PATCHBAY_CLIENT_REMOVED = 20,
  624. /*!
  625. * A patchbay client has been renamed.
  626. * @param pluginId Client Id
  627. * @param valueStr New client name
  628. */
  629. ENGINE_CALLBACK_PATCHBAY_CLIENT_RENAMED = 21,
  630. /*!
  631. * A patchbay client icon has changed.
  632. * @param pluginId Client Id
  633. * @param valueStr New icon name
  634. */
  635. ENGINE_CALLBACK_PATCHBAY_CLIENT_ICON_CHANGED = 22,
  636. /*!
  637. * A patchbay port has been added.
  638. * @param pluginId Client Id
  639. * @param value1 Port Id
  640. * @param value2 Port hints
  641. * @param valueStr Port name
  642. * @see PatchbayPortHints
  643. */
  644. ENGINE_CALLBACK_PATCHBAY_PORT_ADDED = 23,
  645. /*!
  646. * A patchbay port has been removed.
  647. * @param pluginId Client Id
  648. * @param value1 Port Id
  649. */
  650. ENGINE_CALLBACK_PATCHBAY_PORT_REMOVED = 24,
  651. /*!
  652. * A patchbay port has been renamed.
  653. * @param pluginId Client Id
  654. * @param value1 Port Id
  655. * @param valueStr New port name
  656. */
  657. ENGINE_CALLBACK_PATCHBAY_PORT_RENAMED = 25,
  658. /*!
  659. * A patchbay connection has been added.
  660. * @param value1 Output port Id
  661. * @param value2 Input port Id
  662. */
  663. ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED = 26,
  664. /*!
  665. * A patchbay connection has been removed.
  666. * @param value1 Output port Id
  667. * @param value2 Input port Id
  668. */
  669. ENGINE_CALLBACK_PATCHBAY_CONNECTION_REMOVED = 27,
  670. /*!
  671. * Engine started.
  672. * @param value1 Process mode
  673. * @param value2 Transport mode
  674. * @param valuestr Engine driver
  675. * @see EngineProcessMode
  676. * @see EngineTransportMode
  677. */
  678. ENGINE_CALLBACK_ENGINE_STARTED = 28,
  679. /*!
  680. * Engine stopped.
  681. */
  682. ENGINE_CALLBACK_ENGINE_STOPPED = 29,
  683. /*!
  684. * Engine process mode has changed.
  685. * @param value1 New process mode
  686. * @see EngineProcessMode
  687. */
  688. ENGINE_CALLBACK_PROCESS_MODE_CHANGED = 30,
  689. /*!
  690. * Engine transport mode has changed.
  691. * @param value1 New transport mode
  692. * @see EngineTransportMode
  693. */
  694. ENGINE_CALLBACK_TRANSPORT_MODE_CHANGED = 31,
  695. /*!
  696. * Engine buffer-size changed.
  697. * @param value1 New buffer size
  698. */
  699. ENGINE_CALLBACK_BUFFER_SIZE_CHANGED = 32,
  700. /*!
  701. * Engine sample-rate changed.
  702. * @param value3 New sample rate
  703. */
  704. ENGINE_CALLBACK_SAMPLE_RATE_CHANGED = 33,
  705. /*!
  706. * Show a message as information.
  707. * @param valueStr The message
  708. */
  709. ENGINE_CALLBACK_INFO = 34,
  710. /*!
  711. * Show a message as an error.
  712. * @param valueStr The message
  713. */
  714. ENGINE_CALLBACK_ERROR = 35,
  715. /*!
  716. * The engine has crashed or malfunctioned and will no longer work.
  717. */
  718. ENGINE_CALLBACK_QUIT = 36
  719. } EngineCallbackOpcode;
  720. // ------------------------------------------------------------------------------------------------------------
  721. // Engine Option
  722. /*!
  723. * Engine options.
  724. * @see CarlaEngine::getOptions(), CarlaEngine::setOption() and carla_set_engine_option()
  725. */
  726. typedef enum {
  727. /*!
  728. * Debug.\n
  729. * This option is undefined and used only for testing purposes.
  730. */
  731. ENGINE_OPTION_DEBUG = 0,
  732. /*!
  733. * Set the engine processing mode.\n
  734. * Default is ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS on Linux and ENGINE_PROCESS_MODE_CONTINUOUS_RACK for all other OSes.
  735. * @see EngineProcessMode
  736. */
  737. ENGINE_OPTION_PROCESS_MODE = 1,
  738. /*!
  739. * Set the engine transport mode.\n
  740. * Default is ENGINE_TRANSPORT_MODE_JACK on Linux and ENGINE_TRANSPORT_MODE_INTERNAL for all other OSes.
  741. * @see EngineTransportMode
  742. */
  743. ENGINE_OPTION_TRANSPORT_MODE = 2,
  744. /*!
  745. * Force mono plugins as stereo, by running 2 instances at the same time.\n
  746. * Default is false, but always true when process mode is ENGINE_PROCESS_MODE_CONTINUOUS_RACK.
  747. * @note Not supported by all plugins
  748. * @see PLUGIN_OPTION_FORCE_STEREO
  749. */
  750. ENGINE_OPTION_FORCE_STEREO = 3,
  751. /*!
  752. * Use plugin bridges whenever possible.\n
  753. * Default is no, EXPERIMENTAL.
  754. */
  755. ENGINE_OPTION_PREFER_PLUGIN_BRIDGES = 4,
  756. /*!
  757. * Use UI bridges whenever possible, otherwise UIs will be directly handled in the main backend thread.\n
  758. * Default is yes.
  759. */
  760. ENGINE_OPTION_PREFER_UI_BRIDGES = 5,
  761. /*!
  762. * Make custom plugin UIs always-on-top.\n
  763. * Default is yes.
  764. */
  765. ENGINE_OPTION_UIS_ALWAYS_ON_TOP = 6,
  766. /*!
  767. * Maximum number of parameters allowed.\n
  768. * Default is MAX_DEFAULT_PARAMETERS.
  769. */
  770. ENGINE_OPTION_MAX_PARAMETERS = 7,
  771. /*!
  772. * Timeout value for how much to wait for UI bridges to respond, in milliseconds.\n
  773. * Default is 4000 (4 seconds).
  774. */
  775. ENGINE_OPTION_UI_BRIDGES_TIMEOUT = 8,
  776. /*!
  777. * Audio number of periods.\n
  778. * Default is 2.
  779. */
  780. ENGINE_OPTION_AUDIO_NUM_PERIODS = 9,
  781. /*!
  782. * Audio buffer size.\n
  783. * Default is 512.
  784. */
  785. ENGINE_OPTION_AUDIO_BUFFER_SIZE = 10,
  786. /*!
  787. * Audio sample rate.\n
  788. * Default is 44100.
  789. */
  790. ENGINE_OPTION_AUDIO_SAMPLE_RATE = 11,
  791. /*!
  792. * Audio device (within a driver).\n
  793. * Default unset.
  794. */
  795. ENGINE_OPTION_AUDIO_DEVICE = 12,
  796. /*!
  797. * Set path to the binary files.\n
  798. * Default unset.
  799. * @note Must be set for plugin and UI bridges to work
  800. */
  801. ENGINE_OPTION_PATH_BINARIES = 13,
  802. /*!
  803. * Set path to the resource files.\n
  804. * Default unset.
  805. * @note Must be set for some internal plugins to work
  806. */
  807. ENGINE_OPTION_PATH_RESOURCES = 14
  808. } EngineOption;
  809. // ------------------------------------------------------------------------------------------------------------
  810. // Engine Process Mode
  811. /*!
  812. * Engine process mode.
  813. * @see ENGINE_OPTION_PROCESS_MODE
  814. */
  815. typedef enum {
  816. /*!
  817. * Single client mode.\n
  818. * Inputs and outputs are added dynamically as needed by plugins.
  819. */
  820. ENGINE_PROCESS_MODE_SINGLE_CLIENT = 0,
  821. /*!
  822. * Multiple client mode.\n
  823. * It has 1 master client + 1 client per plugin.
  824. */
  825. ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS = 1,
  826. /*!
  827. * Single client, 'rack' mode.\n
  828. * Processes plugins in order of Id, with forced stereo always on.
  829. */
  830. ENGINE_PROCESS_MODE_CONTINUOUS_RACK = 2,
  831. /*!
  832. * Single client, 'patchbay' mode.
  833. */
  834. ENGINE_PROCESS_MODE_PATCHBAY = 3,
  835. /*!
  836. * Special mode, used in plugin-bridges only.
  837. */
  838. ENGINE_PROCESS_MODE_BRIDGE = 4
  839. } EngineProcessMode;
  840. // ------------------------------------------------------------------------------------------------------------
  841. // Engine Transport Mode
  842. /*!
  843. * Engine transport mode.
  844. * @see ENGINE_OPTION_TRANSPORT_MODE
  845. */
  846. typedef enum {
  847. /*!
  848. * Internal transport mode.
  849. */
  850. ENGINE_TRANSPORT_MODE_INTERNAL = 0,
  851. /*!
  852. * Transport from JACK.\n
  853. * Only available if driver name is "JACK".
  854. */
  855. ENGINE_TRANSPORT_MODE_JACK = 1,
  856. /*!
  857. * Transport from host, used when Carla is a plugin.
  858. */
  859. ENGINE_TRANSPORT_MODE_PLUGIN = 2,
  860. /*!
  861. * Special mode, used in plugin-bridges only.
  862. */
  863. ENGINE_TRANSPORT_MODE_BRIDGE = 3
  864. } EngineTransportMode;
  865. // ------------------------------------------------------------------------------------------------------------
  866. // Carla Backend API (C stuff)
  867. /*!
  868. * Engine callback function.\n
  869. * Front-ends must never block indefinitely during a callback.
  870. * @see EngineCallbackOpcode, CarlaEngine::setCallback() and carla_set_engine_callback()
  871. */
  872. typedef void (*EngineCallbackFunc)(void* ptr, EngineCallbackOpcode action, uint pluginId, int value1, int value2, float value3, const char* valueStr);
  873. /*!
  874. * Parameter data.
  875. */
  876. typedef struct _ParameterData {
  877. /*!
  878. * Index as seen by Carla.
  879. */
  880. int32_t index;
  881. /*!
  882. * Real index as seen by plugins.
  883. */
  884. int32_t rindex;
  885. /*!
  886. * This parameter hints.
  887. * @see ParameterHints
  888. */
  889. unsigned int hints;
  890. /*!
  891. * Currently mapped MIDI CC.\n
  892. * A value lower than 0 means invalid or unused.\n
  893. * Maximum allowed value is 95 (0x5F).
  894. */
  895. int16_t midiCC;
  896. /*!
  897. * Currently mapped MIDI channel.\n
  898. * Counts from 0 to 15.
  899. */
  900. uint8_t midiChannel;
  901. #ifdef __cplusplus
  902. /*!
  903. * C++ constructor.
  904. */
  905. _ParameterData() noexcept
  906. : index(PARAMETER_NULL),
  907. rindex(-1),
  908. hints(0x0),
  909. midiCC(-1),
  910. midiChannel(0) {}
  911. #endif
  912. } ParameterData;
  913. /*!
  914. * Parameter ranges.
  915. */
  916. typedef struct _ParameterRanges {
  917. /*!
  918. * Default value.
  919. */
  920. float def;
  921. /*!
  922. * Minimum value.
  923. */
  924. float min;
  925. /*!
  926. * Maximum value.
  927. */
  928. float max;
  929. /*!
  930. * Regular, single step value.
  931. */
  932. float step;
  933. /*!
  934. * Small step value.
  935. */
  936. float stepSmall;
  937. /*!
  938. * Large step value.
  939. */
  940. float stepLarge;
  941. #ifdef __cplusplus
  942. /*!
  943. * C++ constructor.
  944. */
  945. _ParameterRanges() noexcept
  946. : def(0.0f),
  947. min(0.0f),
  948. max(1.0f),
  949. step(0.01f),
  950. stepSmall(0.0001f),
  951. stepLarge(0.1f) {}
  952. /*!
  953. * Fix default value within range.
  954. */
  955. void fixDefault() noexcept
  956. {
  957. fixValue(def);
  958. }
  959. /*!
  960. * Fix a value within range.
  961. */
  962. void fixValue(float& value) const noexcept
  963. {
  964. if (value <= min)
  965. value = min;
  966. else if (value > max)
  967. value = max;
  968. }
  969. /*!
  970. * Get a fixed value within range.
  971. */
  972. float getFixedValue(const float& value) const noexcept
  973. {
  974. if (value <= min)
  975. return min;
  976. if (value >= max)
  977. return max;
  978. return value;
  979. }
  980. /*!
  981. * Get a value normalized to 0.0<->1.0.
  982. */
  983. float getNormalizedValue(const float& value) const noexcept
  984. {
  985. const float normValue((value - min) / (max - min));
  986. if (normValue <= 0.0f)
  987. return 0.0f;
  988. if (normValue >= 1.0f)
  989. return 1.0f;
  990. return normValue;
  991. }
  992. /*!
  993. * Get a value normalized to 0.0<->1.0, fixed within range.
  994. */
  995. float getFixedAndNormalizedValue(const float& value) const noexcept
  996. {
  997. if (value <= min)
  998. return 0.0f;
  999. if (value >= max)
  1000. return 1.0f;
  1001. const float normValue((value - min) / (max - min));
  1002. if (normValue <= 0.0f)
  1003. return 0.0f;
  1004. if (normValue >= 1.0f)
  1005. return 1.0f;
  1006. return normValue;
  1007. }
  1008. /*!
  1009. * Get a proper value previously normalized to 0.0<->1.0.
  1010. */
  1011. float getUnnormalizedValue(const float& value) const noexcept
  1012. {
  1013. return value * (max - min) + min;
  1014. }
  1015. #endif
  1016. } ParameterRanges;
  1017. /*!
  1018. * MIDI Program data.
  1019. */
  1020. typedef struct _MidiProgramData {
  1021. /*!
  1022. * MIDI bank.
  1023. */
  1024. uint32_t bank;
  1025. /*!
  1026. * MIDI program.
  1027. */
  1028. uint32_t program;
  1029. /*!
  1030. * MIDI program name.
  1031. */
  1032. const char* name;
  1033. #ifdef __cplusplus
  1034. /*!
  1035. * C++ constructor.
  1036. */
  1037. _MidiProgramData() noexcept
  1038. : bank(0),
  1039. program(0),
  1040. name(nullptr) {}
  1041. #endif
  1042. } MidiProgramData;
  1043. /*!
  1044. * Custom data, used for saving key:value 'dictionaries'.
  1045. */
  1046. typedef struct _CustomData {
  1047. /*!
  1048. * Value type, in URI form.
  1049. * @see CustomDataTypes
  1050. */
  1051. const char* type;
  1052. /*!
  1053. * Key.
  1054. * @see CustomDataKeys
  1055. */
  1056. const char* key;
  1057. /*!
  1058. * Value.
  1059. */
  1060. const char* value;
  1061. #ifdef __cplusplus
  1062. /*!
  1063. * C++ constructor.
  1064. */
  1065. _CustomData() noexcept
  1066. : type(nullptr),
  1067. key(nullptr),
  1068. value(nullptr) {}
  1069. #endif
  1070. } CustomData;
  1071. /*!
  1072. * Engine driver device information.
  1073. */
  1074. typedef struct _EngineDriverDeviceInfo {
  1075. /*!
  1076. * This driver device hints.
  1077. * @see EngineDriverHints
  1078. */
  1079. unsigned int hints;
  1080. /*!
  1081. * Available buffer sizes.\n
  1082. * Terminated with 0.
  1083. */
  1084. const uint32_t* bufferSizes;
  1085. /*!
  1086. * Available sample rates.\n
  1087. * Terminated with 0.0.
  1088. */
  1089. const double* sampleRates;
  1090. #ifdef __cplusplus
  1091. /*!
  1092. * C++ constructor.
  1093. */
  1094. _EngineDriverDeviceInfo()
  1095. : hints(0x0),
  1096. bufferSizes(nullptr),
  1097. sampleRates(nullptr) {}
  1098. #endif
  1099. } EngineDriverDeviceInfo;
  1100. /** @} */
  1101. #ifdef __cplusplus
  1102. /* Forward declarations of commonly used Carla classes */
  1103. class CarlaEngine;
  1104. class CarlaPlugin;
  1105. /* End namespace */
  1106. CARLA_BACKEND_END_NAMESPACE
  1107. #endif
  1108. #endif /* CARLA_BACKEND_H_INCLUDED */