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.

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