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.

1499 lines
32KB

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