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.

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