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.

1554 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 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 = 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 valuestr Engine driver
  738. * @see EngineProcessMode
  739. * @see EngineTransportMode
  740. */
  741. ENGINE_CALLBACK_ENGINE_STARTED = 29,
  742. /*!
  743. * Engine stopped.
  744. */
  745. ENGINE_CALLBACK_ENGINE_STOPPED = 30,
  746. /*!
  747. * Engine process mode has changed.
  748. * @a value1 New process mode
  749. * @see EngineProcessMode
  750. */
  751. ENGINE_CALLBACK_PROCESS_MODE_CHANGED = 31,
  752. /*!
  753. * Engine transport mode has changed.
  754. * @a value1 New transport mode
  755. * @see EngineTransportMode
  756. */
  757. ENGINE_CALLBACK_TRANSPORT_MODE_CHANGED = 32,
  758. /*!
  759. * Engine buffer-size changed.
  760. * @a value1 New buffer size
  761. */
  762. ENGINE_CALLBACK_BUFFER_SIZE_CHANGED = 33,
  763. /*!
  764. * Engine sample-rate changed.
  765. * @a value3 New sample rate
  766. */
  767. ENGINE_CALLBACK_SAMPLE_RATE_CHANGED = 34,
  768. /*!
  769. * Project has finished loading.
  770. */
  771. ENGINE_CALLBACK_PROJECT_LOAD_FINISHED = 35,
  772. /*!
  773. * NSM callback.
  774. * (Work in progress, values are not defined yet)
  775. */
  776. ENGINE_CALLBACK_NSM = 36,
  777. /*!
  778. * Idle frontend.
  779. * This is used by the engine during long operations that might block the frontend,
  780. * giving it the possibility to idle while the operation is still in place.
  781. */
  782. ENGINE_CALLBACK_IDLE = 37,
  783. /*!
  784. * Show a message as information.
  785. * @a valueStr The message
  786. */
  787. ENGINE_CALLBACK_INFO = 38,
  788. /*!
  789. * Show a message as an error.
  790. * @a valueStr The message
  791. */
  792. ENGINE_CALLBACK_ERROR = 39,
  793. /*!
  794. * The engine has crashed or malfunctioned and will no longer work.
  795. */
  796. ENGINE_CALLBACK_QUIT = 40
  797. } EngineCallbackOpcode;
  798. /* ------------------------------------------------------------------------------------------------------------
  799. * Engine Option */
  800. /*!
  801. * Engine options.
  802. * @see CarlaEngine::getOptions(), CarlaEngine::setOption() and carla_set_engine_option()
  803. */
  804. typedef enum {
  805. /*!
  806. * Debug.
  807. * This option is undefined and used only for testing purposes.
  808. */
  809. ENGINE_OPTION_DEBUG = 0,
  810. /*!
  811. * Set the engine processing mode.
  812. * Default is ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS on Linux and ENGINE_PROCESS_MODE_PATCHBAY for all other OSes.
  813. * @see EngineProcessMode
  814. */
  815. ENGINE_OPTION_PROCESS_MODE = 1,
  816. /*!
  817. * Set the engine transport mode.
  818. * Default is ENGINE_TRANSPORT_MODE_JACK on Linux and ENGINE_TRANSPORT_MODE_INTERNAL for all other OSes.
  819. * @see EngineTransportMode
  820. */
  821. ENGINE_OPTION_TRANSPORT_MODE = 2,
  822. /*!
  823. * Force mono plugins as stereo, by running 2 instances at the same time.
  824. * Default is false, but always true when process mode is ENGINE_PROCESS_MODE_CONTINUOUS_RACK.
  825. * @note Not supported by all plugins
  826. * @see PLUGIN_OPTION_FORCE_STEREO
  827. */
  828. ENGINE_OPTION_FORCE_STEREO = 3,
  829. /*!
  830. * Use plugin bridges whenever possible.
  831. * Default is no, EXPERIMENTAL.
  832. */
  833. ENGINE_OPTION_PREFER_PLUGIN_BRIDGES = 4,
  834. /*!
  835. * Use UI bridges whenever possible, otherwise UIs will be directly handled in the main backend thread.
  836. * Default is yes.
  837. */
  838. ENGINE_OPTION_PREFER_UI_BRIDGES = 5,
  839. /*!
  840. * Make custom plugin UIs always-on-top.
  841. * Default is yes.
  842. */
  843. ENGINE_OPTION_UIS_ALWAYS_ON_TOP = 6,
  844. /*!
  845. * Maximum number of parameters allowed.
  846. * Default is MAX_DEFAULT_PARAMETERS.
  847. */
  848. ENGINE_OPTION_MAX_PARAMETERS = 7,
  849. /*!
  850. * Timeout value for how much to wait for UI bridges to respond, in milliseconds.
  851. * Default is 4000 (4 seconds).
  852. */
  853. ENGINE_OPTION_UI_BRIDGES_TIMEOUT = 8,
  854. /*!
  855. * Number of audio periods.
  856. * Default is 2.
  857. */
  858. ENGINE_OPTION_AUDIO_NUM_PERIODS = 9,
  859. /*!
  860. * Audio buffer size.
  861. * Default is 512.
  862. */
  863. ENGINE_OPTION_AUDIO_BUFFER_SIZE = 10,
  864. /*!
  865. * Audio sample rate.
  866. * Default is 44100.
  867. */
  868. ENGINE_OPTION_AUDIO_SAMPLE_RATE = 11,
  869. /*!
  870. * Audio device (within a driver).
  871. * Default unset.
  872. */
  873. ENGINE_OPTION_AUDIO_DEVICE = 12,
  874. /*!
  875. * Set path used for a specific plugin type.
  876. * Uses value as the plugin format, valueStr as actual path.
  877. * @see PluginType
  878. */
  879. ENGINE_OPTION_PLUGIN_PATH = 13,
  880. /*!
  881. * Set path to the binary files.
  882. * Default unset.
  883. * @note Must be set for plugin and UI bridges to work
  884. */
  885. ENGINE_OPTION_PATH_BINARIES = 14,
  886. /*!
  887. * Set path to the resource files.
  888. * Default unset.
  889. * @note Must be set for some internal plugins to work
  890. */
  891. ENGINE_OPTION_PATH_RESOURCES = 15,
  892. /*!
  893. * Prevent bad plugin and UI behaviour.
  894. * @note: Linux only
  895. */
  896. ENGINE_OPTION_PREVENT_BAD_BEHAVIOUR = 16,
  897. /*!
  898. * Set frontend winId, used to define as parent window for plugin UIs.
  899. */
  900. ENGINE_OPTION_FRONTEND_WIN_ID = 17,
  901. #ifndef CARLA_OS_WIN
  902. /*!
  903. * Set path to wine executable.
  904. */
  905. ENGINE_OPTION_WINE_EXECUTABLE = 18,
  906. /*!
  907. * Enable automatic wineprefix detection.
  908. */
  909. ENGINE_OPTION_WINE_AUTO_PREFIX = 19,
  910. /*!
  911. * Fallback wineprefix to use if automatic detection fails or is disabled, and WINEPREFIX is not set.
  912. */
  913. ENGINE_OPTION_WINE_FALLBACK_PREFIX = 20,
  914. /*!
  915. * Enable realtime priority for Wine application and server threads.
  916. */
  917. ENGINE_OPTION_WINE_RT_PRIO_ENABLED = 21,
  918. /*!
  919. * Base realtime priority for Wine threads.
  920. */
  921. ENGINE_OPTION_WINE_BASE_RT_PRIO = 22,
  922. /*!
  923. * Wine server realtime priority.
  924. */
  925. ENGINE_OPTION_WINE_SERVER_RT_PRIO = 23,
  926. #endif
  927. /*!
  928. * Capture console output into debug callbacks.
  929. */
  930. ENGINE_OPTION_DEBUG_CONSOLE_OUTPUT = 24
  931. } EngineOption;
  932. /* ------------------------------------------------------------------------------------------------------------
  933. * Engine Process Mode */
  934. /*!
  935. * Engine process mode.
  936. * @see ENGINE_OPTION_PROCESS_MODE
  937. */
  938. typedef enum {
  939. /*!
  940. * Single client mode.
  941. * Inputs and outputs are added dynamically as needed by plugins.
  942. */
  943. ENGINE_PROCESS_MODE_SINGLE_CLIENT = 0,
  944. /*!
  945. * Multiple client mode.
  946. * It has 1 master client + 1 client per plugin.
  947. */
  948. ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS = 1,
  949. /*!
  950. * Single client, 'rack' mode.
  951. * Processes plugins in order of Id, with forced stereo always on.
  952. */
  953. ENGINE_PROCESS_MODE_CONTINUOUS_RACK = 2,
  954. /*!
  955. * Single client, 'patchbay' mode.
  956. */
  957. ENGINE_PROCESS_MODE_PATCHBAY = 3,
  958. /*!
  959. * Special mode, used in plugin-bridges only.
  960. */
  961. ENGINE_PROCESS_MODE_BRIDGE = 4
  962. } EngineProcessMode;
  963. /* ------------------------------------------------------------------------------------------------------------
  964. * Engine Transport Mode */
  965. /*!
  966. * Engine transport mode.
  967. * @see ENGINE_OPTION_TRANSPORT_MODE
  968. */
  969. typedef enum {
  970. /*!
  971. * No transport.
  972. */
  973. ENGINE_TRANSPORT_MODE_DISABLED = 0,
  974. /*!
  975. * Internal transport mode.
  976. */
  977. ENGINE_TRANSPORT_MODE_INTERNAL = 1,
  978. /*!
  979. * Transport from JACK.
  980. * Only available if driver name is "JACK".
  981. */
  982. ENGINE_TRANSPORT_MODE_JACK = 2,
  983. /*!
  984. * Transport from host, used when Carla is a plugin.
  985. */
  986. ENGINE_TRANSPORT_MODE_PLUGIN = 3,
  987. /*!
  988. * Special mode, used in plugin-bridges only.
  989. */
  990. ENGINE_TRANSPORT_MODE_BRIDGE = 4
  991. } EngineTransportMode;
  992. /* ------------------------------------------------------------------------------------------------------------
  993. * File Callback Opcode */
  994. /*!
  995. * File callback opcodes.
  996. * Front-ends must always block-wait for user input.
  997. * @see FileCallbackFunc, CarlaEngine::setFileCallback() and carla_set_file_callback()
  998. */
  999. typedef enum {
  1000. /*!
  1001. * Debug.
  1002. * This opcode is undefined and used only for testing purposes.
  1003. */
  1004. FILE_CALLBACK_DEBUG = 0,
  1005. /*!
  1006. * Open file or folder.
  1007. */
  1008. FILE_CALLBACK_OPEN = 1,
  1009. /*!
  1010. * Save file or folder.
  1011. */
  1012. FILE_CALLBACK_SAVE = 2
  1013. } FileCallbackOpcode;
  1014. /* ------------------------------------------------------------------------------------------------------------
  1015. * Patchbay Icon */
  1016. /*!
  1017. * The icon of a patchbay client/group.
  1018. */
  1019. enum PatchbayIcon {
  1020. /*!
  1021. * Generic application icon.
  1022. * Used for all non-plugin clients that don't have a specific icon.
  1023. */
  1024. PATCHBAY_ICON_APPLICATION = 0,
  1025. /*!
  1026. * Plugin icon.
  1027. * Used for all plugin clients that don't have a specific icon.
  1028. */
  1029. PATCHBAY_ICON_PLUGIN = 1,
  1030. /*!
  1031. * Hardware icon.
  1032. * Used for hardware (audio or MIDI) clients.
  1033. */
  1034. PATCHBAY_ICON_HARDWARE = 2,
  1035. /*!
  1036. * Carla icon.
  1037. * Used for the main app.
  1038. */
  1039. PATCHBAY_ICON_CARLA = 3,
  1040. /*!
  1041. * DISTRHO icon.
  1042. * Used for DISTRHO based plugins.
  1043. */
  1044. PATCHBAY_ICON_DISTRHO = 4,
  1045. /*!
  1046. * File icon.
  1047. * Used for file type plugins (like GIG and SF2).
  1048. */
  1049. PATCHBAY_ICON_FILE = 5
  1050. };
  1051. /* ------------------------------------------------------------------------------------------------------------
  1052. * Carla Backend API (C stuff) */
  1053. /*!
  1054. * Engine callback function.
  1055. * Front-ends must never block indefinitely during a callback.
  1056. * @see EngineCallbackOpcode, CarlaEngine::setCallback() and carla_set_engine_callback()
  1057. */
  1058. typedef void (*EngineCallbackFunc)(void* ptr, EngineCallbackOpcode action, uint pluginId, int value1, int value2, float value3, const char* valueStr);
  1059. /*!
  1060. * File callback function.
  1061. * @see FileCallbackOpcode
  1062. */
  1063. typedef const char* (*FileCallbackFunc)(void* ptr, FileCallbackOpcode action, bool isDir, const char* title, const char* filter);
  1064. /*!
  1065. * Parameter data.
  1066. */
  1067. typedef struct {
  1068. /*!
  1069. * This parameter type.
  1070. */
  1071. ParameterType type;
  1072. /*!
  1073. * This parameter hints.
  1074. * @see ParameterHints
  1075. */
  1076. uint hints;
  1077. /*!
  1078. * Index as seen by Carla.
  1079. */
  1080. int32_t index;
  1081. /*!
  1082. * Real index as seen by plugins.
  1083. */
  1084. int32_t rindex;
  1085. /*!
  1086. * Currently mapped MIDI CC.
  1087. * A value lower than 0 means invalid or unused.
  1088. * Maximum allowed value is 119 (0x77).
  1089. */
  1090. int16_t midiCC;
  1091. /*!
  1092. * Currently mapped MIDI channel.
  1093. * Counts from 0 to 15.
  1094. */
  1095. uint8_t midiChannel;
  1096. } ParameterData;
  1097. /*!
  1098. * Parameter ranges.
  1099. */
  1100. typedef struct {
  1101. /*!
  1102. * Default value.
  1103. */
  1104. float def;
  1105. /*!
  1106. * Minimum value.
  1107. */
  1108. float min;
  1109. /*!
  1110. * Maximum value.
  1111. */
  1112. float max;
  1113. /*!
  1114. * Regular, single step value.
  1115. */
  1116. float step;
  1117. /*!
  1118. * Small step value.
  1119. */
  1120. float stepSmall;
  1121. /*!
  1122. * Large step value.
  1123. */
  1124. float stepLarge;
  1125. #ifdef __cplusplus
  1126. /*!
  1127. * Fix the default value within range.
  1128. */
  1129. void fixDefault() noexcept
  1130. {
  1131. fixValue(def);
  1132. }
  1133. /*!
  1134. * Fix a value within range.
  1135. */
  1136. void fixValue(float& value) const noexcept
  1137. {
  1138. if (value < min)
  1139. value = min;
  1140. else if (value > max)
  1141. value = max;
  1142. }
  1143. /*!
  1144. * Get a fixed value within range.
  1145. */
  1146. const float& getFixedValue(const float& value) const noexcept
  1147. {
  1148. if (value <= min)
  1149. return min;
  1150. if (value >= max)
  1151. return max;
  1152. return value;
  1153. }
  1154. /*!
  1155. * Get a value normalized to 0.0<->1.0.
  1156. */
  1157. float getNormalizedValue(const float& value) const noexcept
  1158. {
  1159. const float normValue((value - min) / (max - min));
  1160. if (normValue <= 0.0f)
  1161. return 0.0f;
  1162. if (normValue >= 1.0f)
  1163. return 1.0f;
  1164. return normValue;
  1165. }
  1166. /*!
  1167. * Get a value normalized to 0.0<->1.0, fixed within range.
  1168. */
  1169. float getFixedAndNormalizedValue(const float& value) const noexcept
  1170. {
  1171. if (value <= min)
  1172. return 0.0f;
  1173. if (value >= max)
  1174. return 1.0f;
  1175. const float normValue((value - min) / (max - min));
  1176. if (normValue <= 0.0f)
  1177. return 0.0f;
  1178. if (normValue >= 1.0f)
  1179. return 1.0f;
  1180. return normValue;
  1181. }
  1182. /*!
  1183. * Get a proper value previously normalized to 0.0<->1.0.
  1184. */
  1185. float getUnnormalizedValue(const float& value) const noexcept
  1186. {
  1187. if (value <= 0.0f)
  1188. return min;
  1189. if (value >= 1.0f)
  1190. return max;
  1191. return value * (max - min) + min;
  1192. }
  1193. /*!
  1194. * Get a logarithmic value previously normalized to 0.0<->1.0.
  1195. */
  1196. float getUnnormalizedLogValue(const float& value) const noexcept
  1197. {
  1198. if (value <= 0.0f)
  1199. return min;
  1200. if (value >= 1.0f)
  1201. return max;
  1202. return min * std::pow(max/min, value);
  1203. }
  1204. #endif /* __cplusplus */
  1205. } ParameterRanges;
  1206. /*!
  1207. * MIDI Program data.
  1208. */
  1209. typedef struct {
  1210. /*!
  1211. * MIDI bank.
  1212. */
  1213. uint32_t bank;
  1214. /*!
  1215. * MIDI program.
  1216. */
  1217. uint32_t program;
  1218. /*!
  1219. * MIDI program name.
  1220. */
  1221. const char* name;
  1222. } MidiProgramData;
  1223. /*!
  1224. * Custom data, used for saving key:value 'dictionaries'.
  1225. */
  1226. typedef struct {
  1227. /*!
  1228. * Value type, in URI form.
  1229. * @see CustomDataTypes
  1230. */
  1231. const char* type;
  1232. /*!
  1233. * Key.
  1234. * @see CustomDataKeys
  1235. */
  1236. const char* key;
  1237. /*!
  1238. * Value.
  1239. */
  1240. const char* value;
  1241. #ifdef __cplusplus
  1242. /*!
  1243. * Check if valid.
  1244. */
  1245. bool isValid() const noexcept
  1246. {
  1247. if (type == nullptr || type[0] == '\0') return false;
  1248. if (key == nullptr || key [0] == '\0') return false;
  1249. if (value == nullptr) return false;
  1250. return true;
  1251. }
  1252. #endif /* __cplusplus */
  1253. } CustomData;
  1254. /*!
  1255. * Engine driver device information.
  1256. */
  1257. typedef struct {
  1258. /*!
  1259. * This driver device hints.
  1260. * @see EngineDriverHints
  1261. */
  1262. uint hints;
  1263. /*!
  1264. * Available buffer sizes.
  1265. * Terminated with 0.
  1266. */
  1267. const uint32_t* bufferSizes;
  1268. /*!
  1269. * Available sample rates.
  1270. * Terminated with 0.0.
  1271. */
  1272. const double* sampleRates;
  1273. } EngineDriverDeviceInfo;
  1274. /** @} */
  1275. #ifdef __cplusplus
  1276. /* Forward declarations of commonly used Carla classes */
  1277. class CarlaEngine;
  1278. class CarlaEngineClient;
  1279. class CarlaPlugin;
  1280. /* End namespace */
  1281. CARLA_BACKEND_END_NAMESPACE
  1282. #endif
  1283. #endif /* CARLA_BACKEND_H_INCLUDED */