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

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