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.

1555 lines
34KB

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