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.

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