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.

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