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.

1890 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. * Highest index allowed for mappings.
  633. */
  634. CONTROL_INDEX_MAX_ALLOWED = CONTROL_INDEX_MIDI_PITCHBEND
  635. } SpecialMappedControlIndex;
  636. /* ------------------------------------------------------------------------------------------------------------
  637. * Engine Callback Opcode */
  638. /*!
  639. * Engine callback opcodes.
  640. * Front-ends must never block indefinitely during a callback.
  641. * @see EngineCallbackFunc, CarlaEngine::setCallback() and carla_set_engine_callback()
  642. */
  643. typedef enum {
  644. /*!
  645. * Debug.
  646. * This opcode is undefined and used only for testing purposes.
  647. */
  648. ENGINE_CALLBACK_DEBUG = 0,
  649. /*!
  650. * A plugin has been added.
  651. * @a pluginId Plugin Id
  652. * @a valueStr Plugin name
  653. */
  654. ENGINE_CALLBACK_PLUGIN_ADDED = 1,
  655. /*!
  656. * A plugin has been removed.
  657. * @a pluginId Plugin Id
  658. */
  659. ENGINE_CALLBACK_PLUGIN_REMOVED = 2,
  660. /*!
  661. * A plugin has been renamed.
  662. * @a pluginId Plugin Id
  663. * @a valueStr New plugin name
  664. */
  665. ENGINE_CALLBACK_PLUGIN_RENAMED = 3,
  666. /*!
  667. * A plugin has become unavailable.
  668. * @a pluginId Plugin Id
  669. * @a valueStr Related error string
  670. */
  671. ENGINE_CALLBACK_PLUGIN_UNAVAILABLE = 4,
  672. /*!
  673. * A parameter value has changed.
  674. * @a pluginId Plugin Id
  675. * @a value1 Parameter index
  676. * @a valuef New parameter value
  677. */
  678. ENGINE_CALLBACK_PARAMETER_VALUE_CHANGED = 5,
  679. /*!
  680. * A parameter default has changed.
  681. * @a pluginId Plugin Id
  682. * @a value1 Parameter index
  683. * @a valuef New default value
  684. */
  685. ENGINE_CALLBACK_PARAMETER_DEFAULT_CHANGED = 6,
  686. #ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
  687. /*!
  688. * A parameter's mapped control index has changed.
  689. * @a pluginId Plugin Id
  690. * @a value1 Parameter index
  691. * @a value2 New control index
  692. */
  693. ENGINE_CALLBACK_PARAMETER_MAPPED_CONTROL_INDEX_CHANGED = 7,
  694. /*!
  695. * A parameter's MIDI channel has changed.
  696. * @a pluginId Plugin Id
  697. * @a value1 Parameter index
  698. * @a value2 New MIDI channel
  699. */
  700. ENGINE_CALLBACK_PARAMETER_MIDI_CHANNEL_CHANGED = 8,
  701. /*!
  702. * A plugin option has changed.
  703. * @a pluginId Plugin Id
  704. * @a value1 Option
  705. * @a value2 New on/off state (1 for on, 0 for off)
  706. * @see PluginOptions
  707. */
  708. ENGINE_CALLBACK_OPTION_CHANGED = 9,
  709. #endif
  710. /*!
  711. * The current program of a plugin has changed.
  712. * @a pluginId Plugin Id
  713. * @a value1 New program index
  714. */
  715. ENGINE_CALLBACK_PROGRAM_CHANGED = 10,
  716. /*!
  717. * The current MIDI program of a plugin has changed.
  718. * @a pluginId Plugin Id
  719. * @a value1 New MIDI program index
  720. */
  721. ENGINE_CALLBACK_MIDI_PROGRAM_CHANGED = 11,
  722. /*!
  723. * A plugin's custom UI state has changed.
  724. * @a pluginId Plugin Id
  725. * @a value1 New state, as follows:
  726. * 0: UI is now hidden
  727. * 1: UI is now visible
  728. * -1: UI has crashed and should not be shown again
  729. */
  730. ENGINE_CALLBACK_UI_STATE_CHANGED = 12,
  731. /*!
  732. * A note has been pressed.
  733. * @a pluginId Plugin Id
  734. * @a value1 Channel
  735. * @a value2 Note
  736. * @a value3 Velocity
  737. */
  738. ENGINE_CALLBACK_NOTE_ON = 13,
  739. /*!
  740. * A note has been released.
  741. * @a pluginId Plugin Id
  742. * @a value1 Channel
  743. * @a value2 Note
  744. */
  745. ENGINE_CALLBACK_NOTE_OFF = 14,
  746. /*!
  747. * A plugin needs update.
  748. * @a pluginId Plugin Id
  749. */
  750. ENGINE_CALLBACK_UPDATE = 15,
  751. /*!
  752. * A plugin's data/information has changed.
  753. * @a pluginId Plugin Id
  754. */
  755. ENGINE_CALLBACK_RELOAD_INFO = 16,
  756. /*!
  757. * A plugin's parameters have changed.
  758. * @a pluginId Plugin Id
  759. */
  760. ENGINE_CALLBACK_RELOAD_PARAMETERS = 17,
  761. /*!
  762. * A plugin's programs have changed.
  763. * @a pluginId Plugin Id
  764. */
  765. ENGINE_CALLBACK_RELOAD_PROGRAMS = 18,
  766. /*!
  767. * A plugin state has changed.
  768. * @a pluginId Plugin Id
  769. */
  770. ENGINE_CALLBACK_RELOAD_ALL = 19,
  771. #ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
  772. /*!
  773. * A patchbay client has been added.
  774. * @a pluginId Client Id
  775. * @a value1 Client icon
  776. * @a value2 Plugin Id (-1 if not a plugin)
  777. * @a valueStr Client name
  778. * @see PatchbayIcon
  779. */
  780. ENGINE_CALLBACK_PATCHBAY_CLIENT_ADDED = 20,
  781. /*!
  782. * A patchbay client has been removed.
  783. * @a pluginId Client Id
  784. */
  785. ENGINE_CALLBACK_PATCHBAY_CLIENT_REMOVED = 21,
  786. /*!
  787. * A patchbay client has been renamed.
  788. * @a pluginId Client Id
  789. * @a valueStr New client name
  790. */
  791. ENGINE_CALLBACK_PATCHBAY_CLIENT_RENAMED = 22,
  792. /*!
  793. * A patchbay client data has changed.
  794. * @a pluginId Client Id
  795. * @a value1 New icon
  796. * @a value2 New plugin Id (-1 if not a plugin)
  797. * @see PatchbayIcon
  798. */
  799. ENGINE_CALLBACK_PATCHBAY_CLIENT_DATA_CHANGED = 23,
  800. /*!
  801. * A patchbay port has been added.
  802. * @a pluginId Client Id
  803. * @a value1 Port Id
  804. * @a value2 Port hints
  805. * @a value3 Port group Id (0 for none)
  806. * @a valueStr Port name
  807. * @see PatchbayPortHints
  808. */
  809. ENGINE_CALLBACK_PATCHBAY_PORT_ADDED = 24,
  810. /*!
  811. * A patchbay port has been removed.
  812. * @a pluginId Client Id
  813. * @a value1 Port Id
  814. */
  815. ENGINE_CALLBACK_PATCHBAY_PORT_REMOVED = 25,
  816. /*!
  817. * A patchbay port has changed (like the name or group Id).
  818. * @a pluginId Client Id
  819. * @a value1 Port Id
  820. * @a value2 Port hints
  821. * @a value3 Port group Id (0 for none)
  822. * @a valueStr Port name
  823. */
  824. ENGINE_CALLBACK_PATCHBAY_PORT_CHANGED = 26,
  825. /*!
  826. * A patchbay connection has been added.
  827. * @a pluginId Connection Id
  828. * @a valueStr Out group and port plus in group and port, in "og:op:ig:ip" syntax.
  829. */
  830. ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED = 27,
  831. /*!
  832. * A patchbay connection has been removed.
  833. * @a pluginId Connection Id
  834. */
  835. ENGINE_CALLBACK_PATCHBAY_CONNECTION_REMOVED = 28,
  836. #endif
  837. /*!
  838. * Engine started.
  839. * @a pluginId How many plugins are known to be running
  840. * @a value1 Process mode
  841. * @a value2 Transport mode
  842. * @a value3 Buffer size
  843. * @a valuef Sample rate
  844. * @a valuestr Engine driver
  845. * @see EngineProcessMode
  846. * @see EngineTransportMode
  847. */
  848. ENGINE_CALLBACK_ENGINE_STARTED = 29,
  849. /*!
  850. * Engine stopped.
  851. */
  852. ENGINE_CALLBACK_ENGINE_STOPPED = 30,
  853. /*!
  854. * Engine process mode has changed.
  855. * @a value1 New process mode
  856. * @see EngineProcessMode
  857. */
  858. ENGINE_CALLBACK_PROCESS_MODE_CHANGED = 31,
  859. /*!
  860. * Engine transport mode has changed.
  861. * @a value1 New transport mode
  862. * @a valueStr New transport features enabled
  863. * @see EngineTransportMode
  864. */
  865. ENGINE_CALLBACK_TRANSPORT_MODE_CHANGED = 32,
  866. /*!
  867. * Engine buffer-size changed.
  868. * @a value1 New buffer size
  869. */
  870. ENGINE_CALLBACK_BUFFER_SIZE_CHANGED = 33,
  871. /*!
  872. * Engine sample-rate changed.
  873. * @a valuef New sample rate
  874. */
  875. ENGINE_CALLBACK_SAMPLE_RATE_CHANGED = 34,
  876. /*!
  877. * A cancelable action has been started or stopped.
  878. * @a pluginId Plugin Id the action relates to, -1 for none
  879. * @a value1 1 for action started, 0 for stopped
  880. * @a valueStr Action name
  881. */
  882. ENGINE_CALLBACK_CANCELABLE_ACTION = 35,
  883. /*!
  884. * Project has finished loading.
  885. */
  886. ENGINE_CALLBACK_PROJECT_LOAD_FINISHED = 36,
  887. /*!
  888. * NSM callback, to be handled by a frontend.
  889. * Frontend must call carla_nsm_ready() with opcode as parameter as a response
  890. * @a value1 NSM opcode
  891. * @a value2 Integer value
  892. * @a valueStr String value
  893. * @see NsmCallbackOpcode
  894. */
  895. ENGINE_CALLBACK_NSM = 37,
  896. /*!
  897. * Idle frontend.
  898. * This is used by the engine during long operations that might block the frontend,
  899. * giving it the possibility to idle while the operation is still in place.
  900. */
  901. ENGINE_CALLBACK_IDLE = 38,
  902. /*!
  903. * Show a message as information.
  904. * @a valueStr The message
  905. */
  906. ENGINE_CALLBACK_INFO = 39,
  907. /*!
  908. * Show a message as an error.
  909. * @a valueStr The message
  910. */
  911. ENGINE_CALLBACK_ERROR = 40,
  912. /*!
  913. * The engine has crashed or malfunctioned and will no longer work.
  914. */
  915. ENGINE_CALLBACK_QUIT = 41,
  916. /*!
  917. * A plugin requested for its inline display to be redrawn.
  918. * @a pluginId Plugin Id to redraw
  919. */
  920. ENGINE_CALLBACK_INLINE_DISPLAY_REDRAW = 42,
  921. /*!
  922. * A patchbay port group has been added.
  923. * @a pluginId Client Id
  924. * @a value1 Group Id (unique value within this client)
  925. * @a value2 Group hints
  926. * @a valueStr Group name
  927. * @see PatchbayPortGroupHints
  928. */
  929. ENGINE_CALLBACK_PATCHBAY_PORT_GROUP_ADDED = 43,
  930. /*!
  931. * A patchbay port group has been removed.
  932. * @a pluginId Client Id
  933. * @a value1 Group Id
  934. */
  935. ENGINE_CALLBACK_PATCHBAY_PORT_GROUP_REMOVED = 44,
  936. /*!
  937. * A patchbay port group has changed.
  938. * @a pluginId Client Id
  939. * @a value1 Group Id
  940. * @a value2 Group hints
  941. * @a valueStr Group name
  942. * @see PatchbayPortGroupHints
  943. */
  944. ENGINE_CALLBACK_PATCHBAY_PORT_GROUP_CHANGED = 45,
  945. /*!
  946. * A parameter's mapped range has changed.
  947. * @a pluginId Plugin Id
  948. * @a value1 Parameter index
  949. * @a valueStr New mapped range as "%f:%f" syntax
  950. */
  951. ENGINE_CALLBACK_PARAMETER_MAPPED_RANGE_CHANGED = 46,
  952. /*!
  953. * A patchbay client position has changed.
  954. * @a pluginId Client Id
  955. * @a value1 X position 1
  956. * @a value2 Y position 1
  957. * @a value3 X position 2
  958. * @a valuef Y position 2
  959. */
  960. ENGINE_CALLBACK_PATCHBAY_CLIENT_POSITION_CHANGED = 47,
  961. /*!
  962. * A plugin embed UI has been resized.
  963. * @a pluginId Plugin Id to resize
  964. * @a value1 New width
  965. * @a value2 New height
  966. */
  967. ENGINE_CALLBACK_EMBED_UI_RESIZED = 48,
  968. } EngineCallbackOpcode;
  969. /* ------------------------------------------------------------------------------------------------------------
  970. * NSM Callback Opcode */
  971. /*!
  972. * NSM callback opcodes.
  973. * @see ENGINE_CALLBACK_NSM
  974. */
  975. typedef enum {
  976. /*!
  977. * NSM is available and initialized.
  978. */
  979. NSM_CALLBACK_INIT = 0,
  980. /*!
  981. * Error from NSM side.
  982. * @a valueInt Error code
  983. * @a valueStr Error string
  984. */
  985. NSM_CALLBACK_ERROR = 1,
  986. /*!
  987. * Announce message.
  988. * @a valueInt SM Flags (WIP, to be defined)
  989. * @a valueStr SM Name
  990. */
  991. NSM_CALLBACK_ANNOUNCE = 2,
  992. /*!
  993. * Open message.
  994. * @a valueStr Project filename
  995. */
  996. NSM_CALLBACK_OPEN = 3,
  997. /*!
  998. * Save message.
  999. */
  1000. NSM_CALLBACK_SAVE = 4,
  1001. /*!
  1002. * Session-is-loaded message.
  1003. */
  1004. NSM_CALLBACK_SESSION_IS_LOADED = 5,
  1005. /*!
  1006. * Show-optional-gui message.
  1007. */
  1008. NSM_CALLBACK_SHOW_OPTIONAL_GUI = 6,
  1009. /*!
  1010. * Hide-optional-gui message.
  1011. */
  1012. NSM_CALLBACK_HIDE_OPTIONAL_GUI = 7
  1013. } NsmCallbackOpcode;
  1014. /* ------------------------------------------------------------------------------------------------------------
  1015. * Engine Option */
  1016. /*!
  1017. * Engine options.
  1018. * @see CarlaEngine::getOptions(), CarlaEngine::setOption() and carla_set_engine_option()
  1019. */
  1020. typedef enum {
  1021. /*!
  1022. * Debug.
  1023. * This option is undefined and used only for testing purposes.
  1024. */
  1025. ENGINE_OPTION_DEBUG = 0,
  1026. /*!
  1027. * Set the engine processing mode.
  1028. * Default is ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS on Linux and ENGINE_PROCESS_MODE_PATCHBAY for all other OSes.
  1029. * @see EngineProcessMode
  1030. */
  1031. ENGINE_OPTION_PROCESS_MODE = 1,
  1032. /*!
  1033. * Set the engine transport mode.
  1034. * Default is ENGINE_TRANSPORT_MODE_JACK on Linux and ENGINE_TRANSPORT_MODE_INTERNAL for all other OSes.
  1035. * @see EngineTransportMode
  1036. */
  1037. ENGINE_OPTION_TRANSPORT_MODE = 2,
  1038. /*!
  1039. * Force mono plugins as stereo, by running 2 instances at the same time.
  1040. * Default is false, but always true when process mode is ENGINE_PROCESS_MODE_CONTINUOUS_RACK.
  1041. * @note Not supported by all plugins
  1042. * @see PLUGIN_OPTION_FORCE_STEREO
  1043. */
  1044. ENGINE_OPTION_FORCE_STEREO = 3,
  1045. /*!
  1046. * Use plugin bridges whenever possible.
  1047. * Default is no, EXPERIMENTAL.
  1048. */
  1049. ENGINE_OPTION_PREFER_PLUGIN_BRIDGES = 4,
  1050. /*!
  1051. * Use UI bridges whenever possible, otherwise UIs will be directly handled in the main backend thread.
  1052. * Default is yes.
  1053. */
  1054. ENGINE_OPTION_PREFER_UI_BRIDGES = 5,
  1055. /*!
  1056. * Make custom plugin UIs always-on-top.
  1057. * Default is yes.
  1058. */
  1059. ENGINE_OPTION_UIS_ALWAYS_ON_TOP = 6,
  1060. /*!
  1061. * Maximum number of parameters allowed.
  1062. * Default is MAX_DEFAULT_PARAMETERS.
  1063. */
  1064. ENGINE_OPTION_MAX_PARAMETERS = 7,
  1065. /*!
  1066. * Reset Xrun counter after project load.
  1067. */
  1068. ENGINE_OPTION_RESET_XRUNS = 8,
  1069. /*!
  1070. * Timeout value for how much to wait for UI bridges to respond, in milliseconds.
  1071. * Default is 4000 (4 seconds).
  1072. */
  1073. ENGINE_OPTION_UI_BRIDGES_TIMEOUT = 9,
  1074. /*!
  1075. * Audio buffer size.
  1076. * Default is 512.
  1077. */
  1078. ENGINE_OPTION_AUDIO_BUFFER_SIZE = 10,
  1079. /*!
  1080. * Audio sample rate.
  1081. * Default is 44100.
  1082. */
  1083. ENGINE_OPTION_AUDIO_SAMPLE_RATE = 11,
  1084. /*!
  1085. * Wherever to use 3 audio periods instead of the default 2.
  1086. * Default is false.
  1087. */
  1088. ENGINE_OPTION_AUDIO_TRIPLE_BUFFER = 12,
  1089. /*!
  1090. * Audio driver.
  1091. * Default depends on platform.
  1092. */
  1093. ENGINE_OPTION_AUDIO_DRIVER = 13,
  1094. /*!
  1095. * Audio device (within a driver).
  1096. * Default unset.
  1097. */
  1098. ENGINE_OPTION_AUDIO_DEVICE = 14,
  1099. /*!
  1100. * Wherever to enable OSC support in the engine.
  1101. */
  1102. ENGINE_OPTION_OSC_ENABLED = 15,
  1103. /*!
  1104. * The network TCP port to use for OSC.
  1105. * A value of 0 means use a random port.
  1106. * A value of < 0 means to not enable the TCP port for OSC.
  1107. * @note Valid ports begin at 1024 and end at 32767 (inclusive)
  1108. */
  1109. ENGINE_OPTION_OSC_PORT_TCP = 16,
  1110. /*!
  1111. * The network UDP port to use for OSC.
  1112. * A value of 0 means use a random port.
  1113. * A value of < 0 means to not enable the UDP port for OSC.
  1114. * @note Disabling this option prevents DSSI UIs from working!
  1115. * @note Valid ports begin at 1024 and end at 32767 (inclusive)
  1116. */
  1117. ENGINE_OPTION_OSC_PORT_UDP = 17,
  1118. /*!
  1119. * Set path used for a specific file type.
  1120. * Uses value as the file format, valueStr as actual path.
  1121. */
  1122. ENGINE_OPTION_FILE_PATH = 18,
  1123. /*!
  1124. * Set path used for a specific plugin type.
  1125. * Uses value as the plugin format, valueStr as actual path.
  1126. * @see PluginType
  1127. */
  1128. ENGINE_OPTION_PLUGIN_PATH = 19,
  1129. /*!
  1130. * Set path to the binary files.
  1131. * Default unset.
  1132. * @note Must be set for plugin and UI bridges to work
  1133. */
  1134. ENGINE_OPTION_PATH_BINARIES = 20,
  1135. /*!
  1136. * Set path to the resource files.
  1137. * Default unset.
  1138. * @note Must be set for some internal plugins to work
  1139. */
  1140. ENGINE_OPTION_PATH_RESOURCES = 21,
  1141. /*!
  1142. * Prevent bad plugin and UI behaviour.
  1143. * @note: Linux only
  1144. */
  1145. ENGINE_OPTION_PREVENT_BAD_BEHAVIOUR = 22,
  1146. /*!
  1147. * Set background color used in the frontend, so backend can do the same for plugin UIs.
  1148. */
  1149. ENGINE_OPTION_FRONTEND_BACKGROUND_COLOR = 23,
  1150. /*!
  1151. * Set foreground color used in the frontend, so backend can do the same for plugin UIs.
  1152. */
  1153. ENGINE_OPTION_FRONTEND_FOREGROUND_COLOR = 24,
  1154. /*!
  1155. * Set UI scaling used in the frontend, so backend can do the same for plugin UIs.
  1156. */
  1157. ENGINE_OPTION_FRONTEND_UI_SCALE = 25,
  1158. /*!
  1159. * Set frontend winId, used to define as parent window for plugin UIs.
  1160. */
  1161. ENGINE_OPTION_FRONTEND_WIN_ID = 26,
  1162. #if !defined(BUILD_BRIDGE_ALTERNATIVE_ARCH) && !defined(CARLA_OS_WIN)
  1163. /*!
  1164. * Set path to wine executable.
  1165. */
  1166. ENGINE_OPTION_WINE_EXECUTABLE = 27,
  1167. /*!
  1168. * Enable automatic wineprefix detection.
  1169. */
  1170. ENGINE_OPTION_WINE_AUTO_PREFIX = 28,
  1171. /*!
  1172. * Fallback wineprefix to use if automatic detection fails or is disabled, and WINEPREFIX is not set.
  1173. */
  1174. ENGINE_OPTION_WINE_FALLBACK_PREFIX = 29,
  1175. /*!
  1176. * Enable realtime priority for Wine application and server threads.
  1177. */
  1178. ENGINE_OPTION_WINE_RT_PRIO_ENABLED = 30,
  1179. /*!
  1180. * Base realtime priority for Wine threads.
  1181. */
  1182. ENGINE_OPTION_WINE_BASE_RT_PRIO = 31,
  1183. /*!
  1184. * Wine server realtime priority.
  1185. */
  1186. ENGINE_OPTION_WINE_SERVER_RT_PRIO = 32,
  1187. #endif
  1188. /*!
  1189. * Capture console output into debug callbacks.
  1190. */
  1191. ENGINE_OPTION_DEBUG_CONSOLE_OUTPUT = 33,
  1192. /*!
  1193. * A prefix to give to all plugin clients created by Carla.
  1194. * Mostly useful for JACK multi-client mode.
  1195. * @note MUST include at least one "." (dot).
  1196. */
  1197. ENGINE_OPTION_CLIENT_NAME_PREFIX = 34
  1198. } EngineOption;
  1199. /* ------------------------------------------------------------------------------------------------------------
  1200. * Engine Process Mode */
  1201. /*!
  1202. * Engine process mode.
  1203. * @see ENGINE_OPTION_PROCESS_MODE
  1204. */
  1205. typedef enum {
  1206. /*!
  1207. * Single client mode.
  1208. * Inputs and outputs are added dynamically as needed by plugins.
  1209. */
  1210. ENGINE_PROCESS_MODE_SINGLE_CLIENT = 0,
  1211. /*!
  1212. * Multiple client mode.
  1213. * It has 1 master client + 1 client per plugin.
  1214. */
  1215. ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS = 1,
  1216. /*!
  1217. * Single client, 'rack' mode.
  1218. * Processes plugins in order of Id, with forced stereo always on.
  1219. */
  1220. ENGINE_PROCESS_MODE_CONTINUOUS_RACK = 2,
  1221. /*!
  1222. * Single client, 'patchbay' mode.
  1223. */
  1224. ENGINE_PROCESS_MODE_PATCHBAY = 3,
  1225. /*!
  1226. * Special mode, used in plugin-bridges only.
  1227. */
  1228. ENGINE_PROCESS_MODE_BRIDGE = 4
  1229. } EngineProcessMode;
  1230. /* ------------------------------------------------------------------------------------------------------------
  1231. * Engine Transport Mode */
  1232. /*!
  1233. * Engine transport mode.
  1234. * @see ENGINE_OPTION_TRANSPORT_MODE
  1235. */
  1236. typedef enum {
  1237. /*!
  1238. * No transport.
  1239. */
  1240. ENGINE_TRANSPORT_MODE_DISABLED = 0,
  1241. /*!
  1242. * Internal transport mode.
  1243. */
  1244. ENGINE_TRANSPORT_MODE_INTERNAL = 1,
  1245. /*!
  1246. * Transport from JACK.
  1247. * Only available if driver name is "JACK".
  1248. */
  1249. ENGINE_TRANSPORT_MODE_JACK = 2,
  1250. /*!
  1251. * Transport from host, used when Carla is a plugin.
  1252. */
  1253. ENGINE_TRANSPORT_MODE_PLUGIN = 3,
  1254. /*!
  1255. * Special mode, used in plugin-bridges only.
  1256. */
  1257. ENGINE_TRANSPORT_MODE_BRIDGE = 4
  1258. } EngineTransportMode;
  1259. /* ------------------------------------------------------------------------------------------------------------
  1260. * File Callback Opcode */
  1261. /*!
  1262. * File callback opcodes.
  1263. * Front-ends must always block-wait for user input.
  1264. * @see FileCallbackFunc, CarlaEngine::setFileCallback() and carla_set_file_callback()
  1265. */
  1266. typedef enum {
  1267. /*!
  1268. * Debug.
  1269. * This opcode is undefined and used only for testing purposes.
  1270. */
  1271. FILE_CALLBACK_DEBUG = 0,
  1272. /*!
  1273. * Open file or folder.
  1274. */
  1275. FILE_CALLBACK_OPEN = 1,
  1276. /*!
  1277. * Save file or folder.
  1278. */
  1279. FILE_CALLBACK_SAVE = 2
  1280. } FileCallbackOpcode;
  1281. /* ------------------------------------------------------------------------------------------------------------
  1282. * Patchbay Icon */
  1283. /*!
  1284. * The icon of a patchbay client/group.
  1285. */
  1286. enum PatchbayIcon {
  1287. /*!
  1288. * Generic application icon.
  1289. * Used for all non-plugin clients that don't have a specific icon.
  1290. */
  1291. PATCHBAY_ICON_APPLICATION = 0,
  1292. /*!
  1293. * Plugin icon.
  1294. * Used for all plugin clients that don't have a specific icon.
  1295. */
  1296. PATCHBAY_ICON_PLUGIN = 1,
  1297. /*!
  1298. * Hardware icon.
  1299. * Used for hardware (audio or MIDI) clients.
  1300. */
  1301. PATCHBAY_ICON_HARDWARE = 2,
  1302. /*!
  1303. * Carla icon.
  1304. * Used for the main app.
  1305. */
  1306. PATCHBAY_ICON_CARLA = 3,
  1307. /*!
  1308. * DISTRHO icon.
  1309. * Used for DISTRHO based plugins.
  1310. */
  1311. PATCHBAY_ICON_DISTRHO = 4,
  1312. /*!
  1313. * File icon.
  1314. * Used for file type plugins (like SF2 snd SFZ).
  1315. */
  1316. PATCHBAY_ICON_FILE = 5
  1317. };
  1318. /* ------------------------------------------------------------------------------------------------------------
  1319. * Carla Backend API (C stuff) */
  1320. /*!
  1321. * Engine callback function.
  1322. * Front-ends must never block indefinitely during a callback.
  1323. * @see EngineCallbackOpcode, CarlaEngine::setCallback() and carla_set_engine_callback()
  1324. */
  1325. typedef void (*EngineCallbackFunc)(void* ptr, EngineCallbackOpcode action, uint pluginId,
  1326. int value1, int value2, int value3,
  1327. float valuef, const char* valueStr);
  1328. /*!
  1329. * File callback function.
  1330. * @see FileCallbackOpcode
  1331. */
  1332. typedef const char* (*FileCallbackFunc)(void* ptr, FileCallbackOpcode action, bool isDir, const char* title, const char* filter);
  1333. /*!
  1334. * Parameter data.
  1335. */
  1336. typedef struct {
  1337. /*!
  1338. * This parameter type.
  1339. */
  1340. ParameterType type;
  1341. /*!
  1342. * This parameter hints.
  1343. * @see ParameterHints
  1344. */
  1345. uint hints;
  1346. /*!
  1347. * Index as seen by Carla.
  1348. */
  1349. int32_t index;
  1350. /*!
  1351. * Real index as seen by plugins.
  1352. */
  1353. int32_t rindex;
  1354. /*!
  1355. * Currently mapped MIDI channel.
  1356. * Counts from 0 to 15.
  1357. */
  1358. uint8_t midiChannel;
  1359. /*!
  1360. * Currently mapped index.
  1361. * @see SpecialMappedControlIndex
  1362. */
  1363. int16_t mappedControlIndex;
  1364. /*!
  1365. * Minimum value that this parameter maps to.
  1366. */
  1367. float mappedMinimum;
  1368. /*!
  1369. * Maximum value that this parameter maps to.
  1370. */
  1371. float mappedMaximum;
  1372. } ParameterData;
  1373. /*!
  1374. * Parameter ranges.
  1375. */
  1376. typedef struct _ParameterRanges {
  1377. /*!
  1378. * Default value.
  1379. */
  1380. float def;
  1381. /*!
  1382. * Minimum value.
  1383. */
  1384. float min;
  1385. /*!
  1386. * Maximum value.
  1387. */
  1388. float max;
  1389. /*!
  1390. * Regular, single step value.
  1391. */
  1392. float step;
  1393. /*!
  1394. * Small step value.
  1395. */
  1396. float stepSmall;
  1397. /*!
  1398. * Large step value.
  1399. */
  1400. float stepLarge;
  1401. #ifdef __cplusplus
  1402. /*!
  1403. * Fix the default value within range.
  1404. */
  1405. void fixDefault() noexcept
  1406. {
  1407. fixValue(def);
  1408. }
  1409. /*!
  1410. * Fix a value within range.
  1411. */
  1412. void fixValue(float& value) const noexcept
  1413. {
  1414. if (value < min)
  1415. value = min;
  1416. else if (value > max)
  1417. value = max;
  1418. }
  1419. /*!
  1420. * Get a fixed value within range.
  1421. */
  1422. const float& getFixedValue(const float& value) const noexcept
  1423. {
  1424. if (value <= min)
  1425. return min;
  1426. if (value >= max)
  1427. return max;
  1428. return value;
  1429. }
  1430. /*!
  1431. * Get a value normalized to 0.0<->1.0.
  1432. */
  1433. float getNormalizedValue(const float& value) const noexcept
  1434. {
  1435. const float normValue((value - min) / (max - min));
  1436. if (normValue <= 0.0f)
  1437. return 0.0f;
  1438. if (normValue >= 1.0f)
  1439. return 1.0f;
  1440. return normValue;
  1441. }
  1442. /*!
  1443. * Get a value normalized to 0.0<->1.0, fixed within range.
  1444. */
  1445. float getFixedAndNormalizedValue(const float& value) const noexcept
  1446. {
  1447. if (value <= min)
  1448. return 0.0f;
  1449. if (value >= max)
  1450. return 1.0f;
  1451. const float normValue((value - min) / (max - min));
  1452. if (normValue <= 0.0f)
  1453. return 0.0f;
  1454. if (normValue >= 1.0f)
  1455. return 1.0f;
  1456. return normValue;
  1457. }
  1458. /*!
  1459. * Get a proper value previously normalized to 0.0<->1.0.
  1460. */
  1461. float getUnnormalizedValue(const float& value) const noexcept
  1462. {
  1463. if (value <= 0.0f)
  1464. return min;
  1465. if (value >= 1.0f)
  1466. return max;
  1467. return value * (max - min) + min;
  1468. }
  1469. /*!
  1470. * Get a logarithmic value previously normalized to 0.0<->1.0.
  1471. */
  1472. float getUnnormalizedLogValue(const float& value) const noexcept
  1473. {
  1474. if (value <= 0.0f)
  1475. return min;
  1476. if (value >= 1.0f)
  1477. return max;
  1478. float rmin = min;
  1479. if (std::abs(min) < std::numeric_limits<float>::epsilon())
  1480. rmin = 0.00001f;
  1481. return rmin * std::pow(max/rmin, value);
  1482. }
  1483. #endif /* __cplusplus */
  1484. } ParameterRanges;
  1485. /*!
  1486. * MIDI Program data.
  1487. */
  1488. typedef struct {
  1489. /*!
  1490. * MIDI bank.
  1491. */
  1492. uint32_t bank;
  1493. /*!
  1494. * MIDI program.
  1495. */
  1496. uint32_t program;
  1497. /*!
  1498. * MIDI program name.
  1499. */
  1500. const char* name;
  1501. } MidiProgramData;
  1502. /*!
  1503. * Custom data, used for saving key:value 'dictionaries'.
  1504. */
  1505. typedef struct {
  1506. /*!
  1507. * Value type, in URI form.
  1508. * @see CustomDataTypes
  1509. */
  1510. const char* type;
  1511. /*!
  1512. * Key.
  1513. * @see CustomDataKeys
  1514. */
  1515. const char* key;
  1516. /*!
  1517. * Value.
  1518. */
  1519. const char* value;
  1520. #ifdef __cplusplus
  1521. /*!
  1522. * Check if valid.
  1523. */
  1524. bool isValid() const noexcept
  1525. {
  1526. if (type == nullptr || type[0] == '\0') return false;
  1527. if (key == nullptr || key [0] == '\0') return false;
  1528. if (value == nullptr) return false;
  1529. return true;
  1530. }
  1531. #endif /* __cplusplus */
  1532. } CustomData;
  1533. /*!
  1534. * Engine driver device information.
  1535. */
  1536. typedef struct {
  1537. /*!
  1538. * This driver device hints.
  1539. * @see EngineDriverHints
  1540. */
  1541. uint hints;
  1542. /*!
  1543. * Available buffer sizes.
  1544. * Terminated with 0.
  1545. */
  1546. const uint32_t* bufferSizes;
  1547. /*!
  1548. * Available sample rates.
  1549. * Terminated with 0.0.
  1550. */
  1551. const double* sampleRates;
  1552. } EngineDriverDeviceInfo;
  1553. /** @} */
  1554. #ifdef __cplusplus
  1555. /* Forward declarations of commonly used Carla classes */
  1556. class CarlaEngine;
  1557. class CarlaEngineClient;
  1558. class CarlaEngineCVSourcePorts;
  1559. class CarlaPlugin;
  1560. /* End namespace */
  1561. CARLA_BACKEND_END_NAMESPACE
  1562. #endif
  1563. #endif /* CARLA_BACKEND_H_INCLUDED */