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.

1325 lines
28KB

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