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.

805 lines
23KB

  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 doc/GPL.txt file.
  16. */
  17. #ifndef CARLA_BACKEND_HPP_INCLUDED
  18. #define CARLA_BACKEND_HPP_INCLUDED
  19. #include "CarlaDefines.hpp"
  20. #ifdef CARLA_PROPER_CPP11_SUPPORT
  21. # include <cstdint>
  22. #else
  23. # include <stdint.h>
  24. #endif
  25. #define CARLA_BACKEND_START_NAMESPACE namespace CarlaBackend {
  26. #define CARLA_BACKEND_END_NAMESPACE }
  27. #define CARLA_BACKEND_USE_NAMESPACE using namespace CarlaBackend;
  28. #define STR_MAX 0xFF
  29. CARLA_BACKEND_START_NAMESPACE
  30. /*!
  31. * @defgroup CarlaBackendAPI Carla Backend API
  32. *
  33. * The Carla Backend API.\n
  34. * This is the base definitions for everything in the Carla code.
  35. * @{
  36. */
  37. const unsigned int MAX_DEFAULT_PLUGINS = 99; //!< Maximum default number of loadable plugins.
  38. const unsigned int MAX_RACK_PLUGINS = 16; //!< Maximum number of loadable plugins in rack mode.
  39. const unsigned int MAX_PATCHBAY_PLUGINS = 255; //!< Maximum number of loadable plugins in patchbay mode.
  40. const unsigned int MAX_DEFAULT_PARAMETERS = 200; //!< Maximum default number of parameters allowed.\see OPTION_MAX_PARAMETERS
  41. /*!
  42. * @defgroup PluginHints Plugin Hints
  43. *
  44. * Various plugin hints.
  45. * \see CarlaPlugin::hints()
  46. * @{
  47. */
  48. const unsigned int PLUGIN_IS_BRIDGE = 0x001; //!< Plugin is a bridge. This hint is required because "bridge" itself is not a plugin type.
  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_HAS_SINGLE_THREAD = 0x020; //!< Plugin has a single thread for all UI events (not thread-safe).
  53. const unsigned int PLUGIN_CAN_DRYWET = 0x100; //!< Plugin can use internal Dry/Wet control.
  54. const unsigned int PLUGIN_CAN_VOLUME = 0x200; //!< Plugin can use internal Volume control.
  55. const unsigned int PLUGIN_CAN_BALANCE = 0x400; //!< Plugin can use internal Left & Right Balance controls.
  56. const unsigned int PLUGIN_CAN_PANNING = 0x800; //!< Plugin can use internal Panning control.
  57. /**@}*/
  58. /*!
  59. * @defgroup PluginOptions Plugin Options
  60. *
  61. * Various plugin options.
  62. * \see CarlaPlugin::availableOptions() and CarlaPlugin::options()
  63. * @{
  64. */
  65. const unsigned int PLUGIN_OPTION_FIXED_BUFFER = 0x001; //!< Use a constant/fixed-size audio buffer.
  66. const unsigned int PLUGIN_OPTION_FORCE_STEREO = 0x002; //!< Force mono plugin as stereo.
  67. const unsigned int PLUGIN_OPTION_MAP_PROGRAM_CHANGES = 0x004; //!< Map MIDI-Programs to plugin programs.
  68. const unsigned int PLUGIN_OPTION_USE_CHUNKS = 0x008; //!< Use chunks to save&restore data.
  69. const unsigned int PLUGIN_OPTION_SEND_CONTROL_CHANGES = 0x010; //!< Send MIDI control change events.
  70. const unsigned int PLUGIN_OPTION_SEND_CHANNEL_PRESSURE = 0x020; //!< Send MIDI channel pressure events.
  71. const unsigned int PLUGIN_OPTION_SEND_NOTE_AFTERTOUCH = 0x040; //!< Send MIDI note aftertouch events.
  72. const unsigned int PLUGIN_OPTION_SEND_PITCHBEND = 0x080; //!< Send MIDI pitchbend events.
  73. const unsigned int PLUGIN_OPTION_SEND_ALL_SOUND_OFF = 0x100; //!< Send MIDI all-sounds/notes-off events, single note-offs otherwise.
  74. /**@}*/
  75. /*!
  76. * @defgroup ParameterHints Parameter Hints
  77. *
  78. * Various parameter hints.
  79. * \see CarlaPlugin::parameterData()
  80. * @{
  81. */
  82. const unsigned int PARAMETER_IS_BOOLEAN = 0x001; //!< Parameter value is a boolean (always at minimum or maximum values).
  83. const unsigned int PARAMETER_IS_INTEGER = 0x002; //!< Parameter value is an integer.
  84. const unsigned int PARAMETER_IS_LOGARITHMIC = 0x004; //!< Parameter values are logarithmic.
  85. const unsigned int PARAMETER_IS_ENABLED = 0x008; //!< Parameter is enabled (can be changed).
  86. const unsigned int PARAMETER_IS_AUTOMABLE = 0x010; //!< Parameter is automable (realtime safe).
  87. const unsigned int PARAMETER_IS_READ_ONLY = 0x020; //!< Parameter is read-only.
  88. const unsigned int PARAMETER_USES_SAMPLERATE = 0x040; //!< Parameter needs Sample-Rate to work (value and ranges are multiplied by SR, and must be divided by SR on save).
  89. const unsigned int PARAMETER_USES_SCALEPOINTS = 0x080; //!< Parameter uses scalepoints to define internal values in a meaningful way.
  90. const unsigned int PARAMETER_USES_CUSTOM_TEXT = 0x100; //!< Parameter uses custom text for displaying its value.\see CarlaPlugin::getParameterText()
  91. /**@}*/
  92. /*!
  93. * @defgroup CustomDataTypes Custom Data types
  94. *
  95. * The type defines how the \param value in the CustomData struct is stored.\n
  96. * Types are valid URIs. Any non-string or non-simple type (not integral) is saved in a base64 encoded format.
  97. * \see CustomData
  98. * @{
  99. */
  100. const char* const CUSTOM_DATA_INVALID = nullptr; //!< Null or invalid data.
  101. const char* const CUSTOM_DATA_CHUNK = "http://kxstudio.sf.net/ns/carla/chunk"; //!< Carla chunk URI.
  102. const char* const CUSTOM_DATA_STRING = "http://kxstudio.sf.net/ns/carla/string"; //!< Carla string URI.
  103. /**@}*/
  104. /*!
  105. * @defgroup PatchbayPortHints Patchbay Port Hints
  106. *
  107. * Various patchbay port hints.
  108. * @{
  109. */
  110. const unsigned int PATCHBAY_PORT_IS_INPUT = 0x01; //!< Patchbay port is input.
  111. const unsigned int PATCHBAY_PORT_IS_OUTPUT = 0x02; //!< Patchbay port is output.
  112. const unsigned int PATCHBAY_PORT_IS_AUDIO = 0x10; //!< Patchbay port is of Audio type.
  113. const unsigned int PATCHBAY_PORT_IS_CV = 0x20; //!< Patchbay port is of CV type.
  114. const unsigned int PATCHBAY_PORT_IS_MIDI = 0x40; //!< Patchbay port is of MIDI type.
  115. /**@}*/
  116. /*!
  117. * The binary type of a plugin.
  118. */
  119. enum BinaryType {
  120. BINARY_NONE = 0, //!< Null binary type.
  121. BINARY_POSIX32 = 1, //!< POSIX 32bit.
  122. BINARY_POSIX64 = 2, //!< POSIX 64bit.
  123. BINARY_WIN32 = 3, //!< Windows 32bit.
  124. BINARY_WIN64 = 4, //!< Windows 64bit.
  125. BINARY_OTHER = 5 //!< Other.
  126. };
  127. /*!
  128. * All the available plugin types, provided by subclasses of CarlaPlugin.\n
  129. * Some plugin classes might provide more than 1 plugin type.
  130. */
  131. enum PluginType {
  132. PLUGIN_NONE = 0, //!< Null plugin type.
  133. PLUGIN_INTERNAL = 1, //!< Internal plugin.
  134. PLUGIN_LADSPA = 2, //!< LADSPA plugin.
  135. PLUGIN_DSSI = 3, //!< DSSI plugin.
  136. PLUGIN_LV2 = 4, //!< LV2 plugin.
  137. PLUGIN_VST = 5, //!< VST1/2 plugin.
  138. PLUGIN_VST3 = 6, //!< VST3 plugin.
  139. PLUGIN_GIG = 7, //!< GIG sound kit.
  140. PLUGIN_SF2 = 8, //!< SF2 sound kit (aka SoundFont).
  141. PLUGIN_SFZ = 9 //!< SFZ sound kit.
  142. };
  143. /*!
  144. * Plugin category, describing the funtionality of a plugin.\n
  145. * When a plugin fails to tell its own category, one is atributted to it based on its name.
  146. */
  147. enum PluginCategory {
  148. PLUGIN_CATEGORY_NONE = 0, //!< Null plugin category.
  149. PLUGIN_CATEGORY_SYNTH = 1, //!< A synthesizer or generator.
  150. PLUGIN_CATEGORY_DELAY = 2, //!< A delay or reverberator.
  151. PLUGIN_CATEGORY_EQ = 3, //!< An equalizer.
  152. PLUGIN_CATEGORY_FILTER = 4, //!< A filter.
  153. PLUGIN_CATEGORY_DYNAMICS = 5, //!< A 'dynamic' plugin (amplifier, compressor, gate, etc).
  154. PLUGIN_CATEGORY_MODULATOR = 6, //!< A 'modulator' plugin (chorus, flanger, phaser, etc).
  155. PLUGIN_CATEGORY_UTILITY = 7, //!< An 'utility' plugin (analyzer, converter, mixer, etc).
  156. PLUGIN_CATEGORY_OTHER = 8 //!< Misc plugin (used to check if the plugin has a category).
  157. };
  158. /*!
  159. * Plugin parameter type.
  160. */
  161. enum ParameterType {
  162. PARAMETER_UNKNOWN = 0, //!< Null parameter type.
  163. PARAMETER_INPUT = 1, //!< Input parameter.
  164. PARAMETER_OUTPUT = 2, //!< Ouput parameter.
  165. PARAMETER_LATENCY = 3, //!< Special latency parameter, used in LADSPA, DSSI and LV2 plugins.
  166. PARAMETER_SAMPLE_RATE = 4, //!< Special sample-rate parameter, used in LADSPA, DSSI and LV2 plugins.
  167. #ifdef WANT_LV2
  168. PARAMETER_LV2_FREEWHEEL = 5, //!< Special LV2 Plugin parameter used to report freewheel (offline) mode.
  169. PARAMETER_LV2_TIME = 6 //!< Special LV2 Plugin parameter used to report time information.
  170. #endif
  171. };
  172. /*!
  173. * Internal parameter indexes.\n
  174. * These are special parameters used internally, plugins do not know about their existence.
  175. */
  176. enum InternalParametersIndex {
  177. PARAMETER_NULL = -1, //!< Null parameter.
  178. PARAMETER_ACTIVE = -2, //!< Active parameter, can only be 'true' or 'false'; default is 'false'.
  179. PARAMETER_DRYWET = -3, //!< Dry/Wet parameter, range 0.0...1.0; default is 1.0.
  180. PARAMETER_VOLUME = -4, //!< Volume parameter, range 0.0...1.27; default is 1.0.
  181. PARAMETER_BALANCE_LEFT = -5, //!< Stereo Balance-Left parameter, range -1.0...1.0; default is -1.0.
  182. PARAMETER_BALANCE_RIGHT = -6, //!< Stereo Balance-Right parameter, range -1.0...1.0; default is 1.0.
  183. PARAMETER_PANNING = -7, //!< Mono Panning parameter, range -1.0...1.0; default is 0.0.
  184. PARAMETER_CTRL_CHANNEL = -8, //!< MIDI Control channel, range -1...15 (-1 = off).
  185. PARAMETER_MAX = -9 //!< Max value, defined for convenience.
  186. };
  187. /*!
  188. * The icon of a patchbay client/group.
  189. */
  190. enum PatchbayIconType {
  191. PATCHBAY_ICON_APPLICATION = 0, //!< Generic application icon.
  192. PATCHBAY_ICON_HARDWARE = 1, //!< Hardware icon.
  193. PATCHBAY_ICON_CARLA = 2, //!< Carla icon.
  194. PATCHBAY_ICON_DISTRHO = 3, //!< DISTRHO icon.
  195. PATCHBAY_ICON_FILE = 4, //!< File icon.
  196. PATCHBAY_ICON_PLUGIN = 5 //!< Plugin icon.
  197. };
  198. /*!
  199. * Options used in the CarlaEngine::setOption() calls.\n
  200. * All options except paths must be set before initiliazing or after closing the engine.
  201. */
  202. enum OptionsType {
  203. /*!
  204. * Set the current process name.\n
  205. * This is a convenience option, as Python lacks this functionality.
  206. * \note Not available on all platforms.
  207. */
  208. OPTION_PROCESS_NAME = 0,
  209. /*!
  210. * Set the engine processing mode.\n
  211. * Default is PROCESS_MODE_MULTIPLE_CLIENTS on Linux and PROCESS_MODE_CONTINUOUS_RACK for all other OSes.
  212. * \see ProcessMode
  213. */
  214. OPTION_PROCESS_MODE = 1,
  215. /*!
  216. * Set the engine transport mode.\n
  217. * Default is TRANSPORT_MODE_INTERNAL.
  218. * \see TransportMode
  219. */
  220. OPTION_TRANSPORT_MODE = 2,
  221. /*!
  222. * Force mono plugins as stereo, by running 2 instances at the same time.
  223. * \note Not supported by all plugins.
  224. * \see PLUGIN_OPTION_FORCE_STEREO
  225. */
  226. OPTION_FORCE_STEREO = 3,
  227. /*!
  228. * Use plugin bridges whenever possible.\n
  229. * Default is no, EXPERIMENTAL.
  230. */
  231. OPTION_PREFER_PLUGIN_BRIDGES = 4,
  232. /*!
  233. * Use OSC-UI bridges whenever possible, otherwise UIs will be handled in the main thread.\n
  234. * Default is yes.
  235. */
  236. OPTION_PREFER_UI_BRIDGES = 5,
  237. /*!
  238. * Make plugin UIs always-on-top.\n
  239. * Default is yes.
  240. */
  241. OPTION_UIS_ALWAYS_ON_TOP = 6,
  242. #ifdef WANT_DSSI
  243. /*!
  244. * Use (unofficial) dssi-vst chunks feature.\n
  245. * Default is no.
  246. * \see PLUGIN_OPTION_USE_CHUNKS
  247. */
  248. OPTION_USE_DSSI_VST_CHUNKS = 7,
  249. #endif
  250. /*!
  251. * Maximum number of parameters allowed.\n
  252. * Default is MAX_DEFAULT_PARAMETERS.
  253. */
  254. OPTION_MAX_PARAMETERS = 8,
  255. /*!
  256. * Timeout value in ms for how much to wait for UI-Bridges to respond.\n
  257. * Default is 4000 (4 secs).
  258. */
  259. OPTION_UI_BRIDGES_TIMEOUT = 9,
  260. #ifdef WANT_RTAUDIO
  261. /*!
  262. * RtAudio number of periods.
  263. */
  264. OPTION_RTAUDIO_NUMBER_PERIODS = 10,
  265. /*!
  266. * RtAudio buffer size.
  267. */
  268. OPTION_RTAUDIO_BUFFER_SIZE = 11,
  269. /*!
  270. * RtAudio sample rate.
  271. */
  272. OPTION_RTAUDIO_SAMPLE_RATE = 12,
  273. /*!
  274. * RtAudio device.
  275. */
  276. OPTION_RTAUDIO_DEVICE = 13,
  277. #endif
  278. /*!
  279. * Set path to the backend resource files.\n
  280. * Default unset.
  281. *
  282. * \note Must be set for some internal plugins to work!
  283. */
  284. OPTION_PATH_RESOURCES = 14,
  285. #ifndef BUILD_BRIDGE
  286. /*!
  287. * Set path to the native plugin bridge executable.\n
  288. * Default unset.
  289. */
  290. OPTION_PATH_BRIDGE_NATIVE = 15,
  291. /*!
  292. * Set path to the POSIX 32bit plugin bridge executable.\n
  293. * Default unset.
  294. */
  295. OPTION_PATH_BRIDGE_POSIX32 = 16,
  296. /*!
  297. * Set path to the POSIX 64bit plugin bridge executable.\n
  298. * Default unset.
  299. */
  300. OPTION_PATH_BRIDGE_POSIX64 = 17,
  301. /*!
  302. * Set path to the Windows 32bit plugin bridge executable.\n
  303. * Default unset.
  304. */
  305. OPTION_PATH_BRIDGE_WIN32 = 18,
  306. /*!
  307. * Set path to the Windows 64bit plugin bridge executable.\n
  308. * Default unset.
  309. */
  310. OPTION_PATH_BRIDGE_WIN64 = 19,
  311. #endif
  312. #ifdef WANT_LV2
  313. /*!
  314. * Set path to the LV2 Gtk2 UI bridge executable.\n
  315. * Default unset.
  316. */
  317. OPTION_PATH_BRIDGE_LV2_GTK2 = 20,
  318. /*!
  319. * Set path to the LV2 Gtk3 UI bridge executable.\n
  320. * Default unset.
  321. */
  322. OPTION_PATH_BRIDGE_LV2_GTK3 = 21,
  323. /*!
  324. * Set path to the LV2 Qt4 UI bridge executable.\n
  325. * Default unset.
  326. */
  327. OPTION_PATH_BRIDGE_LV2_QT4 = 22,
  328. /*!
  329. * Set path to the LV2 Qt5 UI bridge executable.\n
  330. * Default unset.
  331. */
  332. OPTION_PATH_BRIDGE_LV2_QT5 = 23,
  333. /*!
  334. * Set path to the LV2 Cocoa UI bridge executable.\n
  335. * Default unset.
  336. */
  337. OPTION_PATH_BRIDGE_LV2_COCOA = 24,
  338. /*!
  339. * Set path to the LV2 Windows UI bridge executable.\n
  340. * Default unset.
  341. */
  342. OPTION_PATH_BRIDGE_LV2_WINDOWS = 25,
  343. /*!
  344. * Set path to the LV2 X11 UI bridge executable.\n
  345. * Default unset.
  346. */
  347. OPTION_PATH_BRIDGE_LV2_X11 = 26,
  348. #endif
  349. #ifdef WANT_VST
  350. /*!
  351. * Set path to the VST Cocoa UI bridge executable.\n
  352. * Default unset.
  353. */
  354. OPTION_PATH_BRIDGE_VST_COCOA = 27,
  355. /*!
  356. * Set path to the VST HWND UI bridge executable.\n
  357. * Default unset.
  358. */
  359. OPTION_PATH_BRIDGE_VST_HWND = 28,
  360. /*!
  361. * Set path to the VST X11 UI bridge executable.\n
  362. * Default unset.
  363. */
  364. OPTION_PATH_BRIDGE_VST_X11 = 29
  365. #endif
  366. };
  367. /*!
  368. * Opcodes sent from the engine callback to the GUI, as defined by CallbackFunc.
  369. * \see CarlaEngine::setCallback()
  370. */
  371. enum CallbackType {
  372. /*!
  373. * Debug.\n
  374. * This opcode is undefined and used only for testing purposes.
  375. */
  376. CALLBACK_DEBUG = 0,
  377. /*!
  378. * A plugin has been added.
  379. * \param valueStr Plugin name
  380. */
  381. CALLBACK_PLUGIN_ADDED = 1,
  382. /*!
  383. * A plugin has been removed.
  384. */
  385. CALLBACK_PLUGIN_REMOVED = 2,
  386. /*!
  387. * A plugin has been renamed.
  388. * \param valueStr New plugin name
  389. */
  390. CALLBACK_PLUGIN_RENAMED = 3,
  391. /*!
  392. * A parameter value has been changed.
  393. * \param value1 Parameter index
  394. * \param value3 Parameter value
  395. */
  396. CALLBACK_PARAMETER_VALUE_CHANGED = 4,
  397. /*!
  398. * A parameter default has changed.
  399. * \param value1 Parameter index
  400. * \param value3 New default value
  401. */
  402. CALLBACK_PARAMETER_DEFAULT_CHANGED = 5,
  403. /*!
  404. * A parameter's MIDI channel has been changed.
  405. * \param value1 Parameter index
  406. * \param value2 MIDI channel
  407. */
  408. CALLBACK_PARAMETER_MIDI_CHANNEL_CHANGED = 6,
  409. /*!
  410. * A parameter's MIDI CC has been changed.
  411. * \param value1 Parameter index
  412. * \param value2 MIDI CC
  413. */
  414. CALLBACK_PARAMETER_MIDI_CC_CHANGED = 7,
  415. /*!
  416. * The current program has has been changed.
  417. * \param value1 Program index
  418. */
  419. CALLBACK_PROGRAM_CHANGED = 8,
  420. /*!
  421. * The current MIDI program has been changed.
  422. * \param value1 MIDI bank
  423. * \param value2 MIDI program
  424. */
  425. CALLBACK_MIDI_PROGRAM_CHANGED = 9,
  426. /*!
  427. * A note has been pressed.
  428. * \param value1 Channel
  429. * \param value2 Note
  430. * \param value3 Velocity
  431. */
  432. CALLBACK_NOTE_ON = 10,
  433. /*!
  434. * A note has been released.
  435. * \param value1 Channel
  436. * \param value2 Note
  437. */
  438. CALLBACK_NOTE_OFF = 11,
  439. /*!
  440. * The plugin's custom GUI state has changed.
  441. * \param value1 State, as follows:\n
  442. * 0: GUI has been closed or hidden\n
  443. * 1: GUI has been shown\n
  444. * -1: GUI has crashed and should not be shown again
  445. */
  446. CALLBACK_SHOW_GUI = 12,
  447. /*!
  448. * The plugin needs update.
  449. */
  450. CALLBACK_UPDATE = 13,
  451. /*!
  452. * The plugin's data/information has changed.
  453. */
  454. CALLBACK_RELOAD_INFO = 14,
  455. /*!
  456. * The plugin's parameters have changed.
  457. */
  458. CALLBACK_RELOAD_PARAMETERS = 15,
  459. /*!
  460. * The plugin's programs have changed.
  461. */
  462. CALLBACK_RELOAD_PROGRAMS = 16,
  463. /*!
  464. * The plugin's state has changed.
  465. */
  466. CALLBACK_RELOAD_ALL = 17,
  467. /*!
  468. * Canvas client added.
  469. * \param value1 Client Id
  470. * \param value2 Client icon
  471. * \param valueStr Client name
  472. */
  473. CALLBACK_PATCHBAY_CLIENT_ADDED = 18,
  474. /*!
  475. * Canvas client removed.
  476. * \param value1 Client Id
  477. * \param valueStr Client name
  478. */
  479. CALLBACK_PATCHBAY_CLIENT_REMOVED = 19,
  480. /*!
  481. * Canvas client renamed.
  482. * \param value1 Client Id
  483. * \param valueStr New client name
  484. */
  485. CALLBACK_PATCHBAY_CLIENT_RENAMED = 20,
  486. /*!
  487. * Canvas port added.
  488. * \param value1 Client Id
  489. * \param value2 Port Id
  490. * \param value3 Port flags
  491. * \param valueStr Port name
  492. */
  493. CALLBACK_PATCHBAY_PORT_ADDED = 21,
  494. /*!
  495. * Canvas port removed.
  496. * \param value1 Client Id
  497. * \param value2 Port Id
  498. * \param valueStr Port name
  499. */
  500. CALLBACK_PATCHBAY_PORT_REMOVED = 22,
  501. /*!
  502. * Canvas port renamed.
  503. * \param value1 Client Id
  504. * \param value2 Port Id
  505. * \param valueStr New port name
  506. */
  507. CALLBACK_PATCHBAY_PORT_RENAMED = 23,
  508. /*!
  509. * Canvas port connection added.
  510. * \param value1 Output port Id
  511. * \param value2 Input port Id
  512. */
  513. CALLBACK_PATCHBAY_CONNECTION_ADDED = 24,
  514. /*!
  515. * Canvas port connection removed.
  516. * \param value1 Output port Id
  517. * \param value2 Input port Id
  518. */
  519. CALLBACK_PATCHBAY_CONNECTION_REMOVED = 25,
  520. /*!
  521. * Canvas client icon changed.
  522. * \param value1 Client Id
  523. * \param value2 New client icon
  524. * \param valueStr Client name
  525. */
  526. CALLBACK_PATCHBAY_ICON_CHANGED = 26,
  527. /*!
  528. * Engine buffer-size changed.
  529. */
  530. CALLBACK_BUFFER_SIZE_CHANGED = 27,
  531. /*!
  532. * Engine sample-rate changed.
  533. */
  534. CALLBACK_SAMPLE_RATE_CHANGED = 28,
  535. /*!
  536. * Engine process mode changed.
  537. * \param value1 New process mode
  538. * \see ProcessMode
  539. */
  540. CALLBACK_PROCESS_MODE_CHANGED = 29,
  541. /*!
  542. * Non-Session-Manager Announce message.
  543. */
  544. CALLBACK_NSM_ANNOUNCE = 30,
  545. /*!
  546. * Non-Session-Manager Open message.
  547. */
  548. CALLBACK_NSM_OPEN = 31,
  549. /*!
  550. * Non-Session-Manager Save message.
  551. */
  552. CALLBACK_NSM_SAVE = 32,
  553. /*!
  554. * An error occurred, show \a valueStr as an error to user.
  555. */
  556. CALLBACK_ERROR = 33,
  557. /*!
  558. * Show \a valueStr as info to user.
  559. */
  560. CALLBACK_INFO = 34,
  561. /*!
  562. * The engine has crashed or malfunctioned and will no longer work.
  563. */
  564. CALLBACK_QUIT = 35
  565. };
  566. /*!
  567. * Engine process mode.
  568. * \see OPTION_PROCESS_MODE
  569. */
  570. enum ProcessMode {
  571. PROCESS_MODE_SINGLE_CLIENT = 0, //!< Single client mode (dynamic input/outputs as needed by plugins).
  572. PROCESS_MODE_MULTIPLE_CLIENTS = 1, //!< Multiple client mode (1 master client + 1 client per plugin).
  573. PROCESS_MODE_CONTINUOUS_RACK = 2, //!< Single client, 'rack' mode. Processes plugins in order of Id, with forced stereo.
  574. PROCESS_MODE_PATCHBAY = 3, //!< Single client, 'patchbay' mode.
  575. PROCESS_MODE_BRIDGE = 4 //!< Special mode, used in plugin-bridges only.
  576. };
  577. /*!
  578. * All the available transport modes
  579. */
  580. enum TransportMode {
  581. TRANSPORT_MODE_INTERNAL = 0, //!< Internal transport mode.
  582. TRANSPORT_MODE_JACK = 1, //!< Transport from JACK, only available if driver name is "JACK".
  583. TRANSPORT_MODE_PLUGIN = 2, //!< Transport from host, used when Carla is a plugin.
  584. TRANSPORT_MODE_BRIDGE = 3 //!< Special mode, used in plugin-bridges only.
  585. };
  586. /*!
  587. * Callback function the engine will use when something interesting happens.
  588. * \see CallbackType
  589. */
  590. typedef void (*CallbackFunc)(void* ptr, CallbackType action, unsigned int pluginId, int value1, int value2, float value3, const char* valueStr);
  591. /*!
  592. * Parameter data.
  593. */
  594. struct ParameterData {
  595. ParameterType type;
  596. int32_t index;
  597. int32_t rindex;
  598. uint32_t hints;
  599. uint8_t midiChannel;
  600. int16_t midiCC;
  601. #ifndef DOXYGEN
  602. ParameterData() noexcept
  603. : type(PARAMETER_UNKNOWN),
  604. index(PARAMETER_NULL),
  605. rindex(-1),
  606. hints(0x0),
  607. midiChannel(0),
  608. midiCC(-1) {}
  609. #endif
  610. };
  611. /*!
  612. * Parameter ranges.
  613. */
  614. struct ParameterRanges {
  615. float def;
  616. float min;
  617. float max;
  618. float step;
  619. float stepSmall;
  620. float stepLarge;
  621. #ifndef DOXYGEN
  622. ParameterRanges() noexcept
  623. : def(0.0f),
  624. min(0.0f),
  625. max(1.0f),
  626. step(0.01f),
  627. stepSmall(0.0001f),
  628. stepLarge(0.1f) {}
  629. #endif
  630. void fixDefault() noexcept
  631. {
  632. fixValue(def);
  633. }
  634. void fixValue(float& value) const noexcept
  635. {
  636. if (value < min)
  637. value = min;
  638. else if (value > max)
  639. value = max;
  640. }
  641. float getFixedValue(const float& value) const noexcept
  642. {
  643. if (value <= min)
  644. return min;
  645. if (value >= max)
  646. return max;
  647. return value;
  648. }
  649. float getNormalizedValue(const float& value) const noexcept
  650. {
  651. const float normValue((value - min) / (max - min));
  652. if (normValue <= 0.0f)
  653. return 0.0f;
  654. if (normValue >= 1.0f)
  655. return 1.0f;
  656. return normValue;
  657. }
  658. float getUnnormalizedValue(const float& value) const noexcept
  659. {
  660. return value * (max - min) + min;
  661. }
  662. };
  663. /*!
  664. * MIDI Program data.
  665. */
  666. struct MidiProgramData {
  667. uint32_t bank;
  668. uint32_t program;
  669. const char* name;
  670. #ifndef DOXYGEN
  671. MidiProgramData() noexcept
  672. : bank(0),
  673. program(0),
  674. name(nullptr) {}
  675. #endif
  676. };
  677. /*!
  678. * Custom data, for saving key:value 'dictionaries'.\n
  679. * \a type is an URI which defines the \a value type.
  680. * \see CustomDataTypes
  681. */
  682. struct CustomData {
  683. const char* type;
  684. const char* key;
  685. const char* value;
  686. #ifndef DOXYGEN
  687. CustomData() noexcept
  688. : type(nullptr),
  689. key(nullptr),
  690. value(nullptr) {}
  691. #endif
  692. };
  693. /**@}*/
  694. // forward declarations of commonly used Carla classes
  695. class CarlaEngine;
  696. class CarlaPlugin;
  697. CARLA_BACKEND_END_NAMESPACE
  698. #endif // CARLA_BACKEND_HPP_INCLUDED