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.

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