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.

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