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.

1848 lines
41KB

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