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.

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