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.

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