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.

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