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.

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