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.

1484 lines
32KB

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