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 31KB

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