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.

1513 lines
33KB

  1. /*
  2. * Carla Plugin Host
  3. * Copyright (C) 2011-2017 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 <cmath>
  31. /* Start namespace */
  32. CARLA_BACKEND_START_NAMESPACE
  33. #endif
  34. /*!
  35. * @defgroup CarlaBackendAPI Carla Backend API
  36. *
  37. * The Carla Backend API.
  38. *
  39. * These are the base definitions for everything in the Carla backend code.
  40. * @{
  41. */
  42. /* ------------------------------------------------------------------------------------------------------------
  43. * Carla Backend API (base definitions) */
  44. /*!
  45. * Maximum default number of loadable plugins.
  46. */
  47. static const uint MAX_DEFAULT_PLUGINS = 99;
  48. /*!
  49. * Maximum number of loadable plugins in rack mode.
  50. */
  51. static const uint MAX_RACK_PLUGINS = 16;
  52. /*!
  53. * Maximum number of loadable plugins in patchbay mode.
  54. */
  55. static const uint MAX_PATCHBAY_PLUGINS = 255;
  56. /*!
  57. * Maximum default number of parameters allowed.
  58. * @see ENGINE_OPTION_MAX_PARAMETERS
  59. */
  60. static const uint MAX_DEFAULT_PARAMETERS = 200;
  61. /* ------------------------------------------------------------------------------------------------------------
  62. * Engine Driver Device Hints */
  63. /*!
  64. * @defgroup EngineDriverHints Engine Driver Device Hints
  65. *
  66. * Various engine driver device hints.
  67. * @see CarlaEngine::getHints(), CarlaEngine::getDriverDeviceInfo() and carla_get_engine_driver_device_info()
  68. * @{
  69. */
  70. /*!
  71. * Engine driver device has custom control-panel.
  72. */
  73. static const uint ENGINE_DRIVER_DEVICE_HAS_CONTROL_PANEL = 0x1;
  74. /*!
  75. * Engine driver device can use a triple-buffer (3 number of periods instead of the usual 2).
  76. * @see ENGINE_OPTION_AUDIO_NUM_PERIODS
  77. */
  78. static const uint ENGINE_DRIVER_DEVICE_CAN_TRIPLE_BUFFER = 0x2;
  79. /*!
  80. * Engine driver device can change buffer-size on the fly.
  81. * @see ENGINE_OPTION_AUDIO_BUFFER_SIZE
  82. */
  83. static const uint ENGINE_DRIVER_DEVICE_VARIABLE_BUFFER_SIZE = 0x4;
  84. /*!
  85. * Engine driver device can change sample-rate on the fly.
  86. * @see ENGINE_OPTION_AUDIO_SAMPLE_RATE
  87. */
  88. static const uint ENGINE_DRIVER_DEVICE_VARIABLE_SAMPLE_RATE = 0x8;
  89. /** @} */
  90. /* ------------------------------------------------------------------------------------------------------------
  91. * Plugin Hints */
  92. /*!
  93. * @defgroup PluginHints Plugin Hints
  94. *
  95. * Various plugin hints.
  96. * @see CarlaPlugin::getHints() and carla_get_plugin_info()
  97. * @{
  98. */
  99. /*!
  100. * Plugin is a bridge.
  101. * This hint is required because "bridge" itself is not a plugin type.
  102. */
  103. static const uint PLUGIN_IS_BRIDGE = 0x001;
  104. /*!
  105. * Plugin is hard real-time safe.
  106. */
  107. static const uint PLUGIN_IS_RTSAFE = 0x002;
  108. /*!
  109. * Plugin is a synth (produces sound).
  110. */
  111. static const uint PLUGIN_IS_SYNTH = 0x004;
  112. /*!
  113. * Plugin has its own custom UI.
  114. * @see CarlaPlugin::showCustomUI() and carla_show_custom_ui()
  115. */
  116. static const uint PLUGIN_HAS_CUSTOM_UI = 0x008;
  117. /*!
  118. * Plugin can use internal Dry/Wet control.
  119. */
  120. static const uint PLUGIN_CAN_DRYWET = 0x010;
  121. /*!
  122. * Plugin can use internal Volume control.
  123. */
  124. static const uint PLUGIN_CAN_VOLUME = 0x020;
  125. /*!
  126. * Plugin can use internal (Stereo) Balance controls.
  127. */
  128. static const uint PLUGIN_CAN_BALANCE = 0x040;
  129. /*!
  130. * Plugin can use internal (Mono) Panning control.
  131. */
  132. static const uint PLUGIN_CAN_PANNING = 0x080;
  133. /*!
  134. * Plugin needs a constant, fixed-size audio buffer.
  135. */
  136. static const uint PLUGIN_NEEDS_FIXED_BUFFERS = 0x100;
  137. /*!
  138. * Plugin needs to receive all UI events in the main thread.
  139. */
  140. static const uint PLUGIN_NEEDS_UI_MAIN_THREAD = 0x200;
  141. /*!
  142. * Plugin uses 1 program per MIDI channel.
  143. * @note: Only used in some internal plugins and gig+sf2 files.
  144. */
  145. static const uint PLUGIN_USES_MULTI_PROGS = 0x400;
  146. /*!
  147. * Plugin can make use of inline display API.
  148. */
  149. static const uint PLUGIN_HAS_INLINE_DISPLAY = 0x800;
  150. /** @} */
  151. /* ------------------------------------------------------------------------------------------------------------
  152. * Plugin Options */
  153. /*!
  154. * @defgroup PluginOptions Plugin Options
  155. *
  156. * Various plugin options.
  157. * @see CarlaPlugin::getOptionsAvailable(), CarlaPlugin::getOptionsEnabled(), carla_get_plugin_info() and carla_set_option()
  158. * @{
  159. */
  160. /*!
  161. * Use constant/fixed-size audio buffers.
  162. */
  163. static const uint PLUGIN_OPTION_FIXED_BUFFERS = 0x001;
  164. /*!
  165. * Force mono plugin as stereo.
  166. */
  167. static const uint PLUGIN_OPTION_FORCE_STEREO = 0x002;
  168. /*!
  169. * Map MIDI programs to plugin programs.
  170. */
  171. static const uint PLUGIN_OPTION_MAP_PROGRAM_CHANGES = 0x004;
  172. /*!
  173. * Use chunks to save and restore data instead of parameter values.
  174. */
  175. static const uint PLUGIN_OPTION_USE_CHUNKS = 0x008;
  176. /*!
  177. * Send MIDI control change events.
  178. */
  179. static const uint PLUGIN_OPTION_SEND_CONTROL_CHANGES = 0x010;
  180. /*!
  181. * Send MIDI channel pressure events.
  182. */
  183. static const uint PLUGIN_OPTION_SEND_CHANNEL_PRESSURE = 0x020;
  184. /*!
  185. * Send MIDI note after-touch events.
  186. */
  187. static const uint PLUGIN_OPTION_SEND_NOTE_AFTERTOUCH = 0x040;
  188. /*!
  189. * Send MIDI pitch-bend events.
  190. */
  191. static const uint PLUGIN_OPTION_SEND_PITCHBEND = 0x080;
  192. /*!
  193. * Send MIDI all-sounds/notes-off events, single note-offs otherwise.
  194. */
  195. static const uint PLUGIN_OPTION_SEND_ALL_SOUND_OFF = 0x100;
  196. /*!
  197. * Send MIDI bank/program changes.
  198. * @note: This option conflicts with PLUGIN_OPTION_MAP_PROGRAM_CHANGES and cannot be used at the same time.
  199. */
  200. static const uint PLUGIN_OPTION_SEND_PROGRAM_CHANGES = 0x200;
  201. /** @} */
  202. /* ------------------------------------------------------------------------------------------------------------
  203. * Parameter Hints */
  204. /*!
  205. * @defgroup ParameterHints Parameter Hints
  206. *
  207. * Various parameter hints.
  208. * @see CarlaPlugin::getParameterData() and carla_get_parameter_data()
  209. * @{
  210. */
  211. /*!
  212. * Parameter value is boolean.
  213. * It's always at either minimum or maximum value.
  214. */
  215. static const uint PARAMETER_IS_BOOLEAN = 0x001;
  216. /*!
  217. * Parameter value is integer.
  218. */
  219. static const uint PARAMETER_IS_INTEGER = 0x002;
  220. /*!
  221. * Parameter value is logarithmic.
  222. */
  223. static const uint PARAMETER_IS_LOGARITHMIC = 0x004;
  224. /*!
  225. * Parameter is enabled.
  226. * It can be viewed, changed and stored.
  227. */
  228. static const uint PARAMETER_IS_ENABLED = 0x010;
  229. /*!
  230. * Parameter is automable (real-time safe).
  231. */
  232. static const uint PARAMETER_IS_AUTOMABLE = 0x020;
  233. /*!
  234. * Parameter is read-only.
  235. * It cannot be changed.
  236. */
  237. static const uint PARAMETER_IS_READ_ONLY = 0x040;
  238. /*!
  239. * Parameter needs sample rate to work.
  240. * Value and ranges are multiplied by sample rate on usage and divided by sample rate on save.
  241. */
  242. static const uint PARAMETER_USES_SAMPLERATE = 0x100;
  243. /*!
  244. * Parameter uses scale points to define internal values in a meaningful way.
  245. */
  246. static const uint PARAMETER_USES_SCALEPOINTS = 0x200;
  247. /*!
  248. * Parameter uses custom text for displaying its value.
  249. * @see CarlaPlugin::getParameterText() and carla_get_parameter_text()
  250. */
  251. static const uint PARAMETER_USES_CUSTOM_TEXT = 0x400;
  252. /** @} */
  253. /* ------------------------------------------------------------------------------------------------------------
  254. * Patchbay Port Hints */
  255. /*!
  256. * @defgroup PatchbayPortHints Patchbay Port Hints
  257. *
  258. * Various patchbay port hints.
  259. * @{
  260. */
  261. /*!
  262. * Patchbay port is input.
  263. * When this hint is not set, port is assumed to be output.
  264. */
  265. static const uint PATCHBAY_PORT_IS_INPUT = 0x1;
  266. /*!
  267. * Patchbay port is of Audio type.
  268. */
  269. static const uint PATCHBAY_PORT_TYPE_AUDIO = 0x2;
  270. /*!
  271. * Patchbay port is of CV type (Control Voltage).
  272. */
  273. static const uint PATCHBAY_PORT_TYPE_CV = 0x4;
  274. /*!
  275. * Patchbay port is of MIDI type.
  276. */
  277. static const uint PATCHBAY_PORT_TYPE_MIDI = 0x8;
  278. /** @} */
  279. /* ------------------------------------------------------------------------------------------------------------
  280. * Custom Data Types */
  281. /*!
  282. * @defgroup CustomDataTypes Custom Data Types
  283. *
  284. * These types define how the value in the CustomData struct is stored.
  285. * @see CustomData::type
  286. * @{
  287. */
  288. /*!
  289. * Boolean string type URI.
  290. * Only "true" and "false" are valid values.
  291. */
  292. static const char* const CUSTOM_DATA_TYPE_BOOLEAN = "http://kxstudio.sf.net/ns/carla/boolean";
  293. /*!
  294. * Chunk type URI.
  295. */
  296. static const char* const CUSTOM_DATA_TYPE_CHUNK = "http://kxstudio.sf.net/ns/carla/chunk";
  297. /*!
  298. * Property type URI.
  299. */
  300. static const char* const CUSTOM_DATA_TYPE_PROPERTY = "http://kxstudio.sf.net/ns/carla/property";
  301. /*!
  302. * String type URI.
  303. */
  304. static const char* const CUSTOM_DATA_TYPE_STRING = "http://kxstudio.sf.net/ns/carla/string";
  305. /** @} */
  306. /* ------------------------------------------------------------------------------------------------------------
  307. * Custom Data Keys */
  308. /*!
  309. * @defgroup CustomDataKeys Custom Data Keys
  310. *
  311. * Pre-defined keys used internally in Carla.
  312. * @see CustomData::key
  313. * @{
  314. */
  315. /*!
  316. * UI position key.
  317. */
  318. static const char* const CUSTOM_DATA_KEY_UI_POSITION = "CarlaUiPosition";
  319. /*!
  320. * UI size key.
  321. */
  322. static const char* const CUSTOM_DATA_KEY_UI_SIZE = "CarlaUiSize";
  323. /*!
  324. * UI visible key.
  325. */
  326. static const char* const CUSTOM_DATA_KEY_UI_VISIBLE = "CarlaUiVisible";
  327. /** @} */
  328. /* ------------------------------------------------------------------------------------------------------------
  329. * Binary Type */
  330. /*!
  331. * The binary type of a plugin.
  332. */
  333. typedef enum {
  334. /*!
  335. * Null binary type.
  336. */
  337. BINARY_NONE = 0,
  338. /*!
  339. * POSIX 32bit binary.
  340. */
  341. BINARY_POSIX32 = 1,
  342. /*!
  343. * POSIX 64bit binary.
  344. */
  345. BINARY_POSIX64 = 2,
  346. /*!
  347. * Windows 32bit binary.
  348. */
  349. BINARY_WIN32 = 3,
  350. /*!
  351. * Windows 64bit binary.
  352. */
  353. BINARY_WIN64 = 4,
  354. /*!
  355. * Other binary type.
  356. */
  357. BINARY_OTHER = 5
  358. } BinaryType;
  359. /* ------------------------------------------------------------------------------------------------------------
  360. * Plugin Type */
  361. /*!
  362. * Plugin type.
  363. * Some files are handled as if they were plugins.
  364. */
  365. typedef enum {
  366. /*!
  367. * Null plugin type.
  368. */
  369. PLUGIN_NONE = 0,
  370. /*!
  371. * Internal plugin.
  372. */
  373. PLUGIN_INTERNAL = 1,
  374. /*!
  375. * LADSPA plugin.
  376. */
  377. PLUGIN_LADSPA = 2,
  378. /*!
  379. * DSSI plugin.
  380. */
  381. PLUGIN_DSSI = 3,
  382. /*!
  383. * LV2 plugin.
  384. */
  385. PLUGIN_LV2 = 4,
  386. /*!
  387. * VST2 plugin.
  388. */
  389. PLUGIN_VST2 = 5,
  390. /*!
  391. * VST3 plugin.
  392. * @note Windows and MacOS only
  393. */
  394. PLUGIN_VST3 = 6,
  395. /*!
  396. * AU plugin.
  397. * @note MacOS only
  398. */
  399. PLUGIN_AU = 7,
  400. /*!
  401. * GIG file.
  402. */
  403. PLUGIN_GIG = 8,
  404. /*!
  405. * SF2 file (SoundFont).
  406. */
  407. PLUGIN_SF2 = 9,
  408. /*!
  409. * SFZ file.
  410. */
  411. PLUGIN_SFZ = 10,
  412. /*!
  413. * JACK application.
  414. */
  415. PLUGIN_JACK = 11
  416. } PluginType;
  417. /* ------------------------------------------------------------------------------------------------------------
  418. * Plugin Category */
  419. /*!
  420. * Plugin category, which describes the functionality of a plugin.
  421. */
  422. typedef enum {
  423. /*!
  424. * Null plugin category.
  425. */
  426. PLUGIN_CATEGORY_NONE = 0,
  427. /*!
  428. * A synthesizer or generator.
  429. */
  430. PLUGIN_CATEGORY_SYNTH = 1,
  431. /*!
  432. * A delay or reverb.
  433. */
  434. PLUGIN_CATEGORY_DELAY = 2,
  435. /*!
  436. * An equalizer.
  437. */
  438. PLUGIN_CATEGORY_EQ = 3,
  439. /*!
  440. * A filter.
  441. */
  442. PLUGIN_CATEGORY_FILTER = 4,
  443. /*!
  444. * A distortion plugin.
  445. */
  446. PLUGIN_CATEGORY_DISTORTION = 5,
  447. /*!
  448. * A 'dynamic' plugin (amplifier, compressor, gate, etc).
  449. */
  450. PLUGIN_CATEGORY_DYNAMICS = 6,
  451. /*!
  452. * A 'modulator' plugin (chorus, flanger, phaser, etc).
  453. */
  454. PLUGIN_CATEGORY_MODULATOR = 7,
  455. /*!
  456. * An 'utility' plugin (analyzer, converter, mixer, etc).
  457. */
  458. PLUGIN_CATEGORY_UTILITY = 8,
  459. /*!
  460. * Miscellaneous plugin (used to check if the plugin has a category).
  461. */
  462. PLUGIN_CATEGORY_OTHER = 9
  463. } PluginCategory;
  464. /* ------------------------------------------------------------------------------------------------------------
  465. * Parameter Type */
  466. /*!
  467. * Plugin parameter type.
  468. */
  469. typedef enum {
  470. /*!
  471. * Null parameter type.
  472. */
  473. PARAMETER_UNKNOWN = 0,
  474. /*!
  475. * Input parameter.
  476. */
  477. PARAMETER_INPUT = 1,
  478. /*!
  479. * Ouput parameter.
  480. */
  481. PARAMETER_OUTPUT = 2
  482. } ParameterType;
  483. /* ------------------------------------------------------------------------------------------------------------
  484. * Internal Parameter Index */
  485. /*!
  486. * Special parameters used internally in Carla.
  487. * Plugins do not know about their existence.
  488. */
  489. typedef enum {
  490. /*!
  491. * Null parameter.
  492. */
  493. PARAMETER_NULL = -1,
  494. #ifndef BUILD_BRIDGE
  495. /*!
  496. * Active parameter, boolean type.
  497. * Default is 'false'.
  498. */
  499. PARAMETER_ACTIVE = -2,
  500. /*!
  501. * Dry/Wet parameter.
  502. * Range 0.0...1.0; default is 1.0.
  503. */
  504. PARAMETER_DRYWET = -3,
  505. /*!
  506. * Volume parameter.
  507. * Range 0.0...1.27; default is 1.0.
  508. */
  509. PARAMETER_VOLUME = -4,
  510. /*!
  511. * Stereo Balance-Left parameter.
  512. * Range -1.0...1.0; default is -1.0.
  513. */
  514. PARAMETER_BALANCE_LEFT = -5,
  515. /*!
  516. * Stereo Balance-Right parameter.
  517. * Range -1.0...1.0; default is 1.0.
  518. */
  519. PARAMETER_BALANCE_RIGHT = -6,
  520. /*!
  521. * Mono Panning parameter.
  522. * Range -1.0...1.0; default is 0.0.
  523. */
  524. PARAMETER_PANNING = -7,
  525. /*!
  526. * MIDI Control channel, integer type.
  527. * Range -1...15 (-1 = off).
  528. */
  529. PARAMETER_CTRL_CHANNEL = -8,
  530. #endif
  531. /*!
  532. * Max value, defined only for convenience.
  533. */
  534. PARAMETER_MAX = -9
  535. } InternalParameterIndex;
  536. /* ------------------------------------------------------------------------------------------------------------
  537. * Engine Callback Opcode */
  538. /*!
  539. * Engine callback opcodes.
  540. * Front-ends must never block indefinitely during a callback.
  541. * @see EngineCallbackFunc, CarlaEngine::setCallback() and carla_set_engine_callback()
  542. */
  543. typedef enum {
  544. /*!
  545. * Debug.
  546. * This opcode is undefined and used only for testing purposes.
  547. */
  548. ENGINE_CALLBACK_DEBUG = 0,
  549. /*!
  550. * A plugin has been added.
  551. * @a pluginId Plugin Id
  552. * @a valueStr Plugin name
  553. */
  554. ENGINE_CALLBACK_PLUGIN_ADDED = 1,
  555. /*!
  556. * A plugin has been removed.
  557. * @a pluginId Plugin Id
  558. */
  559. ENGINE_CALLBACK_PLUGIN_REMOVED = 2,
  560. /*!
  561. * A plugin has been renamed.
  562. * @a pluginId Plugin Id
  563. * @a valueStr New plugin name
  564. */
  565. ENGINE_CALLBACK_PLUGIN_RENAMED = 3,
  566. /*!
  567. * A plugin has become unavailable.
  568. * @a pluginId Plugin Id
  569. * @a valueStr Related error string
  570. */
  571. ENGINE_CALLBACK_PLUGIN_UNAVAILABLE = 4,
  572. /*!
  573. * A parameter value has changed.
  574. * @a pluginId Plugin Id
  575. * @a value1 Parameter index
  576. * @a value3 New parameter value
  577. */
  578. ENGINE_CALLBACK_PARAMETER_VALUE_CHANGED = 5,
  579. /*!
  580. * A parameter default has changed.
  581. * @a pluginId Plugin Id
  582. * @a value1 Parameter index
  583. * @a value3 New default value
  584. */
  585. ENGINE_CALLBACK_PARAMETER_DEFAULT_CHANGED = 6,
  586. #ifndef BUILD_BRIDGE
  587. /*!
  588. * A parameter's MIDI CC has changed.
  589. * @a pluginId Plugin Id
  590. * @a value1 Parameter index
  591. * @a value2 New MIDI CC
  592. */
  593. ENGINE_CALLBACK_PARAMETER_MIDI_CC_CHANGED = 7,
  594. /*!
  595. * A parameter's MIDI channel has changed.
  596. * @a pluginId Plugin Id
  597. * @a value1 Parameter index
  598. * @a value2 New MIDI channel
  599. */
  600. ENGINE_CALLBACK_PARAMETER_MIDI_CHANNEL_CHANGED = 8,
  601. /*!
  602. * A plugin option has changed.
  603. * @a pluginId Plugin Id
  604. * @a value1 Option
  605. * @a value2 New on/off state (1 for on, 0 for off)
  606. * @see PluginOptions
  607. */
  608. ENGINE_CALLBACK_OPTION_CHANGED = 9,
  609. #endif
  610. /*!
  611. * The current program of a plugin has changed.
  612. * @a pluginId Plugin Id
  613. * @a value1 New program index
  614. */
  615. ENGINE_CALLBACK_PROGRAM_CHANGED = 10,
  616. /*!
  617. * The current MIDI program of a plugin has changed.
  618. * @a pluginId Plugin Id
  619. * @a value1 New MIDI program index
  620. */
  621. ENGINE_CALLBACK_MIDI_PROGRAM_CHANGED = 11,
  622. /*!
  623. * A plugin's custom UI state has changed.
  624. * @a pluginId Plugin Id
  625. * @a value1 New state, as follows:
  626. * 0: UI is now hidden
  627. * 1: UI is now visible
  628. * -1: UI has crashed and should not be shown again
  629. */
  630. ENGINE_CALLBACK_UI_STATE_CHANGED = 12,
  631. /*!
  632. * A note has been pressed.
  633. * @a pluginId Plugin Id
  634. * @a value1 Channel
  635. * @a value2 Note
  636. * @a value3 Velocity
  637. */
  638. ENGINE_CALLBACK_NOTE_ON = 13,
  639. /*!
  640. * A note has been released.
  641. * @a pluginId Plugin Id
  642. * @a value1 Channel
  643. * @a value2 Note
  644. */
  645. ENGINE_CALLBACK_NOTE_OFF = 14,
  646. /*!
  647. * A plugin needs update.
  648. * @a pluginId Plugin Id
  649. */
  650. ENGINE_CALLBACK_UPDATE = 15,
  651. /*!
  652. * A plugin's data/information has changed.
  653. * @a pluginId Plugin Id
  654. */
  655. ENGINE_CALLBACK_RELOAD_INFO = 16,
  656. /*!
  657. * A plugin's parameters have changed.
  658. * @a pluginId Plugin Id
  659. */
  660. ENGINE_CALLBACK_RELOAD_PARAMETERS = 17,
  661. /*!
  662. * A plugin's programs have changed.
  663. * @a pluginId Plugin Id
  664. */
  665. ENGINE_CALLBACK_RELOAD_PROGRAMS = 18,
  666. /*!
  667. * A plugin state has changed.
  668. * @a pluginId Plugin Id
  669. */
  670. ENGINE_CALLBACK_RELOAD_ALL = 19,
  671. #ifndef BUILD_BRIDGE
  672. /*!
  673. * A patchbay client has been added.
  674. * @a pluginId Client Id
  675. * @a value1 Client icon
  676. * @a value2 Plugin Id (-1 if not a plugin)
  677. * @a valueStr Client name
  678. * @see PatchbayIcon
  679. */
  680. ENGINE_CALLBACK_PATCHBAY_CLIENT_ADDED = 20,
  681. /*!
  682. * A patchbay client has been removed.
  683. * @a pluginId Client Id
  684. */
  685. ENGINE_CALLBACK_PATCHBAY_CLIENT_REMOVED = 21,
  686. /*!
  687. * A patchbay client has been renamed.
  688. * @a pluginId Client Id
  689. * @a valueStr New client name
  690. */
  691. ENGINE_CALLBACK_PATCHBAY_CLIENT_RENAMED = 22,
  692. /*!
  693. * A patchbay client data has changed.
  694. * @a pluginId Client Id
  695. * @a value1 New icon
  696. * @a value2 New plugin Id (-1 if not a plugin)
  697. * @see PatchbayIcon
  698. */
  699. ENGINE_CALLBACK_PATCHBAY_CLIENT_DATA_CHANGED = 23,
  700. /*!
  701. * A patchbay port has been added.
  702. * @a pluginId Client Id
  703. * @a value1 Port Id
  704. * @a value2 Port hints
  705. * @a valueStr Port name
  706. * @see PatchbayPortHints
  707. */
  708. ENGINE_CALLBACK_PATCHBAY_PORT_ADDED = 24,
  709. /*!
  710. * A patchbay port has been removed.
  711. * @a pluginId Client Id
  712. * @a value1 Port Id
  713. */
  714. ENGINE_CALLBACK_PATCHBAY_PORT_REMOVED = 25,
  715. /*!
  716. * A patchbay port has been renamed.
  717. * @a pluginId Client Id
  718. * @a value1 Port Id
  719. * @a valueStr New port name
  720. */
  721. ENGINE_CALLBACK_PATCHBAY_PORT_RENAMED = 26,
  722. /*!
  723. * A patchbay connection has been added.
  724. * @a pluginId Connection Id
  725. * @a valueStr Out group and port plus in group and port, in "og:op:ig:ip" syntax.
  726. */
  727. ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED = 27,
  728. /*!
  729. * A patchbay connection has been removed.
  730. * @a pluginId Connection Id
  731. */
  732. ENGINE_CALLBACK_PATCHBAY_CONNECTION_REMOVED = 28,
  733. #endif
  734. /*!
  735. * Engine started.
  736. * @a value1 Process mode
  737. * @a value2 Transport mode
  738. * @a valuestr Engine driver
  739. * @see EngineProcessMode
  740. * @see EngineTransportMode
  741. */
  742. ENGINE_CALLBACK_ENGINE_STARTED = 29,
  743. /*!
  744. * Engine stopped.
  745. */
  746. ENGINE_CALLBACK_ENGINE_STOPPED = 30,
  747. /*!
  748. * Engine process mode has changed.
  749. * @a value1 New process mode
  750. * @see EngineProcessMode
  751. */
  752. ENGINE_CALLBACK_PROCESS_MODE_CHANGED = 31,
  753. /*!
  754. * Engine transport mode has changed.
  755. * @a value1 New transport mode
  756. * @see EngineTransportMode
  757. */
  758. ENGINE_CALLBACK_TRANSPORT_MODE_CHANGED = 32,
  759. /*!
  760. * Engine buffer-size changed.
  761. * @a value1 New buffer size
  762. */
  763. ENGINE_CALLBACK_BUFFER_SIZE_CHANGED = 33,
  764. /*!
  765. * Engine sample-rate changed.
  766. * @a value3 New sample rate
  767. */
  768. ENGINE_CALLBACK_SAMPLE_RATE_CHANGED = 34,
  769. /*!
  770. * NSM callback.
  771. * (Work in progress, values are not defined yet)
  772. */
  773. ENGINE_CALLBACK_NSM = 35,
  774. /*!
  775. * Idle frontend.
  776. * This is used by the engine during long operations that might block the frontend,
  777. * giving it the possibility to idle while the operation is still in place.
  778. */
  779. ENGINE_CALLBACK_IDLE = 36,
  780. /*!
  781. * Show a message as information.
  782. * @a valueStr The message
  783. */
  784. ENGINE_CALLBACK_INFO = 37,
  785. /*!
  786. * Show a message as an error.
  787. * @a valueStr The message
  788. */
  789. ENGINE_CALLBACK_ERROR = 38,
  790. /*!
  791. * The engine has crashed or malfunctioned and will no longer work.
  792. */
  793. ENGINE_CALLBACK_QUIT = 39
  794. } EngineCallbackOpcode;
  795. /* ------------------------------------------------------------------------------------------------------------
  796. * Engine Option */
  797. /*!
  798. * Engine options.
  799. * @see CarlaEngine::getOptions(), CarlaEngine::setOption() and carla_set_engine_option()
  800. */
  801. typedef enum {
  802. /*!
  803. * Debug.
  804. * This option is undefined and used only for testing purposes.
  805. */
  806. ENGINE_OPTION_DEBUG = 0,
  807. /*!
  808. * Set the engine processing mode.
  809. * Default is ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS on Linux and ENGINE_PROCESS_MODE_PATCHBAY for all other OSes.
  810. * @see EngineProcessMode
  811. */
  812. ENGINE_OPTION_PROCESS_MODE = 1,
  813. /*!
  814. * Set the engine transport mode.
  815. * Default is ENGINE_TRANSPORT_MODE_JACK on Linux and ENGINE_TRANSPORT_MODE_INTERNAL for all other OSes.
  816. * @see EngineTransportMode
  817. */
  818. ENGINE_OPTION_TRANSPORT_MODE = 2,
  819. /*!
  820. * Force mono plugins as stereo, by running 2 instances at the same time.
  821. * Default is false, but always true when process mode is ENGINE_PROCESS_MODE_CONTINUOUS_RACK.
  822. * @note Not supported by all plugins
  823. * @see PLUGIN_OPTION_FORCE_STEREO
  824. */
  825. ENGINE_OPTION_FORCE_STEREO = 3,
  826. /*!
  827. * Use plugin bridges whenever possible.
  828. * Default is no, EXPERIMENTAL.
  829. */
  830. ENGINE_OPTION_PREFER_PLUGIN_BRIDGES = 4,
  831. /*!
  832. * Use UI bridges whenever possible, otherwise UIs will be directly handled in the main backend thread.
  833. * Default is yes.
  834. */
  835. ENGINE_OPTION_PREFER_UI_BRIDGES = 5,
  836. /*!
  837. * Make custom plugin UIs always-on-top.
  838. * Default is yes.
  839. */
  840. ENGINE_OPTION_UIS_ALWAYS_ON_TOP = 6,
  841. /*!
  842. * Maximum number of parameters allowed.
  843. * Default is MAX_DEFAULT_PARAMETERS.
  844. */
  845. ENGINE_OPTION_MAX_PARAMETERS = 7,
  846. /*!
  847. * Timeout value for how much to wait for UI bridges to respond, in milliseconds.
  848. * Default is 4000 (4 seconds).
  849. */
  850. ENGINE_OPTION_UI_BRIDGES_TIMEOUT = 8,
  851. /*!
  852. * Number of audio periods.
  853. * Default is 2.
  854. */
  855. ENGINE_OPTION_AUDIO_NUM_PERIODS = 9,
  856. /*!
  857. * Audio buffer size.
  858. * Default is 512.
  859. */
  860. ENGINE_OPTION_AUDIO_BUFFER_SIZE = 10,
  861. /*!
  862. * Audio sample rate.
  863. * Default is 44100.
  864. */
  865. ENGINE_OPTION_AUDIO_SAMPLE_RATE = 11,
  866. /*!
  867. * Audio device (within a driver).
  868. * Default unset.
  869. */
  870. ENGINE_OPTION_AUDIO_DEVICE = 12,
  871. /*!
  872. * Set path used for a specific plugin type.
  873. * Uses value as the plugin format, valueStr as actual path.
  874. * @see PluginType
  875. */
  876. ENGINE_OPTION_PLUGIN_PATH = 13,
  877. /*!
  878. * Set path to the binary files.
  879. * Default unset.
  880. * @note Must be set for plugin and UI bridges to work
  881. */
  882. ENGINE_OPTION_PATH_BINARIES = 14,
  883. /*!
  884. * Set path to the resource files.
  885. * Default unset.
  886. * @note Must be set for some internal plugins to work
  887. */
  888. ENGINE_OPTION_PATH_RESOURCES = 15,
  889. /*!
  890. * Prevent bad plugin and UI behaviour.
  891. * @note: Linux only
  892. */
  893. ENGINE_OPTION_PREVENT_BAD_BEHAVIOUR = 16,
  894. /*!
  895. * Set frontend winId, used to define as parent window for plugin UIs.
  896. */
  897. ENGINE_OPTION_FRONTEND_WIN_ID = 17,
  898. /*!
  899. * Capture console output into debug callbacks.
  900. */
  901. ENGINE_OPTION_DEBUG_CONSOLE_OUTPUT = 18
  902. } EngineOption;
  903. /* ------------------------------------------------------------------------------------------------------------
  904. * Engine Process Mode */
  905. /*!
  906. * Engine process mode.
  907. * @see ENGINE_OPTION_PROCESS_MODE
  908. */
  909. typedef enum {
  910. /*!
  911. * Single client mode.
  912. * Inputs and outputs are added dynamically as needed by plugins.
  913. */
  914. ENGINE_PROCESS_MODE_SINGLE_CLIENT = 0,
  915. /*!
  916. * Multiple client mode.
  917. * It has 1 master client + 1 client per plugin.
  918. */
  919. ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS = 1,
  920. /*!
  921. * Single client, 'rack' mode.
  922. * Processes plugins in order of Id, with forced stereo always on.
  923. */
  924. ENGINE_PROCESS_MODE_CONTINUOUS_RACK = 2,
  925. /*!
  926. * Single client, 'patchbay' mode.
  927. */
  928. ENGINE_PROCESS_MODE_PATCHBAY = 3,
  929. /*!
  930. * Special mode, used in plugin-bridges only.
  931. */
  932. ENGINE_PROCESS_MODE_BRIDGE = 4
  933. } EngineProcessMode;
  934. /* ------------------------------------------------------------------------------------------------------------
  935. * Engine Transport Mode */
  936. /*!
  937. * Engine transport mode.
  938. * @see ENGINE_OPTION_TRANSPORT_MODE
  939. */
  940. typedef enum {
  941. /*!
  942. * Internal transport mode.
  943. */
  944. ENGINE_TRANSPORT_MODE_INTERNAL = 0,
  945. /*!
  946. * Transport from JACK.
  947. * Only available if driver name is "JACK".
  948. */
  949. ENGINE_TRANSPORT_MODE_JACK = 1,
  950. /*!
  951. * Transport from host, used when Carla is a plugin.
  952. */
  953. ENGINE_TRANSPORT_MODE_PLUGIN = 2,
  954. /*!
  955. * Special mode, used in plugin-bridges only.
  956. */
  957. ENGINE_TRANSPORT_MODE_BRIDGE = 3
  958. } EngineTransportMode;
  959. /* ------------------------------------------------------------------------------------------------------------
  960. * File Callback Opcode */
  961. /*!
  962. * File callback opcodes.
  963. * Front-ends must always block-wait for user input.
  964. * @see FileCallbackFunc, CarlaEngine::setFileCallback() and carla_set_file_callback()
  965. */
  966. typedef enum {
  967. /*!
  968. * Debug.
  969. * This opcode is undefined and used only for testing purposes.
  970. */
  971. FILE_CALLBACK_DEBUG = 0,
  972. /*!
  973. * Open file or folder.
  974. */
  975. FILE_CALLBACK_OPEN = 1,
  976. /*!
  977. * Save file or folder.
  978. */
  979. FILE_CALLBACK_SAVE = 2
  980. } FileCallbackOpcode;
  981. /* ------------------------------------------------------------------------------------------------------------
  982. * Patchbay Icon */
  983. /*!
  984. * The icon of a patchbay client/group.
  985. */
  986. enum PatchbayIcon {
  987. /*!
  988. * Generic application icon.
  989. * Used for all non-plugin clients that don't have a specific icon.
  990. */
  991. PATCHBAY_ICON_APPLICATION = 0,
  992. /*!
  993. * Plugin icon.
  994. * Used for all plugin clients that don't have a specific icon.
  995. */
  996. PATCHBAY_ICON_PLUGIN = 1,
  997. /*!
  998. * Hardware icon.
  999. * Used for hardware (audio or MIDI) clients.
  1000. */
  1001. PATCHBAY_ICON_HARDWARE = 2,
  1002. /*!
  1003. * Carla icon.
  1004. * Used for the main app.
  1005. */
  1006. PATCHBAY_ICON_CARLA = 3,
  1007. /*!
  1008. * DISTRHO icon.
  1009. * Used for DISTRHO based plugins.
  1010. */
  1011. PATCHBAY_ICON_DISTRHO = 4,
  1012. /*!
  1013. * File icon.
  1014. * Used for file type plugins (like GIG and SF2).
  1015. */
  1016. PATCHBAY_ICON_FILE = 5
  1017. };
  1018. /* ------------------------------------------------------------------------------------------------------------
  1019. * Carla Backend API (C stuff) */
  1020. /*!
  1021. * Engine callback function.
  1022. * Front-ends must never block indefinitely during a callback.
  1023. * @see EngineCallbackOpcode, CarlaEngine::setCallback() and carla_set_engine_callback()
  1024. */
  1025. typedef void (*EngineCallbackFunc)(void* ptr, EngineCallbackOpcode action, uint pluginId, int value1, int value2, float value3, const char* valueStr);
  1026. /*!
  1027. * File callback function.
  1028. * @see FileCallbackOpcode
  1029. */
  1030. typedef const char* (*FileCallbackFunc)(void* ptr, FileCallbackOpcode action, bool isDir, const char* title, const char* filter);
  1031. /*!
  1032. * Parameter data.
  1033. */
  1034. typedef struct {
  1035. /*!
  1036. * This parameter type.
  1037. */
  1038. ParameterType type;
  1039. /*!
  1040. * This parameter hints.
  1041. * @see ParameterHints
  1042. */
  1043. uint hints;
  1044. /*!
  1045. * Index as seen by Carla.
  1046. */
  1047. int32_t index;
  1048. /*!
  1049. * Real index as seen by plugins.
  1050. */
  1051. int32_t rindex;
  1052. /*!
  1053. * Currently mapped MIDI CC.
  1054. * A value lower than 0 means invalid or unused.
  1055. * Maximum allowed value is 119 (0x77).
  1056. */
  1057. int16_t midiCC;
  1058. /*!
  1059. * Currently mapped MIDI channel.
  1060. * Counts from 0 to 15.
  1061. */
  1062. uint8_t midiChannel;
  1063. } ParameterData;
  1064. /*!
  1065. * Parameter ranges.
  1066. */
  1067. typedef struct {
  1068. /*!
  1069. * Default value.
  1070. */
  1071. float def;
  1072. /*!
  1073. * Minimum value.
  1074. */
  1075. float min;
  1076. /*!
  1077. * Maximum value.
  1078. */
  1079. float max;
  1080. /*!
  1081. * Regular, single step value.
  1082. */
  1083. float step;
  1084. /*!
  1085. * Small step value.
  1086. */
  1087. float stepSmall;
  1088. /*!
  1089. * Large step value.
  1090. */
  1091. float stepLarge;
  1092. #ifdef __cplusplus
  1093. /*!
  1094. * Fix the default value within range.
  1095. */
  1096. void fixDefault() noexcept
  1097. {
  1098. fixValue(def);
  1099. }
  1100. /*!
  1101. * Fix a value within range.
  1102. */
  1103. void fixValue(float& value) const noexcept
  1104. {
  1105. if (value < min)
  1106. value = min;
  1107. else if (value > max)
  1108. value = max;
  1109. }
  1110. /*!
  1111. * Get a fixed value within range.
  1112. */
  1113. const float& getFixedValue(const float& value) const noexcept
  1114. {
  1115. if (value <= min)
  1116. return min;
  1117. if (value >= max)
  1118. return max;
  1119. return value;
  1120. }
  1121. /*!
  1122. * Get a value normalized to 0.0<->1.0.
  1123. */
  1124. float getNormalizedValue(const float& value) const noexcept
  1125. {
  1126. const float normValue((value - min) / (max - min));
  1127. if (normValue <= 0.0f)
  1128. return 0.0f;
  1129. if (normValue >= 1.0f)
  1130. return 1.0f;
  1131. return normValue;
  1132. }
  1133. /*!
  1134. * Get a value normalized to 0.0<->1.0, fixed within range.
  1135. */
  1136. float getFixedAndNormalizedValue(const float& value) const noexcept
  1137. {
  1138. if (value <= min)
  1139. return 0.0f;
  1140. if (value >= max)
  1141. return 1.0f;
  1142. const float normValue((value - min) / (max - min));
  1143. if (normValue <= 0.0f)
  1144. return 0.0f;
  1145. if (normValue >= 1.0f)
  1146. return 1.0f;
  1147. return normValue;
  1148. }
  1149. /*!
  1150. * Get a proper value previously normalized to 0.0<->1.0.
  1151. */
  1152. float getUnnormalizedValue(const float& value) const noexcept
  1153. {
  1154. if (value <= 0.0f)
  1155. return min;
  1156. if (value >= 1.0f)
  1157. return max;
  1158. return value * (max - min) + min;
  1159. }
  1160. /*!
  1161. * Get a logarithmic value previously normalized to 0.0<->1.0.
  1162. */
  1163. float getUnnormalizedLogValue(const float& value) const noexcept
  1164. {
  1165. if (value <= 0.0f)
  1166. return min;
  1167. if (value >= 1.0f)
  1168. return max;
  1169. return min * std::pow(max/min, value);
  1170. }
  1171. #endif /* __cplusplus */
  1172. } ParameterRanges;
  1173. /*!
  1174. * MIDI Program data.
  1175. */
  1176. typedef struct {
  1177. /*!
  1178. * MIDI bank.
  1179. */
  1180. uint32_t bank;
  1181. /*!
  1182. * MIDI program.
  1183. */
  1184. uint32_t program;
  1185. /*!
  1186. * MIDI program name.
  1187. */
  1188. const char* name;
  1189. } MidiProgramData;
  1190. /*!
  1191. * Custom data, used for saving key:value 'dictionaries'.
  1192. */
  1193. typedef struct {
  1194. /*!
  1195. * Value type, in URI form.
  1196. * @see CustomDataTypes
  1197. */
  1198. const char* type;
  1199. /*!
  1200. * Key.
  1201. * @see CustomDataKeys
  1202. */
  1203. const char* key;
  1204. /*!
  1205. * Value.
  1206. */
  1207. const char* value;
  1208. #ifdef __cplusplus
  1209. /*!
  1210. * Check if valid.
  1211. */
  1212. bool isValid() const noexcept
  1213. {
  1214. if (type == nullptr || type[0] == '\0') return false;
  1215. if (key == nullptr || key [0] == '\0') return false;
  1216. if (value == nullptr) return false;
  1217. return true;
  1218. }
  1219. #endif /* __cplusplus */
  1220. } CustomData;
  1221. /*!
  1222. * Engine driver device information.
  1223. */
  1224. typedef struct {
  1225. /*!
  1226. * This driver device hints.
  1227. * @see EngineDriverHints
  1228. */
  1229. uint hints;
  1230. /*!
  1231. * Available buffer sizes.
  1232. * Terminated with 0.
  1233. */
  1234. const uint32_t* bufferSizes;
  1235. /*!
  1236. * Available sample rates.
  1237. * Terminated with 0.0.
  1238. */
  1239. const double* sampleRates;
  1240. } EngineDriverDeviceInfo;
  1241. /** @} */
  1242. #ifdef __cplusplus
  1243. /* Forward declarations of commonly used Carla classes */
  1244. class CarlaEngine;
  1245. class CarlaEngineClient;
  1246. class CarlaPlugin;
  1247. /* End namespace */
  1248. CARLA_BACKEND_END_NAMESPACE
  1249. #endif
  1250. #endif /* CARLA_BACKEND_H_INCLUDED */