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.

1521 lines
33KB

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