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.

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