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.

676 lines
20KB

  1. /*
  2. * Carla Backend API
  3. * Copyright (C) 2011-2013 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 GPL.txt file
  16. */
  17. #ifndef __CARLA_BACKEND_HPP__
  18. #define __CARLA_BACKEND_HPP__
  19. #include "carla_defines.hpp"
  20. #include <cstdint>
  21. #define CARLA_BACKEND_START_NAMESPACE namespace CarlaBackend {
  22. #define CARLA_BACKEND_END_NAMESPACE }
  23. #define CARLA_BACKEND_USE_NAMESPACE using namespace CarlaBackend;
  24. #define STR_MAX 0xFF
  25. CARLA_BACKEND_START_NAMESPACE
  26. /*!
  27. * @defgroup CarlaBackendAPI Carla Backend API
  28. *
  29. * The Carla Backend API
  30. *
  31. * @{
  32. */
  33. const unsigned int MAX_DEFAULT_PLUGINS = 99; //!< Maximum default number of loadable plugins
  34. const unsigned int MAX_RACK_PLUGINS = 16; //!< Maximum number of loadable plugins in rack mode
  35. const unsigned int MAX_PATCHBAY_PLUGINS = 999; //!< Maximum number of loadable plugins in patchbay mode
  36. const unsigned int MAX_DEFAULT_PARAMETERS = 200; //!< Maximum default number of parameters allowed.\see OPTION_MAX_PARAMETERS
  37. /*!
  38. * @defgroup PluginHints Plugin Hints
  39. *
  40. * Various plugin hints.
  41. * \see CarlaPlugin::hints()
  42. * @{
  43. */
  44. const unsigned int PLUGIN_IS_BRIDGE = 0x0001; //!< Plugin is a bridge (ie, BridgePlugin). This hint is required because "bridge" itself is not a plugin type.
  45. const unsigned int PLUGIN_IS_RTSAFE = 0x0002; //!< Plugin is hard real-time safe.
  46. const unsigned int PLUGIN_IS_SYNTH = 0x0004; //!< Plugin is a synthesizer (produces sound).
  47. const unsigned int PLUGIN_HAS_GUI = 0x0010; //!< Plugin has its own custom GUI.
  48. const unsigned int PLUGIN_USES_CHUNKS = 0x0020; //!< Plugin uses chunks to save internal data.\see CarlaPlugin::chunkData()
  49. const unsigned int PLUGIN_USES_SINGLE_THREAD = 0x0040; //!< Plugin needs a single thread for both DSP and UI events.
  50. const unsigned int PLUGIN_CAN_DRYWET = 0x0100; //!< Plugin can make use of Dry/Wet controls.
  51. const unsigned int PLUGIN_CAN_VOLUME = 0x0200; //!< Plugin can make use of Volume controls.
  52. const unsigned int PLUGIN_CAN_BALANCE = 0x0400; //!< Plugin can make use of Left & Right Balance controls.
  53. const unsigned int PLUGIN_CAN_PANNING = 0x0800; //!< Plugin can make use of Panning controls.
  54. const unsigned int PLUGIN_CAN_FORCE_STEREO = 0x1000; //!< Plugin can be used in forced-stereo mode.
  55. /**@}*/
  56. /*!
  57. * @defgroup PluginOptions Plugin Options
  58. *
  59. * Various plugin options.\n
  60. * ON or OFF defines the default plugin value.
  61. * \see CarlaPlugin::options()
  62. * \note PitchBend is disabled by default on VST plugins
  63. * @{
  64. */
  65. const unsigned int PLUGIN_OPTION_FIXED_BUFFER = 0x001; //!< OFF: Use a constant, fixed size audio buffer (128 or lower is used)
  66. const unsigned int PLUGIN_OPTION_FORCE_STEREO = 0x002; //!< OFF: Force mono plugin as stereo
  67. const unsigned int PLUGIN_OPTION_SELF_AUTOMATION = 0x004; //!< OFF: Let the plugin handle MIDI-CC automation, not the host
  68. const unsigned int PLUGIN_OPTION_USE_CHUNKS = 0x008; //!< ON: Use chunks to save data
  69. const unsigned int PLUGIN_OPTION_SEND_ALL_SOUND_OFF = 0x010; //!< ON: Send MIDI ALL_SOUND_OFF / ALL_NOTES_OFF events
  70. const unsigned int PLUGIN_OPTION_SEND_NOTE_OFF_VELO = 0x020; //!< OFF: Send MIDI Note-Off events with a velocity value
  71. const unsigned int PLUGIN_OPTION_SEND_NOTE_AFTERTOUCH = 0x040; //!< ON: Send MIDI Note aftertouch events
  72. const unsigned int PLUGIN_OPTION_SEND_PITCHBEND = 0x080; //!< ON: Send MIDI Pitchbend events
  73. #ifdef WANT_VST
  74. const unsigned int PLUGIN_OPTION_VST_SUPPLY_IDLE = 0x100; //!< ON: Idle Plugin's custom GUI (VST only)
  75. const unsigned int PLUGIN_OPTION_VST_UPDATE_DISPLAY = 0x200; //!< ON: Recheck plugin properties on updateDisplay message (VST Only)
  76. #endif
  77. /**@}*/
  78. /*!
  79. * @defgroup ParameterHints Parameter Hints
  80. *
  81. * Various parameter hints.
  82. * \see CarlaPlugin::parameterData()
  83. * @{
  84. */
  85. const unsigned int PARAMETER_IS_BOOLEAN = 0x01; //!< Parameter value is always a boolean (always at minimum or maximum range).
  86. const unsigned int PARAMETER_IS_INTEGER = 0x02; //!< Parameter value is always an integer.
  87. const unsigned int PARAMETER_IS_LOGARITHMIC = 0x04; //!< Parameter is logarithmic.
  88. const unsigned int PARAMETER_IS_ENABLED = 0x08; //!< Parameter is enabled and will be shown in the host built-in editor.
  89. const unsigned int PARAMETER_IS_AUTOMABLE = 0x10; //!< Parameter is automable (realtime safe)
  90. const unsigned int PARAMETER_USES_SAMPLERATE = 0x20; //!< Parameter needs sample rate to work (value and ranges are multiplied by SR, and must be divided by SR on save).
  91. const unsigned int PARAMETER_USES_SCALEPOINTS = 0x40; //!< Parameter uses scalepoints to define internal values in a meaninful way.
  92. const unsigned int PARAMETER_USES_CUSTOM_TEXT = 0x80; //!< Parameter uses custom text for displaying its value.\see CarlaPlugin::getParameterText()
  93. /**@}*/
  94. /*!
  95. * @defgroup CustomDataTypes Custom Data types
  96. *
  97. * The type defines how the \param value in CustomData is stored.
  98. *
  99. * Types are valid URIs.\n
  100. * Any non-string, non-simple type (not integral) is saved in a base64 encoded format.
  101. */
  102. const char* const CUSTOM_DATA_INVALID = nullptr; //!< Null/Invalid data.
  103. const char* const CUSTOM_DATA_CHUNK = "http://kxstudio.sf.net/ns/carla/chunk"; //!< Carla Chunk
  104. const char* const CUSTOM_DATA_STRING = "http://kxstudio.sf.net/ns/carla/string"; //!< Carla String
  105. /**@}*/
  106. #if 0
  107. /*!
  108. * @defgroup BridgeMessages Bridge Messages
  109. *
  110. * Various bridge related messages, used as configure(<message>, value).
  111. * \note This is for internal use only.
  112. *
  113. * TODO: Review these, may not be needed anymore
  114. * @{
  115. */
  116. const char* const CARLA_BRIDGE_MSG_HIDE_GUI = "CarlaBridgeHideGUI"; //!< Plugin -> Host call, tells host GUI is now hidden
  117. const char* const CARLA_BRIDGE_MSG_SAVED = "CarlaBridgeSaved"; //!< Plugin -> Host call, tells host state is saved
  118. const char* const CARLA_BRIDGE_MSG_SAVE_NOW = "CarlaBridgeSaveNow"; //!< Host -> Plugin call, tells plugin to save state now
  119. const char* const CARLA_BRIDGE_MSG_SET_CHUNK = "CarlaBridgeSetChunk"; //!< Host -> Plugin call, tells plugin to set chunk in file \a value
  120. const char* const CARLA_BRIDGE_MSG_SET_CUSTOM = "CarlaBridgeSetCustom"; //!< Host -> Plugin call, tells plugin to set a custom data set using \a value ("type·key·rvalue").\n If \a type is 'chunk' or 'binary' \a rvalue refers to chunk file.
  121. /**@}*/
  122. #endif
  123. /*!
  124. * The binary type of a plugin.
  125. */
  126. enum BinaryType {
  127. BINARY_NONE = 0, //!< Null binary type.
  128. BINARY_POSIX32 = 1, //!< POSIX 32bit.
  129. BINARY_POSIX64 = 2, //!< POSIX 64bit.
  130. BINARY_WIN32 = 3, //!< Windows 32bit.
  131. BINARY_WIN64 = 4, //!< Windows 64bit.
  132. BINARY_OTHER = 5 //!< Other.
  133. };
  134. /*!
  135. * All the available plugin types, as provided by subclasses of CarlaPlugin.\n
  136. * Some plugin classes might provide more than 1 plugin type.
  137. */
  138. enum PluginType {
  139. PLUGIN_NONE = 0, //!< Null plugin type.
  140. PLUGIN_INTERNAL = 1, //!< Internal plugin.\see NativePlugin
  141. PLUGIN_LADSPA = 2, //!< LADSPA plugin.\see LadspaPlugin
  142. PLUGIN_DSSI = 3, //!< DSSI plugin.\see DssiPlugin
  143. PLUGIN_LV2 = 4, //!< LV2 plugin.\see Lv2Plugin
  144. PLUGIN_VST = 5, //!< VST plugin.\see VstPlugin
  145. PLUGIN_GIG = 6, //!< GIG sound kit, implemented via LinuxSampler.\see LinuxSamplerPlugin
  146. PLUGIN_SF2 = 7, //!< SF2 sound kit (aka SoundFont), implemented via FluidSynth.\see FluidSynthPlugin
  147. PLUGIN_SFZ = 8 //!< SFZ sound kit, implemented via LinuxSampler.\see LinuxSamplerPlugin
  148. };
  149. /*!
  150. * Plugin category, describing the funtionality of a plugin.\n
  151. * When a plugin fails to tell his own category, one is atributted to it based on its name.
  152. */
  153. enum PluginCategory {
  154. PLUGIN_CATEGORY_NONE = 0, //!< Null plugin category.
  155. PLUGIN_CATEGORY_SYNTH = 1, //!< A synthesizer or generator.
  156. PLUGIN_CATEGORY_DELAY = 2, //!< A delay or reverberator.
  157. PLUGIN_CATEGORY_EQ = 3, //!< An equalizer.
  158. PLUGIN_CATEGORY_FILTER = 4, //!< A filter.
  159. PLUGIN_CATEGORY_DYNAMICS = 5, //!< A 'dynamic' plugin (amplifier, compressor, gate, etc).
  160. PLUGIN_CATEGORY_MODULATOR = 6, //!< A 'modulator' plugin (chorus, flanger, phaser, etc).
  161. PLUGIN_CATEGORY_UTILITY = 7, //!< An 'utility' plugin (analyzer, converter, mixer, etc).
  162. PLUGIN_CATEGORY_OTHER = 8 //!< Misc plugin (used to check if the plugin has a category).
  163. };
  164. /*!
  165. * Plugin parameter type.
  166. */
  167. enum ParameterType {
  168. PARAMETER_UNKNOWN = 0, //!< Null parameter type.
  169. PARAMETER_INPUT = 1, //!< Input parameter.
  170. PARAMETER_OUTPUT = 2, //!< Ouput parameter.
  171. PARAMETER_LATENCY = 3, //!< Special latency parameter, used in LADSPA, DSSI and LV2 plugins.
  172. PARAMETER_SAMPLE_RATE = 4, //!< Special sample-rate parameter, used in LADSPA, DSSI and LV2 plugins.
  173. #ifdef WANT_LV2
  174. PARAMETER_LV2_FREEWHEEL = 5, //!< Special LV2 Plugin parameter used to report freewheel (offline) mode.
  175. PARAMETER_LV2_TIME = 6 //!< Special LV2 Plugin parameter used to report time information.
  176. #endif
  177. };
  178. /*!
  179. * Internal parameter indexes.\n
  180. * These are special parameters used internally, plugins do not know about their existence.
  181. */
  182. enum InternalParametersIndex {
  183. PARAMETER_NULL = -1, //!< Null parameter.
  184. PARAMETER_ACTIVE = -2, //!< Active parameter, can only be 'true' or 'false'; default is 'false'.
  185. PARAMETER_DRYWET = -3, //!< Dry/Wet parameter, range 0.0...1.0; default is 1.0.
  186. PARAMETER_VOLUME = -4, //!< Volume parameter, range 0.0...1.27; default is 1.0.
  187. PARAMETER_BALANCE_LEFT = -5, //!< Stereo Balance-Left parameter, range -1.0...1.0; default is -1.0.
  188. PARAMETER_BALANCE_RIGHT = -6, //!< Stereo Balance-Right parameter, range -1.0...1.0; default is 1.0.
  189. PARAMETER_PANNING = -7, //!< Mono Panning parameter, range -1.0...1.0; default is 0.0.
  190. PARAMETER_MAX = -8 //!< Max value, defined for convenience
  191. };
  192. /*!
  193. * Options used in the CarlaEngine::setOption() and set_option() calls.\n
  194. * These options must be set before initiliazing or after closing the engine.
  195. */
  196. enum OptionsType {
  197. /*!
  198. * Try to set the current process name.
  199. * \note Not available on all platforms.
  200. */
  201. OPTION_PROCESS_NAME = 0,
  202. /*!
  203. * Set the engine processing mode.\n
  204. * Default is PROCESS_MODE_CONTINUOUS_RACK.
  205. * \see ProcessMode
  206. */
  207. OPTION_PROCESS_MODE = 1,
  208. /*!
  209. * Force mono plugins as stereo, by running 2 instances at the same time.
  210. * \note Not supported by all plugins.
  211. */
  212. OPTION_FORCE_STEREO = 2,
  213. /*!
  214. * Use plugin bridges whenever possible.\n
  215. * Default is no, and not recommended at this point!.
  216. * EXPERIMENTAL AND INCOMPLETE!
  217. */
  218. OPTION_PREFER_PLUGIN_BRIDGES = 3,
  219. /*!
  220. * Use OSC-UI bridges whenever possible, otherwise UIs will be handled in the main thread.\n
  221. * Default is yes.
  222. */
  223. OPTION_PREFER_UI_BRIDGES = 4,
  224. #ifdef WANT_DSSI
  225. /*!
  226. * Use (unofficial) dssi-vst chunks feature.\n
  227. * Default is no.
  228. */
  229. OPTION_USE_DSSI_VST_CHUNKS = 5,
  230. #endif
  231. /*!
  232. * Maximum number of parameters allowed.\n
  233. * Default is MAX_DEFAULT_PARAMETERS.
  234. */
  235. OPTION_MAX_PARAMETERS = 6,
  236. /*!
  237. * Timeout value in ms for how much to wait for OSC-Bridges to respond.\n
  238. * Default is 4000 (4 secs).
  239. */
  240. OPTION_OSC_UI_TIMEOUT = 7,
  241. /*!
  242. * Prefered buffer size.
  243. */
  244. OPTION_PREFERRED_BUFFER_SIZE = 8,
  245. /*!
  246. * Prefered sample rate.
  247. */
  248. OPTION_PREFERRED_SAMPLE_RATE = 9,
  249. #ifndef BUILD_BRIDGE
  250. /*!
  251. * Set path to the native plugin bridge executable.\n
  252. * Default unset.
  253. */
  254. OPTION_PATH_BRIDGE_NATIVE = 10,
  255. /*!
  256. * Set path to the POSIX 32bit plugin bridge executable.\n
  257. * Default unset.
  258. */
  259. OPTION_PATH_BRIDGE_POSIX32 = 11,
  260. /*!
  261. * Set path to the POSIX 64bit plugin bridge executable.\n
  262. * Default unset.
  263. */
  264. OPTION_PATH_BRIDGE_POSIX64 = 12,
  265. /*!
  266. * Set path to the Windows 32bit plugin bridge executable.\n
  267. * Default unset.
  268. */
  269. OPTION_PATH_BRIDGE_WIN32 = 13,
  270. /*!
  271. * Set path to the Windows 64bit plugin bridge executable.\n
  272. * Default unset.
  273. */
  274. OPTION_PATH_BRIDGE_WIN64 = 14,
  275. #endif
  276. #ifdef WANT_LV2
  277. /*!
  278. * Set path to the LV2 Gtk2 UI bridge executable.\n
  279. * Default unset.
  280. */
  281. OPTION_PATH_BRIDGE_LV2_GTK2 = 15,
  282. /*!
  283. * Set path to the LV2 Gtk3 UI bridge executable.\n
  284. * Default unset.
  285. */
  286. OPTION_PATH_BRIDGE_LV2_GTK3 = 16,
  287. /*!
  288. * Set path to the LV2 Qt4 UI bridge executable.\n
  289. * Default unset.
  290. */
  291. OPTION_PATH_BRIDGE_LV2_QT4 = 17,
  292. /*!
  293. * Set path to the LV2 Qt5 UI bridge executable.\n
  294. * Default unset.
  295. */
  296. OPTION_PATH_BRIDGE_LV2_QT5 = 18,
  297. /*!
  298. * Set path to the LV2 Cocoa UI bridge executable.\n
  299. * Default unset.
  300. */
  301. OPTION_PATH_BRIDGE_LV2_COCOA = 19,
  302. /*!
  303. * Set path to the LV2 Windows UI bridge executable.\n
  304. * Default unset.
  305. */
  306. OPTION_PATH_BRIDGE_LV2_WINDOWS = 20,
  307. /*!
  308. * Set path to the LV2 X11 UI bridge executable.\n
  309. * Default unset.
  310. */
  311. OPTION_PATH_BRIDGE_LV2_X11 = 21,
  312. #endif
  313. #ifdef WANT_VST
  314. /*!
  315. * Set path to the VST Cocoa UI bridge executable.\n
  316. * Default unset.
  317. */
  318. OPTION_PATH_BRIDGE_VST_COCOA = 22,
  319. /*!
  320. * Set path to the VST HWND UI bridge executable.\n
  321. * Default unset.
  322. */
  323. OPTION_PATH_BRIDGE_VST_HWND = 23,
  324. /*!
  325. * Set path to the VST X11 UI bridge executable.\n
  326. * Default unset.
  327. */
  328. OPTION_PATH_BRIDGE_VST_X11 = 24
  329. #endif
  330. };
  331. /*!
  332. * Opcodes sent from the engine callback to the GUI, as defined by CallbackFunc.
  333. *
  334. * \see CarlaEngine::setCallback()
  335. * \see set_callback_function()
  336. */
  337. enum CallbackType {
  338. /*!
  339. * Debug.\n
  340. * This opcode is undefined and used only for testing purposes.
  341. */
  342. CALLBACK_DEBUG = 0,
  343. /*!
  344. * A plugin has been added.
  345. */
  346. CALLBACK_PLUGIN_ADDED = 1,
  347. /*!
  348. * A plugin has been removed.
  349. */
  350. CALLBACK_PLUGIN_REMOVED = 2,
  351. /*!
  352. * A parameter value has been changed.
  353. *
  354. * \param value1 Parameter index
  355. * \param value3 Value
  356. */
  357. CALLBACK_PARAMETER_VALUE_CHANGED = 3,
  358. /*!
  359. * A parameter default has been changed.
  360. *
  361. * \param value1 Parameter index
  362. * \param value3 Default value
  363. */
  364. CALLBACK_PARAMETER_DEFAULT_CHANGED = 4,
  365. /*!
  366. * A parameter's MIDI channel has been changed.
  367. *
  368. * \param value1 Parameter index
  369. * \param value2 MIDI channel
  370. */
  371. CALLBACK_PARAMETER_MIDI_CHANNEL_CHANGED = 5,
  372. /*!
  373. * A parameter's MIDI CC has been changed.
  374. *
  375. * \param value1 Parameter index
  376. * \param value2 MIDI CC
  377. */
  378. CALLBACK_PARAMETER_MIDI_CC_CHANGED = 6,
  379. /*!
  380. * The current program has has been changed.
  381. *
  382. * \param value1 Program index
  383. */
  384. CALLBACK_PROGRAM_CHANGED = 7,
  385. /*!
  386. * The current MIDI program has been changed.
  387. *
  388. * \param value1 MIDI bank
  389. * \param value2 MIDI program
  390. */
  391. CALLBACK_MIDI_PROGRAM_CHANGED = 8,
  392. /*!
  393. * A note has been pressed.
  394. *
  395. * \param value1 Channel
  396. * \param value2 Note
  397. * \param value3 Velocity
  398. */
  399. CALLBACK_NOTE_ON = 9,
  400. /*!
  401. * A note has been released.
  402. *
  403. * \param value1 Channel
  404. * \param value2 Note
  405. */
  406. CALLBACK_NOTE_OFF = 10,
  407. /*!
  408. * The plugin's custom GUI state has changed.
  409. *
  410. * \param value1 State, as follows:.\n
  411. * 0: GUI has been closed or hidden\n
  412. * 1: GUI has been shown\n
  413. * -1: GUI has crashed and should not be shown again
  414. */
  415. CALLBACK_SHOW_GUI = 11,
  416. /*!
  417. * The plugin needs update.
  418. */
  419. CALLBACK_UPDATE = 12,
  420. /*!
  421. * The plugin's data/information has changed.
  422. */
  423. CALLBACK_RELOAD_INFO = 13,
  424. /*!
  425. * The plugin's parameters have changed.
  426. */
  427. CALLBACK_RELOAD_PARAMETERS = 14,
  428. /*!
  429. * The plugin's programs have changed.
  430. */
  431. CALLBACK_RELOAD_PROGRAMS = 15,
  432. /*!
  433. * The plugin's state has changed.
  434. */
  435. CALLBACK_RELOAD_ALL = 16,
  436. /*!
  437. * Non-Session-Manager Announce message.
  438. */
  439. CALLBACK_NSM_ANNOUNCE = 17,
  440. /*!
  441. * Non-Session-Manager Open message #1.
  442. */
  443. CALLBACK_NSM_OPEN1 = 18,
  444. /*!
  445. * Non-Session-Manager Open message #2.
  446. */
  447. CALLBACK_NSM_OPEN2 = 19,
  448. /*!
  449. * Non-Session-Manager Save message.
  450. */
  451. CALLBACK_NSM_SAVE = 20,
  452. /*!
  453. * An error occurred, show last error to user.
  454. */
  455. CALLBACK_ERROR = 21,
  456. /*!
  457. * The engine has crashed or malfunctioned and will no longer work.
  458. */
  459. CALLBACK_QUIT = 22
  460. };
  461. /*!
  462. * Engine process mode.
  463. *
  464. * \see OPTION_PROCESS_MODE
  465. */
  466. enum ProcessMode {
  467. PROCESS_MODE_SINGLE_CLIENT = 0, //!< Single client mode (dynamic input/outputs as needed by plugins)
  468. PROCESS_MODE_MULTIPLE_CLIENTS = 1, //!< Multiple client mode (1 master client + 1 client per plugin)
  469. PROCESS_MODE_CONTINUOUS_RACK = 2, //!< Single client, 'rack' mode. Processes plugins in order of id, with forced stereo.
  470. PROCESS_MODE_PATCHBAY = 3, //!< Single client, 'patchbay' mode.
  471. PROCESS_MODE_BRIDGE = 4 //!< Special mode, used in plugin-bridges only. RT buffers come from shared memory in a separate host app.
  472. };
  473. /*!
  474. * Callback function the engine will call when something interesting happens.
  475. *
  476. * \see CallbackType and set_callback_function()
  477. */
  478. typedef void (*CallbackFunc)(void* ptr, CallbackType action, unsigned int pluginId, int value1, int value2, float value3, const char* valueStr);
  479. /*!
  480. * Parameter data
  481. */
  482. struct ParameterData {
  483. ParameterType type;
  484. int32_t index;
  485. int32_t rindex;
  486. int32_t hints;
  487. uint8_t midiChannel;
  488. int16_t midiCC;
  489. ParameterData()
  490. : type(PARAMETER_UNKNOWN),
  491. index(-1),
  492. rindex(-1),
  493. hints(0),
  494. midiChannel(0),
  495. midiCC(-1) {}
  496. };
  497. /*!
  498. * Parameter ranges
  499. */
  500. struct ParameterRanges {
  501. float def;
  502. float min;
  503. float max;
  504. float step;
  505. float stepSmall;
  506. float stepLarge;
  507. ParameterRanges()
  508. : def(0.0f),
  509. min(0.0f),
  510. max(1.0f),
  511. step(0.01f),
  512. stepSmall(0.0001f),
  513. stepLarge(0.1f) {}
  514. void fixDefault()
  515. {
  516. fixValue(def);
  517. }
  518. void fixValue(float& value) const
  519. {
  520. if (value < min)
  521. value = min;
  522. else if (value > max)
  523. value = max;
  524. }
  525. float fixValue(const float& value) const
  526. {
  527. if (value < min)
  528. return min;
  529. else if (value > max)
  530. return max;
  531. return value;
  532. }
  533. float normalizeValue(const float& value) const
  534. {
  535. return (value - min) / (max - min);
  536. }
  537. float unnormalizeValue(const float& value) const
  538. {
  539. return value * (max - min) + min;
  540. }
  541. };
  542. /*!
  543. * MIDI Program data
  544. */
  545. struct MidiProgramData {
  546. uint32_t bank;
  547. uint32_t program;
  548. const char* name;
  549. MidiProgramData()
  550. : bank(0),
  551. program(0),
  552. name(nullptr) {}
  553. ~MidiProgramData()
  554. {
  555. if (name != nullptr)
  556. delete[] name;
  557. }
  558. };
  559. /*!
  560. * Custom data, saving key:value 'dictionaries'.
  561. * \a type is an URI which defines the \a value type.
  562. *
  563. * \see CustomDataTypes
  564. */
  565. struct CustomData {
  566. const char* type;
  567. const char* key;
  568. const char* value;
  569. CustomData()
  570. : type(nullptr),
  571. key(nullptr),
  572. value(nullptr) {}
  573. ~CustomData()
  574. {
  575. if (type != nullptr)
  576. delete[] type;
  577. if (key != nullptr)
  578. delete[] key;
  579. if (value != nullptr)
  580. delete[] value;
  581. }
  582. };
  583. /**@}*/
  584. // forward declarations of commonly used Carla classes
  585. class CarlaEngine;
  586. class CarlaPlugin;
  587. CARLA_BACKEND_END_NAMESPACE
  588. #endif // __CARLA_BACKEND_HPP__