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.

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