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.

1895 lines
42KB

  1. /*
  2. * Carla Plugin Host
  3. * Copyright (C) 2011-2020 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. # include <algorithm>
  31. # include <cmath>
  32. # include <limits>
  33. /* Start namespace */
  34. CARLA_BACKEND_START_NAMESPACE
  35. #endif
  36. /*!
  37. * @defgroup CarlaBackendAPI Carla Backend API
  38. *
  39. * The Carla Backend API.
  40. *
  41. * These are the base definitions for everything in the Carla backend code.
  42. * @{
  43. */
  44. /* ------------------------------------------------------------------------------------------------------------
  45. * Carla Backend API (base definitions) */
  46. /*!
  47. * Maximum default number of loadable plugins.
  48. */
  49. static const uint MAX_DEFAULT_PLUGINS = 512;
  50. /*!
  51. * Maximum number of loadable plugins in rack mode.
  52. */
  53. static const uint MAX_RACK_PLUGINS = 64;
  54. /*!
  55. * Maximum number of loadable plugins in patchbay mode.
  56. */
  57. static const uint MAX_PATCHBAY_PLUGINS = 255;
  58. /*!
  59. * Maximum default number of parameters allowed.
  60. * @see ENGINE_OPTION_MAX_PARAMETERS
  61. */
  62. static const uint MAX_DEFAULT_PARAMETERS = 200;
  63. /*!
  64. * The "plugin Id" for the global Carla instance.
  65. * Currently only used for audio peaks.
  66. */
  67. static const uint MAIN_CARLA_PLUGIN_ID = 0xFFFF;
  68. /* ------------------------------------------------------------------------------------------------------------
  69. * Engine Driver Device Hints */
  70. /*!
  71. * @defgroup EngineDriverHints Engine Driver Device Hints
  72. *
  73. * Various engine driver device hints.
  74. * @see CarlaEngine::getHints(), CarlaEngine::getDriverDeviceInfo() and carla_get_engine_driver_device_info()
  75. * @{
  76. */
  77. /*!
  78. * Engine driver device has custom control-panel.
  79. */
  80. static const uint ENGINE_DRIVER_DEVICE_HAS_CONTROL_PANEL = 0x1;
  81. /*!
  82. * Engine driver device can use a triple-buffer (3 number of periods instead of the usual 2).
  83. * @see ENGINE_OPTION_AUDIO_NUM_PERIODS
  84. */
  85. static const uint ENGINE_DRIVER_DEVICE_CAN_TRIPLE_BUFFER = 0x2;
  86. /*!
  87. * Engine driver device can change buffer-size on the fly.
  88. * @see ENGINE_OPTION_AUDIO_BUFFER_SIZE
  89. */
  90. static const uint ENGINE_DRIVER_DEVICE_VARIABLE_BUFFER_SIZE = 0x4;
  91. /*!
  92. * Engine driver device can change sample-rate on the fly.
  93. * @see ENGINE_OPTION_AUDIO_SAMPLE_RATE
  94. */
  95. static const uint ENGINE_DRIVER_DEVICE_VARIABLE_SAMPLE_RATE = 0x8;
  96. /** @} */
  97. /* ------------------------------------------------------------------------------------------------------------
  98. * Plugin Hints */
  99. /*!
  100. * @defgroup PluginHints Plugin Hints
  101. *
  102. * Various plugin hints.
  103. * @see CarlaPlugin::getHints() and carla_get_plugin_info()
  104. * @{
  105. */
  106. /*!
  107. * Plugin is a bridge.
  108. * This hint is required because "bridge" itself is not a plugin type.
  109. */
  110. static const uint PLUGIN_IS_BRIDGE = 0x001;
  111. /*!
  112. * Plugin is hard real-time safe.
  113. */
  114. static const uint PLUGIN_IS_RTSAFE = 0x002;
  115. /*!
  116. * Plugin is a synth (produces sound).
  117. */
  118. static const uint PLUGIN_IS_SYNTH = 0x004;
  119. /*!
  120. * Plugin has its own custom UI.
  121. * @see CarlaPlugin::showCustomUI() and carla_show_custom_ui()
  122. */
  123. static const uint PLUGIN_HAS_CUSTOM_UI = 0x008;
  124. /*!
  125. * Plugin can use internal Dry/Wet control.
  126. */
  127. static const uint PLUGIN_CAN_DRYWET = 0x010;
  128. /*!
  129. * Plugin can use internal Volume control.
  130. */
  131. static const uint PLUGIN_CAN_VOLUME = 0x020;
  132. /*!
  133. * Plugin can use internal (Stereo) Balance controls.
  134. */
  135. static const uint PLUGIN_CAN_BALANCE = 0x040;
  136. /*!
  137. * Plugin can use internal (Mono) Panning control.
  138. */
  139. static const uint PLUGIN_CAN_PANNING = 0x080;
  140. /*!
  141. * Plugin needs a constant, fixed-size audio buffer.
  142. */
  143. static const uint PLUGIN_NEEDS_FIXED_BUFFERS = 0x100;
  144. /*!
  145. * Plugin needs to receive all UI events in the main thread.
  146. */
  147. static const uint PLUGIN_NEEDS_UI_MAIN_THREAD = 0x200;
  148. /*!
  149. * Plugin uses 1 program per MIDI channel.
  150. * @note: Only used in some internal plugins and sf2 files.
  151. */
  152. static const uint PLUGIN_USES_MULTI_PROGS = 0x400;
  153. /*!
  154. * Plugin can make use of inline display API.
  155. */
  156. static const uint PLUGIN_HAS_INLINE_DISPLAY = 0x800;
  157. /*!
  158. * Plugin has its own custom UI which can be embed into another Window.
  159. * @see CarlaPlugin::embedCustomUI() and carla_embed_custom_ui()
  160. * @note This is very experimental and subject to change at this point
  161. */
  162. static const uint PLUGIN_HAS_CUSTOM_EMBED_UI = 0x1000;
  163. /** @} */
  164. /* ------------------------------------------------------------------------------------------------------------
  165. * Plugin Options */
  166. /*!
  167. * @defgroup PluginOptions Plugin Options
  168. *
  169. * Various plugin options.
  170. * @note Do not modify these values, as they are saved as-is in project files.
  171. * @see CarlaPlugin::getOptionsAvailable(), CarlaPlugin::getOptionsEnabled(), carla_get_plugin_info() and carla_set_option()
  172. * @{
  173. */
  174. /*!
  175. * Use constant/fixed-size audio buffers.
  176. */
  177. static const uint PLUGIN_OPTION_FIXED_BUFFERS = 0x001;
  178. /*!
  179. * Force mono plugin as stereo.
  180. */
  181. static const uint PLUGIN_OPTION_FORCE_STEREO = 0x002;
  182. /*!
  183. * Map MIDI programs to plugin programs.
  184. */
  185. static const uint PLUGIN_OPTION_MAP_PROGRAM_CHANGES = 0x004;
  186. /*!
  187. * Use chunks to save and restore data instead of parameter values.
  188. */
  189. static const uint PLUGIN_OPTION_USE_CHUNKS = 0x008;
  190. /*!
  191. * Send MIDI control change events.
  192. */
  193. static const uint PLUGIN_OPTION_SEND_CONTROL_CHANGES = 0x010;
  194. /*!
  195. * Send MIDI channel pressure events.
  196. */
  197. static const uint PLUGIN_OPTION_SEND_CHANNEL_PRESSURE = 0x020;
  198. /*!
  199. * Send MIDI note after-touch events.
  200. */
  201. static const uint PLUGIN_OPTION_SEND_NOTE_AFTERTOUCH = 0x040;
  202. /*!
  203. * Send MIDI pitch-bend events.
  204. */
  205. static const uint PLUGIN_OPTION_SEND_PITCHBEND = 0x080;
  206. /*!
  207. * Send MIDI all-sounds/notes-off events, single note-offs otherwise.
  208. */
  209. static const uint PLUGIN_OPTION_SEND_ALL_SOUND_OFF = 0x100;
  210. /*!
  211. * Send MIDI bank/program changes.
  212. * @note: This option conflicts with PLUGIN_OPTION_MAP_PROGRAM_CHANGES and cannot be used at the same time.
  213. */
  214. static const uint PLUGIN_OPTION_SEND_PROGRAM_CHANGES = 0x200;
  215. /*!
  216. * Special flag to indicate that plugin options are not yet set.
  217. * This flag exists because 0x0 as an option value is a valid one, so we need something else to indicate "null-ness".
  218. */
  219. static const uint PLUGIN_OPTIONS_NULL = 0x10000;
  220. /** @} */
  221. /* ------------------------------------------------------------------------------------------------------------
  222. * Parameter Hints */
  223. /*!
  224. * @defgroup ParameterHints Parameter Hints
  225. *
  226. * Various parameter hints.
  227. * @see CarlaPlugin::getParameterData() and carla_get_parameter_data()
  228. * @{
  229. */
  230. /*!
  231. * Parameter value is boolean.
  232. * It's always at either minimum or maximum value.
  233. */
  234. static const uint PARAMETER_IS_BOOLEAN = 0x001;
  235. /*!
  236. * Parameter value is integer.
  237. */
  238. static const uint PARAMETER_IS_INTEGER = 0x002;
  239. /*!
  240. * Parameter value is logarithmic.
  241. */
  242. static const uint PARAMETER_IS_LOGARITHMIC = 0x004;
  243. /*!
  244. * Parameter is enabled.
  245. * It can be viewed, changed and stored.
  246. */
  247. static const uint PARAMETER_IS_ENABLED = 0x010;
  248. /*!
  249. * Parameter is automable (real-time safe).
  250. */
  251. static const uint PARAMETER_IS_AUTOMABLE = 0x020;
  252. /*!
  253. * Parameter is read-only.
  254. * It cannot be changed.
  255. */
  256. static const uint PARAMETER_IS_READ_ONLY = 0x040;
  257. /*!
  258. * Parameter needs sample rate to work.
  259. * Value and ranges are multiplied by sample rate on usage and divided by sample rate on save.
  260. */
  261. static const uint PARAMETER_USES_SAMPLERATE = 0x100;
  262. /*!
  263. * Parameter uses scale points to define internal values in a meaningful way.
  264. */
  265. static const uint PARAMETER_USES_SCALEPOINTS = 0x200;
  266. /*!
  267. * Parameter uses custom text for displaying its value.
  268. * @see CarlaPlugin::getParameterText() and carla_get_parameter_text()
  269. */
  270. static const uint PARAMETER_USES_CUSTOM_TEXT = 0x400;
  271. /*!
  272. * Parameter can be turned into a CV control.
  273. */
  274. static const uint PARAMETER_CAN_BE_CV_CONTROLLED = 0x800;
  275. /** @} */
  276. /* ------------------------------------------------------------------------------------------------------------
  277. * Patchbay Port Hints */
  278. /*!
  279. * @defgroup PatchbayPortHints Patchbay Port Hints
  280. *
  281. * Various patchbay port hints.
  282. * @{
  283. */
  284. /*!
  285. * Patchbay port is input.
  286. * When this hint is not set, port is assumed to be output.
  287. */
  288. static const uint PATCHBAY_PORT_IS_INPUT = 0x01;
  289. /*!
  290. * Patchbay port is of Audio type.
  291. */
  292. static const uint PATCHBAY_PORT_TYPE_AUDIO = 0x02;
  293. /*!
  294. * Patchbay port is of CV type (Control Voltage).
  295. */
  296. static const uint PATCHBAY_PORT_TYPE_CV = 0x04;
  297. /*!
  298. * Patchbay port is of MIDI type.
  299. */
  300. static const uint PATCHBAY_PORT_TYPE_MIDI = 0x08;
  301. /*!
  302. * Patchbay port is of OSC type.
  303. */
  304. static const uint PATCHBAY_PORT_TYPE_OSC = 0x10;
  305. /** @} */
  306. /* ------------------------------------------------------------------------------------------------------------
  307. * Patchbay Port Group Hints */
  308. /*!
  309. * @defgroup PatchbayPortGroupHints Patchbay Port Group Hints
  310. *
  311. * Various patchbay port group hints.
  312. * @{
  313. */
  314. /*!
  315. * Indicates that this group should be considered the "main" input.
  316. */
  317. static const uint PATCHBAY_PORT_GROUP_MAIN_INPUT = 0x01;
  318. /*!
  319. * Indicates that this group should be considered the "main" output.
  320. */
  321. static const uint PATCHBAY_PORT_GROUP_MAIN_OUTPUT = 0x02;
  322. /*!
  323. * A stereo port group, where the 1st port is left and the 2nd is right.
  324. */
  325. static const uint PATCHBAY_PORT_GROUP_STEREO = 0x04;
  326. /*!
  327. * A mid-side stereo group, where the 1st port is center and the 2nd is side.
  328. */
  329. static const uint PATCHBAY_PORT_GROUP_MID_SIDE = 0x08;
  330. /** @} */
  331. /* ------------------------------------------------------------------------------------------------------------
  332. * Custom Data Types */
  333. /*!
  334. * @defgroup CustomDataTypes Custom Data Types
  335. *
  336. * These types define how the value in the CustomData struct is stored.
  337. * @see CustomData::type
  338. * @{
  339. */
  340. /*!
  341. * Boolean string type URI.
  342. * Only "true" and "false" are valid values.
  343. */
  344. static const char* const CUSTOM_DATA_TYPE_BOOLEAN = "http://kxstudio.sf.net/ns/carla/boolean";
  345. /*!
  346. * Chunk type URI.
  347. */
  348. static const char* const CUSTOM_DATA_TYPE_CHUNK = "http://kxstudio.sf.net/ns/carla/chunk";
  349. /*!
  350. * Property type URI.
  351. */
  352. static const char* const CUSTOM_DATA_TYPE_PROPERTY = "http://kxstudio.sf.net/ns/carla/property";
  353. /*!
  354. * String type URI.
  355. */
  356. static const char* const CUSTOM_DATA_TYPE_STRING = "http://kxstudio.sf.net/ns/carla/string";
  357. /** @} */
  358. /* ------------------------------------------------------------------------------------------------------------
  359. * Custom Data Keys */
  360. /*!
  361. * @defgroup CustomDataKeys Custom Data Keys
  362. *
  363. * Pre-defined keys used internally in Carla.
  364. * @see CustomData::key
  365. * @{
  366. */
  367. /*!
  368. * UI position key.
  369. */
  370. static const char* const CUSTOM_DATA_KEY_UI_POSITION = "CarlaUiPosition";
  371. /*!
  372. * UI size key.
  373. */
  374. static const char* const CUSTOM_DATA_KEY_UI_SIZE = "CarlaUiSize";
  375. /*!
  376. * UI visible key.
  377. */
  378. static const char* const CUSTOM_DATA_KEY_UI_VISIBLE = "CarlaUiVisible";
  379. /** @} */
  380. /* ------------------------------------------------------------------------------------------------------------
  381. * Binary Type */
  382. /*!
  383. * The binary type of a plugin.
  384. */
  385. typedef enum {
  386. /*!
  387. * Null binary type.
  388. */
  389. BINARY_NONE = 0,
  390. /*!
  391. * POSIX 32bit binary.
  392. */
  393. BINARY_POSIX32 = 1,
  394. /*!
  395. * POSIX 64bit binary.
  396. */
  397. BINARY_POSIX64 = 2,
  398. /*!
  399. * Windows 32bit binary.
  400. */
  401. BINARY_WIN32 = 3,
  402. /*!
  403. * Windows 64bit binary.
  404. */
  405. BINARY_WIN64 = 4,
  406. /*!
  407. * Other binary type.
  408. */
  409. BINARY_OTHER = 5
  410. } BinaryType;
  411. /* ------------------------------------------------------------------------------------------------------------
  412. * File Type */
  413. /*!
  414. * File type.
  415. */
  416. typedef enum {
  417. /*!
  418. * Null file type.
  419. */
  420. FILE_NONE = 0,
  421. /*!
  422. * Audio file.
  423. */
  424. FILE_AUDIO = 1,
  425. /*!
  426. * MIDI file.
  427. */
  428. FILE_MIDI = 2
  429. } FileType;
  430. /* ------------------------------------------------------------------------------------------------------------
  431. * Plugin Type */
  432. /*!
  433. * Plugin type.
  434. * Some files are handled as if they were plugins.
  435. */
  436. typedef enum {
  437. /*!
  438. * Null plugin type.
  439. */
  440. PLUGIN_NONE = 0,
  441. /*!
  442. * Internal plugin.
  443. */
  444. PLUGIN_INTERNAL = 1,
  445. /*!
  446. * LADSPA plugin.
  447. */
  448. PLUGIN_LADSPA = 2,
  449. /*!
  450. * DSSI plugin.
  451. */
  452. PLUGIN_DSSI = 3,
  453. /*!
  454. * LV2 plugin.
  455. */
  456. PLUGIN_LV2 = 4,
  457. /*!
  458. * VST2 plugin.
  459. */
  460. PLUGIN_VST2 = 5,
  461. /*!
  462. * VST3 plugin.
  463. * @note Windows and MacOS only
  464. */
  465. PLUGIN_VST3 = 6,
  466. /*!
  467. * AU plugin.
  468. * @note MacOS only
  469. */
  470. PLUGIN_AU = 7,
  471. /*!
  472. * DLS file.
  473. */
  474. PLUGIN_DLS = 8,
  475. /*!
  476. * GIG file.
  477. */
  478. PLUGIN_GIG = 9,
  479. /*!
  480. * SF2/3 file (SoundFont).
  481. */
  482. PLUGIN_SF2 = 10,
  483. /*!
  484. * SFZ file.
  485. */
  486. PLUGIN_SFZ = 11,
  487. /*!
  488. * JACK application.
  489. */
  490. PLUGIN_JACK = 12
  491. } PluginType;
  492. /* ------------------------------------------------------------------------------------------------------------
  493. * Plugin Category */
  494. /*!
  495. * Plugin category, which describes the functionality of a plugin.
  496. */
  497. typedef enum {
  498. /*!
  499. * Null plugin category.
  500. */
  501. PLUGIN_CATEGORY_NONE = 0,
  502. /*!
  503. * A synthesizer or generator.
  504. */
  505. PLUGIN_CATEGORY_SYNTH = 1,
  506. /*!
  507. * A delay or reverb.
  508. */
  509. PLUGIN_CATEGORY_DELAY = 2,
  510. /*!
  511. * An equalizer.
  512. */
  513. PLUGIN_CATEGORY_EQ = 3,
  514. /*!
  515. * A filter.
  516. */
  517. PLUGIN_CATEGORY_FILTER = 4,
  518. /*!
  519. * A distortion plugin.
  520. */
  521. PLUGIN_CATEGORY_DISTORTION = 5,
  522. /*!
  523. * A 'dynamic' plugin (amplifier, compressor, gate, etc).
  524. */
  525. PLUGIN_CATEGORY_DYNAMICS = 6,
  526. /*!
  527. * A 'modulator' plugin (chorus, flanger, phaser, etc).
  528. */
  529. PLUGIN_CATEGORY_MODULATOR = 7,
  530. /*!
  531. * An 'utility' plugin (analyzer, converter, mixer, etc).
  532. */
  533. PLUGIN_CATEGORY_UTILITY = 8,
  534. /*!
  535. * Miscellaneous plugin (used to check if the plugin has a category).
  536. */
  537. PLUGIN_CATEGORY_OTHER = 9
  538. } PluginCategory;
  539. /* ------------------------------------------------------------------------------------------------------------
  540. * Parameter Type */
  541. /*!
  542. * Plugin parameter type.
  543. */
  544. typedef enum {
  545. /*!
  546. * Null parameter type.
  547. */
  548. PARAMETER_UNKNOWN = 0,
  549. /*!
  550. * Input parameter.
  551. */
  552. PARAMETER_INPUT = 1,
  553. /*!
  554. * Output parameter.
  555. */
  556. PARAMETER_OUTPUT = 2
  557. } ParameterType;
  558. /* ------------------------------------------------------------------------------------------------------------
  559. * Internal Parameter Index */
  560. /*!
  561. * Special parameters used internally in Carla.
  562. * Plugins do not know about their existence.
  563. */
  564. typedef enum {
  565. /*!
  566. * Null parameter.
  567. */
  568. PARAMETER_NULL = -1,
  569. #ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
  570. /*!
  571. * Active parameter, boolean type.
  572. * Default is 'false'.
  573. */
  574. PARAMETER_ACTIVE = -2,
  575. /*!
  576. * Dry/Wet parameter.
  577. * Range 0.0...1.0; default is 1.0.
  578. */
  579. PARAMETER_DRYWET = -3,
  580. /*!
  581. * Volume parameter.
  582. * Range 0.0...1.27; default is 1.0.
  583. */
  584. PARAMETER_VOLUME = -4,
  585. /*!
  586. * Stereo Balance-Left parameter.
  587. * Range -1.0...1.0; default is -1.0.
  588. */
  589. PARAMETER_BALANCE_LEFT = -5,
  590. /*!
  591. * Stereo Balance-Right parameter.
  592. * Range -1.0...1.0; default is 1.0.
  593. */
  594. PARAMETER_BALANCE_RIGHT = -6,
  595. /*!
  596. * Mono Panning parameter.
  597. * Range -1.0...1.0; default is 0.0.
  598. */
  599. PARAMETER_PANNING = -7,
  600. /*!
  601. * MIDI Control channel, integer type.
  602. * Range -1...15 (-1 = off).
  603. */
  604. PARAMETER_CTRL_CHANNEL = -8,
  605. #endif
  606. /*!
  607. * Max value, defined only for convenience.
  608. */
  609. PARAMETER_MAX = -9
  610. } InternalParameterIndex;
  611. /* ------------------------------------------------------------------------------------------------------------
  612. * Special Mapped Control Index */
  613. /*!
  614. * Specially designated mapped control indexes.
  615. * Values between 0 and 119 (0x77) are reserved for MIDI CC, which uses direct values.
  616. * @see ParameterData::mappedControlIndex
  617. */
  618. typedef enum {
  619. /*!
  620. * Unused control index, meaning no mapping is enabled.
  621. */
  622. CONTROL_INDEX_NONE = -1,
  623. /*!
  624. * CV control index, meaning the parameter is exposed as CV port.
  625. */
  626. CONTROL_INDEX_CV = 130,
  627. /*!
  628. * Special value to indicate MIDI pitchbend.
  629. */
  630. CONTROL_INDEX_MIDI_PITCHBEND = 131,
  631. /*!
  632. * Special value to indicate MIDI learn.
  633. */
  634. CONTROL_INDEX_MIDI_LEARN = 132,
  635. /*!
  636. * Highest index allowed for mappings.
  637. */
  638. CONTROL_INDEX_MAX_ALLOWED = CONTROL_INDEX_MIDI_LEARN
  639. } SpecialMappedControlIndex;
  640. /* ------------------------------------------------------------------------------------------------------------
  641. * Engine Callback Opcode */
  642. /*!
  643. * Engine callback opcodes.
  644. * Front-ends must never block indefinitely during a callback.
  645. * @see EngineCallbackFunc, CarlaEngine::setCallback() and carla_set_engine_callback()
  646. */
  647. typedef enum {
  648. /*!
  649. * Debug.
  650. * This opcode is undefined and used only for testing purposes.
  651. */
  652. ENGINE_CALLBACK_DEBUG = 0,
  653. /*!
  654. * A plugin has been added.
  655. * @a pluginId Plugin Id
  656. * @a valueStr Plugin name
  657. */
  658. ENGINE_CALLBACK_PLUGIN_ADDED = 1,
  659. /*!
  660. * A plugin has been removed.
  661. * @a pluginId Plugin Id
  662. */
  663. ENGINE_CALLBACK_PLUGIN_REMOVED = 2,
  664. /*!
  665. * A plugin has been renamed.
  666. * @a pluginId Plugin Id
  667. * @a valueStr New plugin name
  668. */
  669. ENGINE_CALLBACK_PLUGIN_RENAMED = 3,
  670. /*!
  671. * A plugin has become unavailable.
  672. * @a pluginId Plugin Id
  673. * @a valueStr Related error string
  674. */
  675. ENGINE_CALLBACK_PLUGIN_UNAVAILABLE = 4,
  676. /*!
  677. * A parameter value has changed.
  678. * @a pluginId Plugin Id
  679. * @a value1 Parameter index
  680. * @a valuef New parameter value
  681. */
  682. ENGINE_CALLBACK_PARAMETER_VALUE_CHANGED = 5,
  683. /*!
  684. * A parameter default has changed.
  685. * @a pluginId Plugin Id
  686. * @a value1 Parameter index
  687. * @a valuef New default value
  688. */
  689. ENGINE_CALLBACK_PARAMETER_DEFAULT_CHANGED = 6,
  690. #ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
  691. /*!
  692. * A parameter's mapped control index has changed.
  693. * @a pluginId Plugin Id
  694. * @a value1 Parameter index
  695. * @a value2 New control index
  696. */
  697. ENGINE_CALLBACK_PARAMETER_MAPPED_CONTROL_INDEX_CHANGED = 7,
  698. /*!
  699. * A parameter's MIDI channel has changed.
  700. * @a pluginId Plugin Id
  701. * @a value1 Parameter index
  702. * @a value2 New MIDI channel
  703. */
  704. ENGINE_CALLBACK_PARAMETER_MIDI_CHANNEL_CHANGED = 8,
  705. /*!
  706. * A plugin option has changed.
  707. * @a pluginId Plugin Id
  708. * @a value1 Option
  709. * @a value2 New on/off state (1 for on, 0 for off)
  710. * @see PluginOptions
  711. */
  712. ENGINE_CALLBACK_OPTION_CHANGED = 9,
  713. #endif
  714. /*!
  715. * The current program of a plugin has changed.
  716. * @a pluginId Plugin Id
  717. * @a value1 New program index
  718. */
  719. ENGINE_CALLBACK_PROGRAM_CHANGED = 10,
  720. /*!
  721. * The current MIDI program of a plugin has changed.
  722. * @a pluginId Plugin Id
  723. * @a value1 New MIDI program index
  724. */
  725. ENGINE_CALLBACK_MIDI_PROGRAM_CHANGED = 11,
  726. /*!
  727. * A plugin's custom UI state has changed.
  728. * @a pluginId Plugin Id
  729. * @a value1 New state, as follows:
  730. * 0: UI is now hidden
  731. * 1: UI is now visible
  732. * -1: UI has crashed and should not be shown again
  733. */
  734. ENGINE_CALLBACK_UI_STATE_CHANGED = 12,
  735. /*!
  736. * A note has been pressed.
  737. * @a pluginId Plugin Id
  738. * @a value1 Channel
  739. * @a value2 Note
  740. * @a value3 Velocity
  741. */
  742. ENGINE_CALLBACK_NOTE_ON = 13,
  743. /*!
  744. * A note has been released.
  745. * @a pluginId Plugin Id
  746. * @a value1 Channel
  747. * @a value2 Note
  748. */
  749. ENGINE_CALLBACK_NOTE_OFF = 14,
  750. /*!
  751. * A plugin needs update.
  752. * @a pluginId Plugin Id
  753. */
  754. ENGINE_CALLBACK_UPDATE = 15,
  755. /*!
  756. * A plugin's data/information has changed.
  757. * @a pluginId Plugin Id
  758. */
  759. ENGINE_CALLBACK_RELOAD_INFO = 16,
  760. /*!
  761. * A plugin's parameters have changed.
  762. * @a pluginId Plugin Id
  763. */
  764. ENGINE_CALLBACK_RELOAD_PARAMETERS = 17,
  765. /*!
  766. * A plugin's programs have changed.
  767. * @a pluginId Plugin Id
  768. */
  769. ENGINE_CALLBACK_RELOAD_PROGRAMS = 18,
  770. /*!
  771. * A plugin state has changed.
  772. * @a pluginId Plugin Id
  773. */
  774. ENGINE_CALLBACK_RELOAD_ALL = 19,
  775. #ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
  776. /*!
  777. * A patchbay client has been added.
  778. * @a pluginId Client Id
  779. * @a value1 Client icon
  780. * @a value2 Plugin Id (-1 if not a plugin)
  781. * @a valueStr Client name
  782. * @see PatchbayIcon
  783. */
  784. ENGINE_CALLBACK_PATCHBAY_CLIENT_ADDED = 20,
  785. /*!
  786. * A patchbay client has been removed.
  787. * @a pluginId Client Id
  788. */
  789. ENGINE_CALLBACK_PATCHBAY_CLIENT_REMOVED = 21,
  790. /*!
  791. * A patchbay client has been renamed.
  792. * @a pluginId Client Id
  793. * @a valueStr New client name
  794. */
  795. ENGINE_CALLBACK_PATCHBAY_CLIENT_RENAMED = 22,
  796. /*!
  797. * A patchbay client data has changed.
  798. * @a pluginId Client Id
  799. * @a value1 New icon
  800. * @a value2 New plugin Id (-1 if not a plugin)
  801. * @see PatchbayIcon
  802. */
  803. ENGINE_CALLBACK_PATCHBAY_CLIENT_DATA_CHANGED = 23,
  804. /*!
  805. * A patchbay port has been added.
  806. * @a pluginId Client Id
  807. * @a value1 Port Id
  808. * @a value2 Port hints
  809. * @a value3 Port group Id (0 for none)
  810. * @a valueStr Port name
  811. * @see PatchbayPortHints
  812. */
  813. ENGINE_CALLBACK_PATCHBAY_PORT_ADDED = 24,
  814. /*!
  815. * A patchbay port has been removed.
  816. * @a pluginId Client Id
  817. * @a value1 Port Id
  818. */
  819. ENGINE_CALLBACK_PATCHBAY_PORT_REMOVED = 25,
  820. /*!
  821. * A patchbay port has changed (like the name or group Id).
  822. * @a pluginId Client Id
  823. * @a value1 Port Id
  824. * @a value2 Port hints
  825. * @a value3 Port group Id (0 for none)
  826. * @a valueStr Port name
  827. */
  828. ENGINE_CALLBACK_PATCHBAY_PORT_CHANGED = 26,
  829. /*!
  830. * A patchbay connection has been added.
  831. * @a pluginId Connection Id
  832. * @a valueStr Out group and port plus in group and port, in "og:op:ig:ip" syntax.
  833. */
  834. ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED = 27,
  835. /*!
  836. * A patchbay connection has been removed.
  837. * @a pluginId Connection Id
  838. */
  839. ENGINE_CALLBACK_PATCHBAY_CONNECTION_REMOVED = 28,
  840. #endif
  841. /*!
  842. * Engine started.
  843. * @a pluginId How many plugins are known to be running
  844. * @a value1 Process mode
  845. * @a value2 Transport mode
  846. * @a value3 Buffer size
  847. * @a valuef Sample rate
  848. * @a valuestr Engine driver
  849. * @see EngineProcessMode
  850. * @see EngineTransportMode
  851. */
  852. ENGINE_CALLBACK_ENGINE_STARTED = 29,
  853. /*!
  854. * Engine stopped.
  855. */
  856. ENGINE_CALLBACK_ENGINE_STOPPED = 30,
  857. /*!
  858. * Engine process mode has changed.
  859. * @a value1 New process mode
  860. * @see EngineProcessMode
  861. */
  862. ENGINE_CALLBACK_PROCESS_MODE_CHANGED = 31,
  863. /*!
  864. * Engine transport mode has changed.
  865. * @a value1 New transport mode
  866. * @a valueStr New transport features enabled
  867. * @see EngineTransportMode
  868. */
  869. ENGINE_CALLBACK_TRANSPORT_MODE_CHANGED = 32,
  870. /*!
  871. * Engine buffer-size changed.
  872. * @a value1 New buffer size
  873. */
  874. ENGINE_CALLBACK_BUFFER_SIZE_CHANGED = 33,
  875. /*!
  876. * Engine sample-rate changed.
  877. * @a valuef New sample rate
  878. */
  879. ENGINE_CALLBACK_SAMPLE_RATE_CHANGED = 34,
  880. /*!
  881. * A cancelable action has been started or stopped.
  882. * @a pluginId Plugin Id the action relates to, -1 for none
  883. * @a value1 1 for action started, 0 for stopped
  884. * @a valueStr Action name
  885. */
  886. ENGINE_CALLBACK_CANCELABLE_ACTION = 35,
  887. /*!
  888. * Project has finished loading.
  889. */
  890. ENGINE_CALLBACK_PROJECT_LOAD_FINISHED = 36,
  891. /*!
  892. * NSM callback, to be handled by a frontend.
  893. * Frontend must call carla_nsm_ready() with opcode as parameter as a response
  894. * @a value1 NSM opcode
  895. * @a value2 Integer value
  896. * @a valueStr String value
  897. * @see NsmCallbackOpcode
  898. */
  899. ENGINE_CALLBACK_NSM = 37,
  900. /*!
  901. * Idle frontend.
  902. * This is used by the engine during long operations that might block the frontend,
  903. * giving it the possibility to idle while the operation is still in place.
  904. */
  905. ENGINE_CALLBACK_IDLE = 38,
  906. /*!
  907. * Show a message as information.
  908. * @a valueStr The message
  909. */
  910. ENGINE_CALLBACK_INFO = 39,
  911. /*!
  912. * Show a message as an error.
  913. * @a valueStr The message
  914. */
  915. ENGINE_CALLBACK_ERROR = 40,
  916. /*!
  917. * The engine has crashed or malfunctioned and will no longer work.
  918. */
  919. ENGINE_CALLBACK_QUIT = 41,
  920. /*!
  921. * A plugin requested for its inline display to be redrawn.
  922. * @a pluginId Plugin Id to redraw
  923. */
  924. ENGINE_CALLBACK_INLINE_DISPLAY_REDRAW = 42,
  925. /*!
  926. * A patchbay port group has been added.
  927. * @a pluginId Client Id
  928. * @a value1 Group Id (unique value within this client)
  929. * @a value2 Group hints
  930. * @a valueStr Group name
  931. * @see PatchbayPortGroupHints
  932. */
  933. ENGINE_CALLBACK_PATCHBAY_PORT_GROUP_ADDED = 43,
  934. /*!
  935. * A patchbay port group has been removed.
  936. * @a pluginId Client Id
  937. * @a value1 Group Id
  938. */
  939. ENGINE_CALLBACK_PATCHBAY_PORT_GROUP_REMOVED = 44,
  940. /*!
  941. * A patchbay port group has changed.
  942. * @a pluginId Client Id
  943. * @a value1 Group Id
  944. * @a value2 Group hints
  945. * @a valueStr Group name
  946. * @see PatchbayPortGroupHints
  947. */
  948. ENGINE_CALLBACK_PATCHBAY_PORT_GROUP_CHANGED = 45,
  949. /*!
  950. * A parameter's mapped range has changed.
  951. * @a pluginId Plugin Id
  952. * @a value1 Parameter index
  953. * @a valueStr New mapped range as "%f:%f" syntax
  954. */
  955. ENGINE_CALLBACK_PARAMETER_MAPPED_RANGE_CHANGED = 46,
  956. /*!
  957. * A patchbay client position has changed.
  958. * @a pluginId Client Id
  959. * @a value1 X position 1
  960. * @a value2 Y position 1
  961. * @a value3 X position 2
  962. * @a valuef Y position 2
  963. */
  964. ENGINE_CALLBACK_PATCHBAY_CLIENT_POSITION_CHANGED = 47,
  965. /*!
  966. * A plugin embed UI has been resized.
  967. * @a pluginId Plugin Id to resize
  968. * @a value1 New width
  969. * @a value2 New height
  970. */
  971. ENGINE_CALLBACK_EMBED_UI_RESIZED = 48,
  972. } EngineCallbackOpcode;
  973. /* ------------------------------------------------------------------------------------------------------------
  974. * NSM Callback Opcode */
  975. /*!
  976. * NSM callback opcodes.
  977. * @see ENGINE_CALLBACK_NSM
  978. */
  979. typedef enum {
  980. /*!
  981. * NSM is available and initialized.
  982. */
  983. NSM_CALLBACK_INIT = 0,
  984. /*!
  985. * Error from NSM side.
  986. * @a valueInt Error code
  987. * @a valueStr Error string
  988. */
  989. NSM_CALLBACK_ERROR = 1,
  990. /*!
  991. * Announce message.
  992. * @a valueInt SM Flags (WIP, to be defined)
  993. * @a valueStr SM Name
  994. */
  995. NSM_CALLBACK_ANNOUNCE = 2,
  996. /*!
  997. * Open message.
  998. * @a valueStr Project filename
  999. */
  1000. NSM_CALLBACK_OPEN = 3,
  1001. /*!
  1002. * Save message.
  1003. */
  1004. NSM_CALLBACK_SAVE = 4,
  1005. /*!
  1006. * Session-is-loaded message.
  1007. */
  1008. NSM_CALLBACK_SESSION_IS_LOADED = 5,
  1009. /*!
  1010. * Show-optional-gui message.
  1011. */
  1012. NSM_CALLBACK_SHOW_OPTIONAL_GUI = 6,
  1013. /*!
  1014. * Hide-optional-gui message.
  1015. */
  1016. NSM_CALLBACK_HIDE_OPTIONAL_GUI = 7
  1017. } NsmCallbackOpcode;
  1018. /* ------------------------------------------------------------------------------------------------------------
  1019. * Engine Option */
  1020. /*!
  1021. * Engine options.
  1022. * @see CarlaEngine::getOptions(), CarlaEngine::setOption() and carla_set_engine_option()
  1023. */
  1024. typedef enum {
  1025. /*!
  1026. * Debug.
  1027. * This option is undefined and used only for testing purposes.
  1028. */
  1029. ENGINE_OPTION_DEBUG = 0,
  1030. /*!
  1031. * Set the engine processing mode.
  1032. * Default is ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS on Linux and ENGINE_PROCESS_MODE_PATCHBAY for all other OSes.
  1033. * @see EngineProcessMode
  1034. */
  1035. ENGINE_OPTION_PROCESS_MODE = 1,
  1036. /*!
  1037. * Set the engine transport mode.
  1038. * Default is ENGINE_TRANSPORT_MODE_JACK on Linux and ENGINE_TRANSPORT_MODE_INTERNAL for all other OSes.
  1039. * @see EngineTransportMode
  1040. */
  1041. ENGINE_OPTION_TRANSPORT_MODE = 2,
  1042. /*!
  1043. * Force mono plugins as stereo, by running 2 instances at the same time.
  1044. * Default is false, but always true when process mode is ENGINE_PROCESS_MODE_CONTINUOUS_RACK.
  1045. * @note Not supported by all plugins
  1046. * @see PLUGIN_OPTION_FORCE_STEREO
  1047. */
  1048. ENGINE_OPTION_FORCE_STEREO = 3,
  1049. /*!
  1050. * Use plugin bridges whenever possible.
  1051. * Default is no, EXPERIMENTAL.
  1052. */
  1053. ENGINE_OPTION_PREFER_PLUGIN_BRIDGES = 4,
  1054. /*!
  1055. * Use UI bridges whenever possible, otherwise UIs will be directly handled in the main backend thread.
  1056. * Default is yes.
  1057. */
  1058. ENGINE_OPTION_PREFER_UI_BRIDGES = 5,
  1059. /*!
  1060. * Make custom plugin UIs always-on-top.
  1061. * Default is yes.
  1062. */
  1063. ENGINE_OPTION_UIS_ALWAYS_ON_TOP = 6,
  1064. /*!
  1065. * Maximum number of parameters allowed.
  1066. * Default is MAX_DEFAULT_PARAMETERS.
  1067. */
  1068. ENGINE_OPTION_MAX_PARAMETERS = 7,
  1069. /*!
  1070. * Reset Xrun counter after project load.
  1071. */
  1072. ENGINE_OPTION_RESET_XRUNS = 8,
  1073. /*!
  1074. * Timeout value for how much to wait for UI bridges to respond, in milliseconds.
  1075. * Default is 4000 (4 seconds).
  1076. */
  1077. ENGINE_OPTION_UI_BRIDGES_TIMEOUT = 9,
  1078. /*!
  1079. * Audio buffer size.
  1080. * Default is 512.
  1081. */
  1082. ENGINE_OPTION_AUDIO_BUFFER_SIZE = 10,
  1083. /*!
  1084. * Audio sample rate.
  1085. * Default is 44100.
  1086. */
  1087. ENGINE_OPTION_AUDIO_SAMPLE_RATE = 11,
  1088. /*!
  1089. * Wherever to use 3 audio periods instead of the default 2.
  1090. * Default is false.
  1091. */
  1092. ENGINE_OPTION_AUDIO_TRIPLE_BUFFER = 12,
  1093. /*!
  1094. * Audio driver.
  1095. * Default depends on platform.
  1096. */
  1097. ENGINE_OPTION_AUDIO_DRIVER = 13,
  1098. /*!
  1099. * Audio device (within a driver).
  1100. * Default unset.
  1101. */
  1102. ENGINE_OPTION_AUDIO_DEVICE = 14,
  1103. /*!
  1104. * Wherever to enable OSC support in the engine.
  1105. */
  1106. ENGINE_OPTION_OSC_ENABLED = 15,
  1107. /*!
  1108. * The network TCP port to use for OSC.
  1109. * A value of 0 means use a random port.
  1110. * A value of < 0 means to not enable the TCP port for OSC.
  1111. * @note Valid ports begin at 1024 and end at 32767 (inclusive)
  1112. */
  1113. ENGINE_OPTION_OSC_PORT_TCP = 16,
  1114. /*!
  1115. * The network UDP port to use for OSC.
  1116. * A value of 0 means use a random port.
  1117. * A value of < 0 means to not enable the UDP port for OSC.
  1118. * @note Disabling this option prevents DSSI UIs from working!
  1119. * @note Valid ports begin at 1024 and end at 32767 (inclusive)
  1120. */
  1121. ENGINE_OPTION_OSC_PORT_UDP = 17,
  1122. /*!
  1123. * Set path used for a specific file type.
  1124. * Uses value as the file format, valueStr as actual path.
  1125. */
  1126. ENGINE_OPTION_FILE_PATH = 18,
  1127. /*!
  1128. * Set path used for a specific plugin type.
  1129. * Uses value as the plugin format, valueStr as actual path.
  1130. * @see PluginType
  1131. */
  1132. ENGINE_OPTION_PLUGIN_PATH = 19,
  1133. /*!
  1134. * Set path to the binary files.
  1135. * Default unset.
  1136. * @note Must be set for plugin and UI bridges to work
  1137. */
  1138. ENGINE_OPTION_PATH_BINARIES = 20,
  1139. /*!
  1140. * Set path to the resource files.
  1141. * Default unset.
  1142. * @note Must be set for some internal plugins to work
  1143. */
  1144. ENGINE_OPTION_PATH_RESOURCES = 21,
  1145. /*!
  1146. * Prevent bad plugin and UI behaviour.
  1147. * @note: Linux only
  1148. */
  1149. ENGINE_OPTION_PREVENT_BAD_BEHAVIOUR = 22,
  1150. /*!
  1151. * Set background color used in the frontend, so backend can do the same for plugin UIs.
  1152. */
  1153. ENGINE_OPTION_FRONTEND_BACKGROUND_COLOR = 23,
  1154. /*!
  1155. * Set foreground color used in the frontend, so backend can do the same for plugin UIs.
  1156. */
  1157. ENGINE_OPTION_FRONTEND_FOREGROUND_COLOR = 24,
  1158. /*!
  1159. * Set UI scaling used in the frontend, so backend can do the same for plugin UIs.
  1160. */
  1161. ENGINE_OPTION_FRONTEND_UI_SCALE = 25,
  1162. /*!
  1163. * Set frontend winId, used to define as parent window for plugin UIs.
  1164. */
  1165. ENGINE_OPTION_FRONTEND_WIN_ID = 26,
  1166. #if !defined(BUILD_BRIDGE_ALTERNATIVE_ARCH) && !defined(CARLA_OS_WIN)
  1167. /*!
  1168. * Set path to wine executable.
  1169. */
  1170. ENGINE_OPTION_WINE_EXECUTABLE = 27,
  1171. /*!
  1172. * Enable automatic wineprefix detection.
  1173. */
  1174. ENGINE_OPTION_WINE_AUTO_PREFIX = 28,
  1175. /*!
  1176. * Fallback wineprefix to use if automatic detection fails or is disabled, and WINEPREFIX is not set.
  1177. */
  1178. ENGINE_OPTION_WINE_FALLBACK_PREFIX = 29,
  1179. /*!
  1180. * Enable realtime priority for Wine application and server threads.
  1181. */
  1182. ENGINE_OPTION_WINE_RT_PRIO_ENABLED = 30,
  1183. /*!
  1184. * Base realtime priority for Wine threads.
  1185. */
  1186. ENGINE_OPTION_WINE_BASE_RT_PRIO = 31,
  1187. /*!
  1188. * Wine server realtime priority.
  1189. */
  1190. ENGINE_OPTION_WINE_SERVER_RT_PRIO = 32,
  1191. #endif
  1192. /*!
  1193. * Capture console output into debug callbacks.
  1194. */
  1195. ENGINE_OPTION_DEBUG_CONSOLE_OUTPUT = 33,
  1196. /*!
  1197. * A prefix to give to all plugin clients created by Carla.
  1198. * Mostly useful for JACK multi-client mode.
  1199. * @note MUST include at least one "." (dot).
  1200. */
  1201. ENGINE_OPTION_CLIENT_NAME_PREFIX = 34
  1202. } EngineOption;
  1203. /* ------------------------------------------------------------------------------------------------------------
  1204. * Engine Process Mode */
  1205. /*!
  1206. * Engine process mode.
  1207. * @see ENGINE_OPTION_PROCESS_MODE
  1208. */
  1209. typedef enum {
  1210. /*!
  1211. * Single client mode.
  1212. * Inputs and outputs are added dynamically as needed by plugins.
  1213. */
  1214. ENGINE_PROCESS_MODE_SINGLE_CLIENT = 0,
  1215. /*!
  1216. * Multiple client mode.
  1217. * It has 1 master client + 1 client per plugin.
  1218. */
  1219. ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS = 1,
  1220. /*!
  1221. * Single client, 'rack' mode.
  1222. * Processes plugins in order of Id, with forced stereo always on.
  1223. */
  1224. ENGINE_PROCESS_MODE_CONTINUOUS_RACK = 2,
  1225. /*!
  1226. * Single client, 'patchbay' mode.
  1227. */
  1228. ENGINE_PROCESS_MODE_PATCHBAY = 3,
  1229. /*!
  1230. * Special mode, used in plugin-bridges only.
  1231. */
  1232. ENGINE_PROCESS_MODE_BRIDGE = 4
  1233. } EngineProcessMode;
  1234. /* ------------------------------------------------------------------------------------------------------------
  1235. * Engine Transport Mode */
  1236. /*!
  1237. * Engine transport mode.
  1238. * @see ENGINE_OPTION_TRANSPORT_MODE
  1239. */
  1240. typedef enum {
  1241. /*!
  1242. * No transport.
  1243. */
  1244. ENGINE_TRANSPORT_MODE_DISABLED = 0,
  1245. /*!
  1246. * Internal transport mode.
  1247. */
  1248. ENGINE_TRANSPORT_MODE_INTERNAL = 1,
  1249. /*!
  1250. * Transport from JACK.
  1251. * Only available if driver name is "JACK".
  1252. */
  1253. ENGINE_TRANSPORT_MODE_JACK = 2,
  1254. /*!
  1255. * Transport from host, used when Carla is a plugin.
  1256. */
  1257. ENGINE_TRANSPORT_MODE_PLUGIN = 3,
  1258. /*!
  1259. * Special mode, used in plugin-bridges only.
  1260. */
  1261. ENGINE_TRANSPORT_MODE_BRIDGE = 4
  1262. } EngineTransportMode;
  1263. /* ------------------------------------------------------------------------------------------------------------
  1264. * File Callback Opcode */
  1265. /*!
  1266. * File callback opcodes.
  1267. * Front-ends must always block-wait for user input.
  1268. * @see FileCallbackFunc, CarlaEngine::setFileCallback() and carla_set_file_callback()
  1269. */
  1270. typedef enum {
  1271. /*!
  1272. * Debug.
  1273. * This opcode is undefined and used only for testing purposes.
  1274. */
  1275. FILE_CALLBACK_DEBUG = 0,
  1276. /*!
  1277. * Open file or folder.
  1278. */
  1279. FILE_CALLBACK_OPEN = 1,
  1280. /*!
  1281. * Save file or folder.
  1282. */
  1283. FILE_CALLBACK_SAVE = 2
  1284. } FileCallbackOpcode;
  1285. /* ------------------------------------------------------------------------------------------------------------
  1286. * Patchbay Icon */
  1287. /*!
  1288. * The icon of a patchbay client/group.
  1289. */
  1290. enum PatchbayIcon {
  1291. /*!
  1292. * Generic application icon.
  1293. * Used for all non-plugin clients that don't have a specific icon.
  1294. */
  1295. PATCHBAY_ICON_APPLICATION = 0,
  1296. /*!
  1297. * Plugin icon.
  1298. * Used for all plugin clients that don't have a specific icon.
  1299. */
  1300. PATCHBAY_ICON_PLUGIN = 1,
  1301. /*!
  1302. * Hardware icon.
  1303. * Used for hardware (audio or MIDI) clients.
  1304. */
  1305. PATCHBAY_ICON_HARDWARE = 2,
  1306. /*!
  1307. * Carla icon.
  1308. * Used for the main app.
  1309. */
  1310. PATCHBAY_ICON_CARLA = 3,
  1311. /*!
  1312. * DISTRHO icon.
  1313. * Used for DISTRHO based plugins.
  1314. */
  1315. PATCHBAY_ICON_DISTRHO = 4,
  1316. /*!
  1317. * File icon.
  1318. * Used for file type plugins (like SF2 snd SFZ).
  1319. */
  1320. PATCHBAY_ICON_FILE = 5
  1321. };
  1322. /* ------------------------------------------------------------------------------------------------------------
  1323. * Carla Backend API (C stuff) */
  1324. /*!
  1325. * Engine callback function.
  1326. * Front-ends must never block indefinitely during a callback.
  1327. * @see EngineCallbackOpcode, CarlaEngine::setCallback() and carla_set_engine_callback()
  1328. */
  1329. typedef void (*EngineCallbackFunc)(void* ptr, EngineCallbackOpcode action, uint pluginId,
  1330. int value1, int value2, int value3,
  1331. float valuef, const char* valueStr);
  1332. /*!
  1333. * File callback function.
  1334. * @see FileCallbackOpcode
  1335. */
  1336. typedef const char* (*FileCallbackFunc)(void* ptr, FileCallbackOpcode action, bool isDir, const char* title, const char* filter);
  1337. /*!
  1338. * Parameter data.
  1339. */
  1340. typedef struct {
  1341. /*!
  1342. * This parameter type.
  1343. */
  1344. ParameterType type;
  1345. /*!
  1346. * This parameter hints.
  1347. * @see ParameterHints
  1348. */
  1349. uint hints;
  1350. /*!
  1351. * Index as seen by Carla.
  1352. */
  1353. int32_t index;
  1354. /*!
  1355. * Real index as seen by plugins.
  1356. */
  1357. int32_t rindex;
  1358. /*!
  1359. * Currently mapped MIDI channel.
  1360. * Counts from 0 to 15.
  1361. */
  1362. uint8_t midiChannel;
  1363. /*!
  1364. * Currently mapped index.
  1365. * @see SpecialMappedControlIndex
  1366. */
  1367. int16_t mappedControlIndex;
  1368. /*!
  1369. * Minimum value that this parameter maps to.
  1370. */
  1371. float mappedMinimum;
  1372. /*!
  1373. * Maximum value that this parameter maps to.
  1374. */
  1375. float mappedMaximum;
  1376. } ParameterData;
  1377. /*!
  1378. * Parameter ranges.
  1379. */
  1380. typedef struct _ParameterRanges {
  1381. /*!
  1382. * Default value.
  1383. */
  1384. float def;
  1385. /*!
  1386. * Minimum value.
  1387. */
  1388. float min;
  1389. /*!
  1390. * Maximum value.
  1391. */
  1392. float max;
  1393. /*!
  1394. * Regular, single step value.
  1395. */
  1396. float step;
  1397. /*!
  1398. * Small step value.
  1399. */
  1400. float stepSmall;
  1401. /*!
  1402. * Large step value.
  1403. */
  1404. float stepLarge;
  1405. #ifdef __cplusplus
  1406. /*!
  1407. * Fix the default value within range.
  1408. */
  1409. void fixDefault() noexcept
  1410. {
  1411. fixValue(def);
  1412. }
  1413. /*!
  1414. * Fix a value within range.
  1415. */
  1416. void fixValue(float& value) const noexcept
  1417. {
  1418. if (value < min)
  1419. value = min;
  1420. else if (value > max)
  1421. value = max;
  1422. }
  1423. /*!
  1424. * Get a fixed value within range.
  1425. */
  1426. const float& getFixedValue(const float& value) const noexcept
  1427. {
  1428. if (value <= min)
  1429. return min;
  1430. if (value >= max)
  1431. return max;
  1432. return value;
  1433. }
  1434. /*!
  1435. * Get a value normalized to 0.0<->1.0.
  1436. */
  1437. float getNormalizedValue(const float& value) const noexcept
  1438. {
  1439. const float normValue((value - min) / (max - min));
  1440. if (normValue <= 0.0f)
  1441. return 0.0f;
  1442. if (normValue >= 1.0f)
  1443. return 1.0f;
  1444. return normValue;
  1445. }
  1446. /*!
  1447. * Get a value normalized to 0.0<->1.0, fixed within range.
  1448. */
  1449. float getFixedAndNormalizedValue(const float& value) const noexcept
  1450. {
  1451. if (value <= min)
  1452. return 0.0f;
  1453. if (value >= max)
  1454. return 1.0f;
  1455. const float normValue((value - min) / (max - min));
  1456. if (normValue <= 0.0f)
  1457. return 0.0f;
  1458. if (normValue >= 1.0f)
  1459. return 1.0f;
  1460. return normValue;
  1461. }
  1462. /*!
  1463. * Get a proper value previously normalized to 0.0<->1.0.
  1464. */
  1465. float getUnnormalizedValue(const float& value) const noexcept
  1466. {
  1467. if (value <= 0.0f)
  1468. return min;
  1469. if (value >= 1.0f)
  1470. return max;
  1471. return value * (max - min) + min;
  1472. }
  1473. /*!
  1474. * Get a logarithmic value previously normalized to 0.0<->1.0.
  1475. */
  1476. float getUnnormalizedLogValue(const float& value) const noexcept
  1477. {
  1478. if (value <= 0.0f)
  1479. return min;
  1480. if (value >= 1.0f)
  1481. return max;
  1482. float rmin = min;
  1483. if (std::abs(min) < std::numeric_limits<float>::epsilon())
  1484. rmin = 0.00001f;
  1485. return rmin * std::pow(max/rmin, value);
  1486. }
  1487. #endif /* __cplusplus */
  1488. } ParameterRanges;
  1489. /*!
  1490. * MIDI Program data.
  1491. */
  1492. typedef struct {
  1493. /*!
  1494. * MIDI bank.
  1495. */
  1496. uint32_t bank;
  1497. /*!
  1498. * MIDI program.
  1499. */
  1500. uint32_t program;
  1501. /*!
  1502. * MIDI program name.
  1503. */
  1504. const char* name;
  1505. } MidiProgramData;
  1506. /*!
  1507. * Custom data, used for saving key:value 'dictionaries'.
  1508. */
  1509. typedef struct {
  1510. /*!
  1511. * Value type, in URI form.
  1512. * @see CustomDataTypes
  1513. */
  1514. const char* type;
  1515. /*!
  1516. * Key.
  1517. * @see CustomDataKeys
  1518. */
  1519. const char* key;
  1520. /*!
  1521. * Value.
  1522. */
  1523. const char* value;
  1524. #ifdef __cplusplus
  1525. /*!
  1526. * Check if valid.
  1527. */
  1528. bool isValid() const noexcept
  1529. {
  1530. if (type == nullptr || type[0] == '\0') return false;
  1531. if (key == nullptr || key [0] == '\0') return false;
  1532. if (value == nullptr) return false;
  1533. return true;
  1534. }
  1535. #endif /* __cplusplus */
  1536. } CustomData;
  1537. /*!
  1538. * Engine driver device information.
  1539. */
  1540. typedef struct {
  1541. /*!
  1542. * This driver device hints.
  1543. * @see EngineDriverHints
  1544. */
  1545. uint hints;
  1546. /*!
  1547. * Available buffer sizes.
  1548. * Terminated with 0.
  1549. */
  1550. const uint32_t* bufferSizes;
  1551. /*!
  1552. * Available sample rates.
  1553. * Terminated with 0.0.
  1554. */
  1555. const double* sampleRates;
  1556. } EngineDriverDeviceInfo;
  1557. /** @} */
  1558. #ifdef __cplusplus
  1559. /* Forward declarations of commonly used Carla classes */
  1560. class CarlaEngine;
  1561. class CarlaEngineClient;
  1562. class CarlaEngineCVSourcePorts;
  1563. class CarlaPlugin;
  1564. /* End namespace */
  1565. CARLA_BACKEND_END_NAMESPACE
  1566. #endif
  1567. #endif /* CARLA_BACKEND_H_INCLUDED */