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.

1437 lines
31KB

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