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.

1547 lines
34KB

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