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.

665 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. #ifndef BUILD_BRIDGE
  146. PLUGIN_INTERNAL = 1, //!< Internal plugin.\see NativePlugin
  147. #endif
  148. PLUGIN_LADSPA = 2, //!< LADSPA plugin.\see LadspaPlugin
  149. PLUGIN_DSSI = 3, //!< DSSI plugin.\see DssiPlugin
  150. PLUGIN_LV2 = 4, //!< LV2 plugin.\see Lv2Plugin
  151. PLUGIN_VST = 5, //!< VST plugin.\see VstPlugin
  152. #ifndef BUILD_BRIDGE
  153. PLUGIN_GIG = 6, //!< GIG sound kit, implemented via LinuxSampler.\see LinuxSamplerPlugin
  154. PLUGIN_SF2 = 7, //!< SF2 sound kit (aka SoundFont), implemented via FluidSynth.\see FluidSynthPlugin
  155. PLUGIN_SFZ = 8 //!< SFZ sound kit, implemented via LinuxSampler.\see LinuxSamplerPlugin
  156. #endif
  157. };
  158. /*!
  159. * Plugin category, describing the funtionality of a plugin.\n
  160. * When a plugin fails to tell his own category, one is atributted to it based on its name.
  161. */
  162. enum PluginCategory {
  163. PLUGIN_CATEGORY_NONE = 0, //!< Null plugin category.
  164. PLUGIN_CATEGORY_SYNTH = 1, //!< A synthesizer or generator.
  165. PLUGIN_CATEGORY_DELAY = 2, //!< A delay or reverberator.
  166. PLUGIN_CATEGORY_EQ = 3, //!< An equalizer.
  167. PLUGIN_CATEGORY_FILTER = 4, //!< A filter.
  168. PLUGIN_CATEGORY_DYNAMICS = 5, //!< A 'dynamic' plugin (amplifier, compressor, gate, etc).
  169. PLUGIN_CATEGORY_MODULATOR = 6, //!< A 'modulator' plugin (chorus, flanger, phaser, etc).
  170. PLUGIN_CATEGORY_UTILITY = 7, //!< An 'utility' plugin (analyzer, converter, mixer, etc).
  171. PLUGIN_CATEGORY_OTHER = 8 //!< Misc plugin (used to check if the plugin has a category).
  172. };
  173. /*!
  174. * Plugin parameter type.
  175. */
  176. enum ParameterType {
  177. PARAMETER_UNKNOWN = 0, //!< Null parameter type.
  178. PARAMETER_INPUT = 1, //!< Input parameter.
  179. PARAMETER_OUTPUT = 2, //!< Ouput parameter.
  180. PARAMETER_LATENCY = 3, //!< Special latency parameter, used in LADSPA, DSSI and LV2 plugins.
  181. PARAMETER_SAMPLE_RATE = 4, //!< Special sample-rate parameter, used in LADSPA, DSSI and LV2 plugins.
  182. #ifdef WANT_LV2
  183. PARAMETER_LV2_FREEWHEEL = 5, //!< Special LV2 Plugin parameter used to report freewheel (offline) mode.
  184. PARAMETER_LV2_TIME = 6 //!< Special LV2 Plugin parameter used to report time information.
  185. #endif
  186. };
  187. /*!
  188. * Internal parameter indexes.\n
  189. * These are special parameters used internally, plugins do not know about their existence.
  190. */
  191. enum InternalParametersIndex {
  192. PARAMETER_NULL = -1, //!< Null parameter.
  193. PARAMETER_ACTIVE = -2, //!< Active parameter, can only be 'true' or 'false'; default is 'false'.
  194. PARAMETER_DRYWET = -3, //!< Dry/Wet parameter, range 0.0...1.0; default is 1.0.
  195. PARAMETER_VOLUME = -4, //!< Volume parameter, range 0.0...1.27; default is 1.0.
  196. PARAMETER_BALANCE_LEFT = -5, //!< Stereo Balance-Left parameter, range -1.0...1.0; default is -1.0.
  197. PARAMETER_BALANCE_RIGHT = -6, //!< Stereo Balance-Right parameter, range -1.0...1.0; default is 1.0.
  198. PARAMETER_PANNING = -7, //!< Mono Panning parameter, range -1.0...1.0; default is 0.0.
  199. PARAMETER_MAX = -8 //!< Max value, defined for convenience
  200. };
  201. /*!
  202. * Options used in the CarlaEngine::setOption() and set_option() calls.\n
  203. * These options must be set before initiliazing or after closing the engine.
  204. */
  205. enum OptionsType {
  206. /*!
  207. * Try to set the current process name.
  208. * \note Not available on all platforms.
  209. */
  210. OPTION_PROCESS_NAME = 0,
  211. /*!
  212. * Set the engine processing mode.\n
  213. * Default is PROCESS_MODE_CONTINUOUS_RACK.
  214. * \see ProcessMode
  215. */
  216. OPTION_PROCESS_MODE = 1,
  217. /*!
  218. * Force mono plugins as stereo, by running 2 instances at the same time.
  219. * \note Not supported by all plugins.
  220. */
  221. OPTION_FORCE_STEREO = 2,
  222. /*!
  223. * Use plugin bridges whenever possible.\n
  224. * Default is no, and not recommended at this point!.
  225. * EXPERIMENTAL AND INCOMPLETE!
  226. */
  227. OPTION_PREFER_PLUGIN_BRIDGES = 3,
  228. /*!
  229. * Use OSC-UI bridges whenever possible, otherwise UIs will be handled in the main thread.\n
  230. * Default is yes.
  231. */
  232. OPTION_PREFER_UI_BRIDGES = 4,
  233. #ifdef WANT_DSSI
  234. /*!
  235. * Use (unofficial) dssi-vst chunks feature.\n
  236. * Default is no.
  237. */
  238. OPTION_USE_DSSI_VST_CHUNKS = 5,
  239. #endif
  240. /*!
  241. * Maximum number of parameters allowed.\n
  242. * Default is MAX_DEFAULT_PARAMETERS.
  243. */
  244. OPTION_MAX_PARAMETERS = 6,
  245. /*!
  246. * Timeout value in ms for how much to wait for OSC-Bridges to respond.\n
  247. * Default is 4000 (4 secs).
  248. */
  249. OPTION_OSC_UI_TIMEOUT = 7,
  250. /*!
  251. * Prefered buffer size.
  252. */
  253. OPTION_PREFERRED_BUFFER_SIZE = 8,
  254. /*!
  255. * Prefered sample rate.
  256. */
  257. OPTION_PREFERRED_SAMPLE_RATE = 9,
  258. #ifndef BUILD_BRIDGE
  259. /*!
  260. * Set path to the native plugin bridge executable.\n
  261. * Default unset.
  262. */
  263. OPTION_PATH_BRIDGE_NATIVE = 10,
  264. /*!
  265. * Set path to the POSIX 32bit plugin bridge executable.\n
  266. * Default unset.
  267. */
  268. OPTION_PATH_BRIDGE_POSIX32 = 11,
  269. /*!
  270. * Set path to the POSIX 64bit plugin bridge executable.\n
  271. * Default unset.
  272. */
  273. OPTION_PATH_BRIDGE_POSIX64 = 12,
  274. /*!
  275. * Set path to the Windows 32bit plugin bridge executable.\n
  276. * Default unset.
  277. */
  278. OPTION_PATH_BRIDGE_WIN32 = 13,
  279. /*!
  280. * Set path to the Windows 64bit plugin bridge executable.\n
  281. * Default unset.
  282. */
  283. OPTION_PATH_BRIDGE_WIN64 = 14,
  284. #endif
  285. #ifdef WANT_LV2
  286. /*!
  287. * Set path to the LV2 Gtk2 UI bridge executable.\n
  288. * Default unset.
  289. */
  290. OPTION_PATH_BRIDGE_LV2_GTK2 = 15,
  291. /*!
  292. * Set path to the LV2 Gtk3 UI bridge executable.\n
  293. * Default unset.
  294. */
  295. OPTION_PATH_BRIDGE_LV2_GTK3 = 16,
  296. /*!
  297. * Set path to the LV2 Qt4 UI bridge executable.\n
  298. * Default unset.
  299. */
  300. OPTION_PATH_BRIDGE_LV2_QT4 = 17,
  301. /*!
  302. * Set path to the LV2 Qt5 UI bridge executable.\n
  303. * Default unset.
  304. */
  305. OPTION_PATH_BRIDGE_LV2_QT5 = 18,
  306. /*!
  307. * Set path to the LV2 Cocoa UI bridge executable.\n
  308. * Default unset.
  309. */
  310. OPTION_PATH_BRIDGE_LV2_COCOA = 19,
  311. /*!
  312. * Set path to the LV2 Windows UI bridge executable.\n
  313. * Default unset.
  314. */
  315. OPTION_PATH_BRIDGE_LV2_WINDOWS = 20,
  316. /*!
  317. * Set path to the LV2 X11 UI bridge executable.\n
  318. * Default unset.
  319. */
  320. OPTION_PATH_BRIDGE_LV2_X11 = 21,
  321. #endif
  322. #ifdef WANT_VST
  323. /*!
  324. * Set path to the VST Cocoa UI bridge executable.\n
  325. * Default unset.
  326. */
  327. OPTION_PATH_BRIDGE_VST_COCOA = 22,
  328. /*!
  329. * Set path to the VST HWND UI bridge executable.\n
  330. * Default unset.
  331. */
  332. OPTION_PATH_BRIDGE_VST_HWND = 23,
  333. /*!
  334. * Set path to the VST X11 UI bridge executable.\n
  335. * Default unset.
  336. */
  337. OPTION_PATH_BRIDGE_VST_X11 = 24
  338. #endif
  339. };
  340. /*!
  341. * Opcodes sent from the engine callback to the GUI, as defined by CallbackFunc.
  342. *
  343. * \see CarlaEngine::setCallback()
  344. * \see set_callback_function()
  345. */
  346. enum CallbackType {
  347. /*!
  348. * Debug.\n
  349. * This opcode is undefined and used only for testing purposes.
  350. */
  351. CALLBACK_DEBUG = 0,
  352. /*!
  353. * A plugin has been added.
  354. */
  355. CALLBACK_PLUGIN_ADDED = 1,
  356. /*!
  357. * A plugin has been removed.
  358. */
  359. CALLBACK_PLUGIN_REMOVED = 2,
  360. /*!
  361. * A parameter has been changed.
  362. *
  363. * \param value1 Parameter index
  364. * \param value3 Value
  365. */
  366. CALLBACK_PARAMETER_VALUE_CHANGED = 3,
  367. /*!
  368. * A parameter's MIDI channel has been changed.
  369. *
  370. * \param value1 Parameter index
  371. * \param value2 MIDI channel
  372. */
  373. CALLBACK_PARAMETER_MIDI_CHANNEL_CHANGED = 4,
  374. /*!
  375. * A parameter's MIDI CC has been changed.
  376. *
  377. * \param value1 Parameter index
  378. * \param value2 MIDI CC
  379. */
  380. CALLBACK_PARAMETER_MIDI_CC_CHANGED = 5,
  381. /*!
  382. * The current program has has been changed.
  383. *
  384. * \param value1 Program index
  385. */
  386. CALLBACK_PROGRAM_CHANGED = 6,
  387. /*!
  388. * The current MIDI program has been changed.
  389. *
  390. * \param value1 MIDI bank
  391. * \param value2 MIDI program
  392. */
  393. CALLBACK_MIDI_PROGRAM_CHANGED = 7,
  394. /*!
  395. * A note has been pressed.
  396. *
  397. * \param value1 Channel
  398. * \param value2 Note
  399. * \param value3 Velocity
  400. */
  401. CALLBACK_NOTE_ON = 8,
  402. /*!
  403. * A note has been released.
  404. *
  405. * \param value1 Channel
  406. * \param value2 Note
  407. */
  408. CALLBACK_NOTE_OFF = 9,
  409. /*!
  410. * The plugin's custom GUI state has changed.
  411. *
  412. * \param value1 State, as follows:.\n
  413. * 0: GUI has been closed or hidden\n
  414. * 1: GUI has been shown\n
  415. * -1: GUI has crashed and should not be shown again
  416. */
  417. CALLBACK_SHOW_GUI = 10,
  418. /*!
  419. * The plugin needs update.
  420. */
  421. CALLBACK_UPDATE = 11,
  422. /*!
  423. * The plugin's data/information has changed.
  424. */
  425. CALLBACK_RELOAD_INFO = 12,
  426. /*!
  427. * The plugin's parameters have changed.
  428. */
  429. CALLBACK_RELOAD_PARAMETERS = 13,
  430. /*!
  431. * The plugin's programs have changed.
  432. */
  433. CALLBACK_RELOAD_PROGRAMS = 14,
  434. /*!
  435. * The plugin's state has changed.
  436. */
  437. CALLBACK_RELOAD_ALL = 15,
  438. /*!
  439. * Non-Session-Manager Announce message.
  440. */
  441. CALLBACK_NSM_ANNOUNCE = 16,
  442. /*!
  443. * Non-Session-Manager Open message #1.
  444. */
  445. CALLBACK_NSM_OPEN1 = 17,
  446. /*!
  447. * Non-Session-Manager Open message #2.
  448. */
  449. CALLBACK_NSM_OPEN2 = 18,
  450. /*!
  451. * Non-Session-Manager Save message.
  452. */
  453. CALLBACK_NSM_SAVE = 19,
  454. /*!
  455. * An error occurred, show last error to user.
  456. */
  457. CALLBACK_ERROR = 20,
  458. /*!
  459. * The engine has crashed or malfunctioned and will no longer work.
  460. */
  461. CALLBACK_QUIT = 21
  462. };
  463. /*!
  464. * Engine process mode.
  465. *
  466. * \see OPTION_PROCESS_MODE
  467. */
  468. enum ProcessMode {
  469. PROCESS_MODE_SINGLE_CLIENT = 0, //!< Single client mode (dynamic input/outputs as needed by plugins)
  470. PROCESS_MODE_MULTIPLE_CLIENTS = 1, //!< Multiple client mode (1 master client + 1 client per plugin)
  471. PROCESS_MODE_CONTINUOUS_RACK = 2, //!< Single client, 'rack' mode. Processes plugins in order of id, with forced stereo.
  472. PROCESS_MODE_PATCHBAY = 3, //!< Single client, 'patchbay' mode.
  473. PROCESS_MODE_BRIDGE = 4 //!< Special mode, used in plugin-bridges only. RT buffers come from shared memory in a separate host app.
  474. };
  475. /*!
  476. * Callback function the engine will call when something interesting happens.
  477. *
  478. * \see CallbackType and set_callback_function()
  479. */
  480. typedef void (*CallbackFunc)(void* ptr, CallbackType action, unsigned int pluginId, int value1, int value2, float value3, const char* valueStr);
  481. /*!
  482. * Parameter data
  483. */
  484. struct ParameterData {
  485. ParameterType type;
  486. int32_t index;
  487. int32_t rindex;
  488. int32_t hints;
  489. uint8_t midiChannel;
  490. int16_t midiCC;
  491. ParameterData()
  492. : type(PARAMETER_UNKNOWN),
  493. index(-1),
  494. rindex(-1),
  495. hints(0),
  496. midiChannel(0),
  497. midiCC(-1) {}
  498. };
  499. /*!
  500. * Parameter ranges
  501. */
  502. struct ParameterRanges {
  503. float def;
  504. float min;
  505. float max;
  506. float step;
  507. float stepSmall;
  508. float stepLarge;
  509. ParameterRanges()
  510. : def(0.0f),
  511. min(0.0f),
  512. max(1.0f),
  513. step(0.01f),
  514. stepSmall(0.0001f),
  515. stepLarge(0.1f) {}
  516. void fixDefault()
  517. {
  518. fixValue(def);
  519. }
  520. void fixValue(float& value) const
  521. {
  522. if (value < min)
  523. value = min;
  524. else if (value > max)
  525. value = max;
  526. }
  527. float fixValue(const float& value) const
  528. {
  529. if (value < min)
  530. return min;
  531. else if (value > max)
  532. return max;
  533. return value;
  534. }
  535. };
  536. /*!
  537. * MIDI Program data
  538. */
  539. struct MidiProgramData {
  540. uint32_t bank;
  541. uint32_t program;
  542. const char* name;
  543. MidiProgramData()
  544. : bank(0),
  545. program(0),
  546. name(nullptr) {}
  547. ~MidiProgramData()
  548. {
  549. std::free((void*)name);
  550. }
  551. };
  552. /*!
  553. * Custom data, saving key:value 'dictionaries'.
  554. * \a type is an URI which defines the \a value type.
  555. *
  556. * \see CustomDataTypes
  557. */
  558. struct CustomData {
  559. const char* type;
  560. const char* key;
  561. const char* value;
  562. CustomData()
  563. : type(nullptr),
  564. key(nullptr),
  565. value(nullptr) {}
  566. ~CustomData()
  567. {
  568. std::free((void*)type);
  569. std::free((void*)key);
  570. std::free((void*)value);
  571. }
  572. };
  573. /**@}*/
  574. // forward declarations of commonly used Carla classes
  575. class CarlaEngine;
  576. class CarlaPlugin;
  577. CARLA_BACKEND_END_NAMESPACE
  578. #endif // __CARLA_BACKEND_HPP__