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.

CarlaBackend.h 32KB

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