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.

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