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.

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