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.

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