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.

1820 lines
40KB

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