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.

1328 lines
27KB

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