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.

1782 lines
39KB

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