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
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
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
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
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556
  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 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. * SF2 file (SoundFont).
  403. */
  404. PLUGIN_SF2 = 6,
  405. /*!
  406. * SFZ file.
  407. */
  408. PLUGIN_SFZ = 7,
  409. /*!
  410. * JACK application.
  411. */
  412. PLUGIN_JACK = 8
  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. } ParameterType;
  480. /* ------------------------------------------------------------------------------------------------------------
  481. * Internal Parameter Index */
  482. /*!
  483. * Special parameters used internally in Carla.
  484. * Plugins do not know about their existence.
  485. */
  486. typedef enum {
  487. /*!
  488. * Null parameter.
  489. */
  490. PARAMETER_NULL = -1,
  491. #ifndef BUILD_BRIDGE
  492. /*!
  493. * Active parameter, boolean type.
  494. * Default is 'false'.
  495. */
  496. PARAMETER_ACTIVE = -2,
  497. /*!
  498. * Dry/Wet parameter.
  499. * Range 0.0...1.0; default is 1.0.
  500. */
  501. PARAMETER_DRYWET = -3,
  502. /*!
  503. * Volume parameter.
  504. * Range 0.0...1.27; default is 1.0.
  505. */
  506. PARAMETER_VOLUME = -4,
  507. /*!
  508. * Stereo Balance-Left parameter.
  509. * Range -1.0...1.0; default is -1.0.
  510. */
  511. PARAMETER_BALANCE_LEFT = -5,
  512. /*!
  513. * Stereo Balance-Right parameter.
  514. * Range -1.0...1.0; default is 1.0.
  515. */
  516. PARAMETER_BALANCE_RIGHT = -6,
  517. /*!
  518. * Mono Panning parameter.
  519. * Range -1.0...1.0; default is 0.0.
  520. */
  521. PARAMETER_PANNING = -7,
  522. /*!
  523. * MIDI Control channel, integer type.
  524. * Range -1...15 (-1 = off).
  525. */
  526. PARAMETER_CTRL_CHANNEL = -8,
  527. #endif
  528. /*!
  529. * Max value, defined only for convenience.
  530. */
  531. PARAMETER_MAX = -9
  532. } InternalParameterIndex;
  533. /* ------------------------------------------------------------------------------------------------------------
  534. * Engine Callback Opcode */
  535. /*!
  536. * Engine callback opcodes.
  537. * Front-ends must never block indefinitely during a callback.
  538. * @see EngineCallbackFunc, CarlaEngine::setCallback() and carla_set_engine_callback()
  539. */
  540. typedef enum {
  541. /*!
  542. * Debug.
  543. * This opcode is undefined and used only for testing purposes.
  544. */
  545. ENGINE_CALLBACK_DEBUG = 0,
  546. /*!
  547. * A plugin has been added.
  548. * @a pluginId Plugin Id
  549. * @a valueStr Plugin name
  550. */
  551. ENGINE_CALLBACK_PLUGIN_ADDED = 1,
  552. /*!
  553. * A plugin has been removed.
  554. * @a pluginId Plugin Id
  555. */
  556. ENGINE_CALLBACK_PLUGIN_REMOVED = 2,
  557. /*!
  558. * A plugin has been renamed.
  559. * @a pluginId Plugin Id
  560. * @a valueStr New plugin name
  561. */
  562. ENGINE_CALLBACK_PLUGIN_RENAMED = 3,
  563. /*!
  564. * A plugin has become unavailable.
  565. * @a pluginId Plugin Id
  566. * @a valueStr Related error string
  567. */
  568. ENGINE_CALLBACK_PLUGIN_UNAVAILABLE = 4,
  569. /*!
  570. * A parameter value has changed.
  571. * @a pluginId Plugin Id
  572. * @a value1 Parameter index
  573. * @a value3 New parameter value
  574. */
  575. ENGINE_CALLBACK_PARAMETER_VALUE_CHANGED = 5,
  576. /*!
  577. * A parameter default has changed.
  578. * @a pluginId Plugin Id
  579. * @a value1 Parameter index
  580. * @a value3 New default value
  581. */
  582. ENGINE_CALLBACK_PARAMETER_DEFAULT_CHANGED = 6,
  583. #ifndef BUILD_BRIDGE
  584. /*!
  585. * A parameter's MIDI CC has changed.
  586. * @a pluginId Plugin Id
  587. * @a value1 Parameter index
  588. * @a value2 New MIDI CC
  589. */
  590. ENGINE_CALLBACK_PARAMETER_MIDI_CC_CHANGED = 7,
  591. /*!
  592. * A parameter's MIDI channel has changed.
  593. * @a pluginId Plugin Id
  594. * @a value1 Parameter index
  595. * @a value2 New MIDI channel
  596. */
  597. ENGINE_CALLBACK_PARAMETER_MIDI_CHANNEL_CHANGED = 8,
  598. /*!
  599. * A plugin option has changed.
  600. * @a pluginId Plugin Id
  601. * @a value1 Option
  602. * @a value2 New on/off state (1 for on, 0 for off)
  603. * @see PluginOptions
  604. */
  605. ENGINE_CALLBACK_OPTION_CHANGED = 9,
  606. #endif
  607. /*!
  608. * The current program of a plugin has changed.
  609. * @a pluginId Plugin Id
  610. * @a value1 New program index
  611. */
  612. ENGINE_CALLBACK_PROGRAM_CHANGED = 10,
  613. /*!
  614. * The current MIDI program of a plugin has changed.
  615. * @a pluginId Plugin Id
  616. * @a value1 New MIDI program index
  617. */
  618. ENGINE_CALLBACK_MIDI_PROGRAM_CHANGED = 11,
  619. /*!
  620. * A plugin's custom UI state has changed.
  621. * @a pluginId Plugin Id
  622. * @a value1 New state, as follows:
  623. * 0: UI is now hidden
  624. * 1: UI is now visible
  625. * -1: UI has crashed and should not be shown again
  626. */
  627. ENGINE_CALLBACK_UI_STATE_CHANGED = 12,
  628. /*!
  629. * A note has been pressed.
  630. * @a pluginId Plugin Id
  631. * @a value1 Channel
  632. * @a value2 Note
  633. * @a value3 Velocity
  634. */
  635. ENGINE_CALLBACK_NOTE_ON = 13,
  636. /*!
  637. * A note has been released.
  638. * @a pluginId Plugin Id
  639. * @a value1 Channel
  640. * @a value2 Note
  641. */
  642. ENGINE_CALLBACK_NOTE_OFF = 14,
  643. /*!
  644. * A plugin needs update.
  645. * @a pluginId Plugin Id
  646. */
  647. ENGINE_CALLBACK_UPDATE = 15,
  648. /*!
  649. * A plugin's data/information has changed.
  650. * @a pluginId Plugin Id
  651. */
  652. ENGINE_CALLBACK_RELOAD_INFO = 16,
  653. /*!
  654. * A plugin's parameters have changed.
  655. * @a pluginId Plugin Id
  656. */
  657. ENGINE_CALLBACK_RELOAD_PARAMETERS = 17,
  658. /*!
  659. * A plugin's programs have changed.
  660. * @a pluginId Plugin Id
  661. */
  662. ENGINE_CALLBACK_RELOAD_PROGRAMS = 18,
  663. /*!
  664. * A plugin state has changed.
  665. * @a pluginId Plugin Id
  666. */
  667. ENGINE_CALLBACK_RELOAD_ALL = 19,
  668. #ifndef BUILD_BRIDGE
  669. /*!
  670. * A patchbay client has been added.
  671. * @a pluginId Client Id
  672. * @a value1 Client icon
  673. * @a value2 Plugin Id (-1 if not a plugin)
  674. * @a valueStr Client name
  675. * @see PatchbayIcon
  676. */
  677. ENGINE_CALLBACK_PATCHBAY_CLIENT_ADDED = 20,
  678. /*!
  679. * A patchbay client has been removed.
  680. * @a pluginId Client Id
  681. */
  682. ENGINE_CALLBACK_PATCHBAY_CLIENT_REMOVED = 21,
  683. /*!
  684. * A patchbay client has been renamed.
  685. * @a pluginId Client Id
  686. * @a valueStr New client name
  687. */
  688. ENGINE_CALLBACK_PATCHBAY_CLIENT_RENAMED = 22,
  689. /*!
  690. * A patchbay client data has changed.
  691. * @a pluginId Client Id
  692. * @a value1 New icon
  693. * @a value2 New plugin Id (-1 if not a plugin)
  694. * @see PatchbayIcon
  695. */
  696. ENGINE_CALLBACK_PATCHBAY_CLIENT_DATA_CHANGED = 23,
  697. /*!
  698. * A patchbay port has been added.
  699. * @a pluginId Client Id
  700. * @a value1 Port Id
  701. * @a value2 Port hints
  702. * @a valueStr Port name
  703. * @see PatchbayPortHints
  704. */
  705. ENGINE_CALLBACK_PATCHBAY_PORT_ADDED = 24,
  706. /*!
  707. * A patchbay port has been removed.
  708. * @a pluginId Client Id
  709. * @a value1 Port Id
  710. */
  711. ENGINE_CALLBACK_PATCHBAY_PORT_REMOVED = 25,
  712. /*!
  713. * A patchbay port has been renamed.
  714. * @a pluginId Client Id
  715. * @a value1 Port Id
  716. * @a valueStr New port name
  717. */
  718. ENGINE_CALLBACK_PATCHBAY_PORT_RENAMED = 26,
  719. /*!
  720. * A patchbay connection has been added.
  721. * @a pluginId Connection Id
  722. * @a valueStr Out group and port plus in group and port, in "og:op:ig:ip" syntax.
  723. */
  724. ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED = 27,
  725. /*!
  726. * A patchbay connection has been removed.
  727. * @a pluginId Connection Id
  728. */
  729. ENGINE_CALLBACK_PATCHBAY_CONNECTION_REMOVED = 28,
  730. #endif
  731. /*!
  732. * Engine started.
  733. * @a value1 Process mode
  734. * @a value2 Transport mode
  735. * @a value3 Sample rate
  736. * @a valuestr Engine driver
  737. * @see EngineProcessMode
  738. * @see EngineTransportMode
  739. */
  740. ENGINE_CALLBACK_ENGINE_STARTED = 29,
  741. /*!
  742. * Engine stopped.
  743. */
  744. ENGINE_CALLBACK_ENGINE_STOPPED = 30,
  745. /*!
  746. * Engine process mode has changed.
  747. * @a value1 New process mode
  748. * @see EngineProcessMode
  749. */
  750. ENGINE_CALLBACK_PROCESS_MODE_CHANGED = 31,
  751. /*!
  752. * Engine transport mode has changed.
  753. * @a value1 New transport mode
  754. * @see EngineTransportMode
  755. */
  756. ENGINE_CALLBACK_TRANSPORT_MODE_CHANGED = 32,
  757. /*!
  758. * Engine buffer-size changed.
  759. * @a value1 New buffer size
  760. */
  761. ENGINE_CALLBACK_BUFFER_SIZE_CHANGED = 33,
  762. /*!
  763. * Engine sample-rate changed.
  764. * @a value3 New sample rate
  765. */
  766. ENGINE_CALLBACK_SAMPLE_RATE_CHANGED = 34,
  767. /*!
  768. * Project has finished loading.
  769. */
  770. ENGINE_CALLBACK_PROJECT_LOAD_FINISHED = 35,
  771. /*!
  772. * NSM callback.
  773. * (Work in progress, values are not defined yet)
  774. */
  775. ENGINE_CALLBACK_NSM = 36,
  776. /*!
  777. * Idle frontend.
  778. * This is used by the engine during long operations that might block the frontend,
  779. * giving it the possibility to idle while the operation is still in place.
  780. */
  781. ENGINE_CALLBACK_IDLE = 37,
  782. /*!
  783. * Show a message as information.
  784. * @a valueStr The message
  785. */
  786. ENGINE_CALLBACK_INFO = 38,
  787. /*!
  788. * Show a message as an error.
  789. * @a valueStr The message
  790. */
  791. ENGINE_CALLBACK_ERROR = 39,
  792. /*!
  793. * The engine has crashed or malfunctioned and will no longer work.
  794. */
  795. ENGINE_CALLBACK_QUIT = 40
  796. } EngineCallbackOpcode;
  797. /* ------------------------------------------------------------------------------------------------------------
  798. * Engine Option */
  799. /*!
  800. * Engine options.
  801. * @see CarlaEngine::getOptions(), CarlaEngine::setOption() and carla_set_engine_option()
  802. */
  803. typedef enum {
  804. /*!
  805. * Debug.
  806. * This option is undefined and used only for testing purposes.
  807. */
  808. ENGINE_OPTION_DEBUG = 0,
  809. /*!
  810. * Set the engine processing mode.
  811. * Default is ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS on Linux and ENGINE_PROCESS_MODE_PATCHBAY for all other OSes.
  812. * @see EngineProcessMode
  813. */
  814. ENGINE_OPTION_PROCESS_MODE = 1,
  815. /*!
  816. * Set the engine transport mode.
  817. * Default is ENGINE_TRANSPORT_MODE_JACK on Linux and ENGINE_TRANSPORT_MODE_INTERNAL for all other OSes.
  818. * @see EngineTransportMode
  819. */
  820. ENGINE_OPTION_TRANSPORT_MODE = 2,
  821. /*!
  822. * Force mono plugins as stereo, by running 2 instances at the same time.
  823. * Default is false, but always true when process mode is ENGINE_PROCESS_MODE_CONTINUOUS_RACK.
  824. * @note Not supported by all plugins
  825. * @see PLUGIN_OPTION_FORCE_STEREO
  826. */
  827. ENGINE_OPTION_FORCE_STEREO = 3,
  828. /*!
  829. * Use plugin bridges whenever possible.
  830. * Default is no, EXPERIMENTAL.
  831. */
  832. ENGINE_OPTION_PREFER_PLUGIN_BRIDGES = 4,
  833. /*!
  834. * Use UI bridges whenever possible, otherwise UIs will be directly handled in the main backend thread.
  835. * Default is yes.
  836. */
  837. ENGINE_OPTION_PREFER_UI_BRIDGES = 5,
  838. /*!
  839. * Make custom plugin UIs always-on-top.
  840. * Default is yes.
  841. */
  842. ENGINE_OPTION_UIS_ALWAYS_ON_TOP = 6,
  843. /*!
  844. * Maximum number of parameters allowed.
  845. * Default is MAX_DEFAULT_PARAMETERS.
  846. */
  847. ENGINE_OPTION_MAX_PARAMETERS = 7,
  848. /*!
  849. * Timeout value for how much to wait for UI bridges to respond, in milliseconds.
  850. * Default is 4000 (4 seconds).
  851. */
  852. ENGINE_OPTION_UI_BRIDGES_TIMEOUT = 8,
  853. /*!
  854. * Audio buffer size.
  855. * Default is 512.
  856. */
  857. ENGINE_OPTION_AUDIO_BUFFER_SIZE = 9,
  858. /*!
  859. * Audio sample rate.
  860. * Default is 44100.
  861. */
  862. ENGINE_OPTION_AUDIO_SAMPLE_RATE = 10,
  863. /*!
  864. * Wherever to use 3 audio periods instead of the default 2.
  865. * Default is false.
  866. */
  867. ENGINE_OPTION_AUDIO_TRIPLE_BUFFER = 11,
  868. /*!
  869. * Audio device (within a driver).
  870. * Default unset.
  871. */
  872. ENGINE_OPTION_AUDIO_DEVICE = 12,
  873. /*!
  874. * Set path used for a specific plugin type.
  875. * Uses value as the plugin format, valueStr as actual path.
  876. * @see PluginType
  877. */
  878. ENGINE_OPTION_PLUGIN_PATH = 13,
  879. /*!
  880. * Set path to the binary files.
  881. * Default unset.
  882. * @note Must be set for plugin and UI bridges to work
  883. */
  884. ENGINE_OPTION_PATH_BINARIES = 14,
  885. /*!
  886. * Set path to the resource files.
  887. * Default unset.
  888. * @note Must be set for some internal plugins to work
  889. */
  890. ENGINE_OPTION_PATH_RESOURCES = 15,
  891. /*!
  892. * Prevent bad plugin and UI behaviour.
  893. * @note: Linux only
  894. */
  895. ENGINE_OPTION_PREVENT_BAD_BEHAVIOUR = 16,
  896. /*!
  897. * Set frontend winId, used to define as parent window for plugin UIs.
  898. */
  899. ENGINE_OPTION_FRONTEND_WIN_ID = 17,
  900. #ifndef CARLA_OS_WIN
  901. /*!
  902. * Set path to wine executable.
  903. */
  904. ENGINE_OPTION_WINE_EXECUTABLE = 18,
  905. /*!
  906. * Enable automatic wineprefix detection.
  907. */
  908. ENGINE_OPTION_WINE_AUTO_PREFIX = 19,
  909. /*!
  910. * Fallback wineprefix to use if automatic detection fails or is disabled, and WINEPREFIX is not set.
  911. */
  912. ENGINE_OPTION_WINE_FALLBACK_PREFIX = 20,
  913. /*!
  914. * Enable realtime priority for Wine application and server threads.
  915. */
  916. ENGINE_OPTION_WINE_RT_PRIO_ENABLED = 21,
  917. /*!
  918. * Base realtime priority for Wine threads.
  919. */
  920. ENGINE_OPTION_WINE_BASE_RT_PRIO = 22,
  921. /*!
  922. * Wine server realtime priority.
  923. */
  924. ENGINE_OPTION_WINE_SERVER_RT_PRIO = 23,
  925. #endif
  926. /*!
  927. * Capture console output into debug callbacks.
  928. */
  929. ENGINE_OPTION_DEBUG_CONSOLE_OUTPUT = 24
  930. } EngineOption;
  931. /* ------------------------------------------------------------------------------------------------------------
  932. * Engine Process Mode */
  933. /*!
  934. * Engine process mode.
  935. * @see ENGINE_OPTION_PROCESS_MODE
  936. */
  937. typedef enum {
  938. /*!
  939. * Single client mode.
  940. * Inputs and outputs are added dynamically as needed by plugins.
  941. */
  942. ENGINE_PROCESS_MODE_SINGLE_CLIENT = 0,
  943. /*!
  944. * Multiple client mode.
  945. * It has 1 master client + 1 client per plugin.
  946. */
  947. ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS = 1,
  948. /*!
  949. * Single client, 'rack' mode.
  950. * Processes plugins in order of Id, with forced stereo always on.
  951. */
  952. ENGINE_PROCESS_MODE_CONTINUOUS_RACK = 2,
  953. /*!
  954. * Single client, 'patchbay' mode.
  955. */
  956. ENGINE_PROCESS_MODE_PATCHBAY = 3,
  957. /*!
  958. * Special mode, used in plugin-bridges only.
  959. */
  960. ENGINE_PROCESS_MODE_BRIDGE = 4
  961. } EngineProcessMode;
  962. /* ------------------------------------------------------------------------------------------------------------
  963. * Engine Transport Mode */
  964. /*!
  965. * Engine transport mode.
  966. * @see ENGINE_OPTION_TRANSPORT_MODE
  967. */
  968. typedef enum {
  969. /*!
  970. * No transport.
  971. */
  972. ENGINE_TRANSPORT_MODE_DISABLED = 0,
  973. /*!
  974. * Internal transport mode.
  975. */
  976. ENGINE_TRANSPORT_MODE_INTERNAL = 1,
  977. /*!
  978. * Transport from JACK.
  979. * Only available if driver name is "JACK".
  980. */
  981. ENGINE_TRANSPORT_MODE_JACK = 2,
  982. /*!
  983. * Transport from host, used when Carla is a plugin.
  984. */
  985. ENGINE_TRANSPORT_MODE_PLUGIN = 3,
  986. /*!
  987. * Special mode, used in plugin-bridges only.
  988. */
  989. ENGINE_TRANSPORT_MODE_BRIDGE = 4
  990. } EngineTransportMode;
  991. /* ------------------------------------------------------------------------------------------------------------
  992. * File Callback Opcode */
  993. /*!
  994. * File callback opcodes.
  995. * Front-ends must always block-wait for user input.
  996. * @see FileCallbackFunc, CarlaEngine::setFileCallback() and carla_set_file_callback()
  997. */
  998. typedef enum {
  999. /*!
  1000. * Debug.
  1001. * This opcode is undefined and used only for testing purposes.
  1002. */
  1003. FILE_CALLBACK_DEBUG = 0,
  1004. /*!
  1005. * Open file or folder.
  1006. */
  1007. FILE_CALLBACK_OPEN = 1,
  1008. /*!
  1009. * Save file or folder.
  1010. */
  1011. FILE_CALLBACK_SAVE = 2
  1012. } FileCallbackOpcode;
  1013. /* ------------------------------------------------------------------------------------------------------------
  1014. * Patchbay Icon */
  1015. /*!
  1016. * The icon of a patchbay client/group.
  1017. */
  1018. enum PatchbayIcon {
  1019. /*!
  1020. * Generic application icon.
  1021. * Used for all non-plugin clients that don't have a specific icon.
  1022. */
  1023. PATCHBAY_ICON_APPLICATION = 0,
  1024. /*!
  1025. * Plugin icon.
  1026. * Used for all plugin clients that don't have a specific icon.
  1027. */
  1028. PATCHBAY_ICON_PLUGIN = 1,
  1029. /*!
  1030. * Hardware icon.
  1031. * Used for hardware (audio or MIDI) clients.
  1032. */
  1033. PATCHBAY_ICON_HARDWARE = 2,
  1034. /*!
  1035. * Carla icon.
  1036. * Used for the main app.
  1037. */
  1038. PATCHBAY_ICON_CARLA = 3,
  1039. /*!
  1040. * DISTRHO icon.
  1041. * Used for DISTRHO based plugins.
  1042. */
  1043. PATCHBAY_ICON_DISTRHO = 4,
  1044. /*!
  1045. * File icon.
  1046. * Used for file type plugins (like SF2 snd SFZ).
  1047. */
  1048. PATCHBAY_ICON_FILE = 5
  1049. };
  1050. /* ------------------------------------------------------------------------------------------------------------
  1051. * Carla Backend API (C stuff) */
  1052. /*!
  1053. * Engine callback function.
  1054. * Front-ends must never block indefinitely during a callback.
  1055. * @see EngineCallbackOpcode, CarlaEngine::setCallback() and carla_set_engine_callback()
  1056. */
  1057. typedef void (*EngineCallbackFunc)(void* ptr, EngineCallbackOpcode action, uint pluginId, int value1, int value2, float value3, const char* valueStr);
  1058. /*!
  1059. * File callback function.
  1060. * @see FileCallbackOpcode
  1061. */
  1062. typedef const char* (*FileCallbackFunc)(void* ptr, FileCallbackOpcode action, bool isDir, const char* title, const char* filter);
  1063. /*!
  1064. * Parameter data.
  1065. */
  1066. typedef struct {
  1067. /*!
  1068. * This parameter type.
  1069. */
  1070. ParameterType type;
  1071. /*!
  1072. * This parameter hints.
  1073. * @see ParameterHints
  1074. */
  1075. uint hints;
  1076. /*!
  1077. * Index as seen by Carla.
  1078. */
  1079. int32_t index;
  1080. /*!
  1081. * Real index as seen by plugins.
  1082. */
  1083. int32_t rindex;
  1084. /*!
  1085. * Currently mapped MIDI CC.
  1086. * A value lower than 0 means invalid or unused.
  1087. * Maximum allowed value is 119 (0x77).
  1088. */
  1089. int16_t midiCC;
  1090. /*!
  1091. * Currently mapped MIDI channel.
  1092. * Counts from 0 to 15.
  1093. */
  1094. uint8_t midiChannel;
  1095. } ParameterData;
  1096. /*!
  1097. * Parameter ranges.
  1098. */
  1099. typedef struct _ParameterRanges {
  1100. /*!
  1101. * Default value.
  1102. */
  1103. float def;
  1104. /*!
  1105. * Minimum value.
  1106. */
  1107. float min;
  1108. /*!
  1109. * Maximum value.
  1110. */
  1111. float max;
  1112. /*!
  1113. * Regular, single step value.
  1114. */
  1115. float step;
  1116. /*!
  1117. * Small step value.
  1118. */
  1119. float stepSmall;
  1120. /*!
  1121. * Large step value.
  1122. */
  1123. float stepLarge;
  1124. #ifdef __cplusplus
  1125. /*!
  1126. * Fix the default value within range.
  1127. */
  1128. void fixDefault() noexcept
  1129. {
  1130. fixValue(def);
  1131. }
  1132. /*!
  1133. * Fix a value within range.
  1134. */
  1135. void fixValue(float& value) const noexcept
  1136. {
  1137. if (value < min)
  1138. value = min;
  1139. else if (value > max)
  1140. value = max;
  1141. }
  1142. /*!
  1143. * Get a fixed value within range.
  1144. */
  1145. const float& getFixedValue(const float& value) const noexcept
  1146. {
  1147. if (value <= min)
  1148. return min;
  1149. if (value >= max)
  1150. return max;
  1151. return value;
  1152. }
  1153. /*!
  1154. * Get a value normalized to 0.0<->1.0.
  1155. */
  1156. float getNormalizedValue(const float& value) const noexcept
  1157. {
  1158. const float normValue((value - min) / (max - min));
  1159. if (normValue <= 0.0f)
  1160. return 0.0f;
  1161. if (normValue >= 1.0f)
  1162. return 1.0f;
  1163. return normValue;
  1164. }
  1165. /*!
  1166. * Get a value normalized to 0.0<->1.0, fixed within range.
  1167. */
  1168. float getFixedAndNormalizedValue(const float& value) const noexcept
  1169. {
  1170. if (value <= min)
  1171. return 0.0f;
  1172. if (value >= max)
  1173. return 1.0f;
  1174. const float normValue((value - min) / (max - min));
  1175. if (normValue <= 0.0f)
  1176. return 0.0f;
  1177. if (normValue >= 1.0f)
  1178. return 1.0f;
  1179. return normValue;
  1180. }
  1181. /*!
  1182. * Get a proper value previously normalized to 0.0<->1.0.
  1183. */
  1184. float getUnnormalizedValue(const float& value) const noexcept
  1185. {
  1186. if (value <= 0.0f)
  1187. return min;
  1188. if (value >= 1.0f)
  1189. return max;
  1190. return value * (max - min) + min;
  1191. }
  1192. /*!
  1193. * Get a logarithmic value previously normalized to 0.0<->1.0.
  1194. */
  1195. float getUnnormalizedLogValue(const float& value) const noexcept
  1196. {
  1197. if (value <= 0.0f)
  1198. return min;
  1199. if (value >= 1.0f)
  1200. return max;
  1201. float rmin = min;
  1202. if (std::abs(min) < std::numeric_limits<float>::epsilon())
  1203. rmin = 0.00001f;
  1204. return rmin * std::pow(max/rmin, value);
  1205. }
  1206. #endif /* __cplusplus */
  1207. } ParameterRanges;
  1208. /*!
  1209. * MIDI Program data.
  1210. */
  1211. typedef struct {
  1212. /*!
  1213. * MIDI bank.
  1214. */
  1215. uint32_t bank;
  1216. /*!
  1217. * MIDI program.
  1218. */
  1219. uint32_t program;
  1220. /*!
  1221. * MIDI program name.
  1222. */
  1223. const char* name;
  1224. } MidiProgramData;
  1225. /*!
  1226. * Custom data, used for saving key:value 'dictionaries'.
  1227. */
  1228. typedef struct {
  1229. /*!
  1230. * Value type, in URI form.
  1231. * @see CustomDataTypes
  1232. */
  1233. const char* type;
  1234. /*!
  1235. * Key.
  1236. * @see CustomDataKeys
  1237. */
  1238. const char* key;
  1239. /*!
  1240. * Value.
  1241. */
  1242. const char* value;
  1243. #ifdef __cplusplus
  1244. /*!
  1245. * Check if valid.
  1246. */
  1247. bool isValid() const noexcept
  1248. {
  1249. if (type == nullptr || type[0] == '\0') return false;
  1250. if (key == nullptr || key [0] == '\0') return false;
  1251. if (value == nullptr) return false;
  1252. return true;
  1253. }
  1254. #endif /* __cplusplus */
  1255. } CustomData;
  1256. /*!
  1257. * Engine driver device information.
  1258. */
  1259. typedef struct {
  1260. /*!
  1261. * This driver device hints.
  1262. * @see EngineDriverHints
  1263. */
  1264. uint hints;
  1265. /*!
  1266. * Available buffer sizes.
  1267. * Terminated with 0.
  1268. */
  1269. const uint32_t* bufferSizes;
  1270. /*!
  1271. * Available sample rates.
  1272. * Terminated with 0.0.
  1273. */
  1274. const double* sampleRates;
  1275. } EngineDriverDeviceInfo;
  1276. /** @} */
  1277. #ifdef __cplusplus
  1278. /* Forward declarations of commonly used Carla classes */
  1279. class CarlaEngine;
  1280. class CarlaEngineClient;
  1281. class CarlaPlugin;
  1282. /* End namespace */
  1283. CARLA_BACKEND_END_NAMESPACE
  1284. #endif
  1285. #endif /* CARLA_BACKEND_H_INCLUDED */