Collection of tools useful for audio production
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.

493 lines
13KB

  1. /*
  2. * Carla Backend
  3. * Copyright (C) 2011-2012 Filipe Coelho <falktx@gmail.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * 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 COPYING file
  16. */
  17. #ifndef CARLA_BACKEND_H
  18. #define CARLA_BACKEND_H
  19. #include "carla_includes.h"
  20. #define CARLA_BACKEND_START_NAMESPACE namespace CarlaBackend {
  21. #define CARLA_BACKEND_END_NAMESPACE }
  22. CARLA_BACKEND_START_NAMESPACE
  23. #define STR_MAX 0xFF
  24. /*!
  25. * @defgroup CarlaBackendAPI Carla Backend API
  26. *
  27. * The Carla Backend API
  28. *
  29. * @{
  30. */
  31. #ifdef BUILD_BRIDGE
  32. const unsigned short MAX_PLUGINS = 1;
  33. #else
  34. const unsigned short MAX_PLUGINS = 99; //!< Maximum number of loadable plugins
  35. #endif
  36. const unsigned int MAX_PARAMETERS = 200; //!< Default value for the maximum number of parameters allowed.\see OPTION_MAX_PARAMETERS
  37. /*!
  38. * @defgroup PluginHints Plugin Hints
  39. *
  40. * Various plugin hints.
  41. * \see CarlaPlugin::hints()
  42. * @{
  43. */
  44. const unsigned int PLUGIN_IS_BRIDGE = 0x01; //!< Plugin is a bridge (ie, BridgePlugin). This hint is required because "bridge" itself is not a plugin type.
  45. const unsigned int PLUGIN_IS_SYNTH = 0x02; //!< Plugin is a synthesizer (produces sound).
  46. const unsigned int PLUGIN_HAS_GUI = 0x04; //!< Plugin has its own custom GUI.
  47. const unsigned int PLUGIN_USES_CHUNKS = 0x08; //!< Plugin uses chunks to save internal data.\see CarlaPlugin::chunkData()
  48. const unsigned int PLUGIN_CAN_DRYWET = 0x10; //!< Plugin can make use of Dry/Wet controls.
  49. const unsigned int PLUGIN_CAN_VOLUME = 0x20; //!< Plugin can make use of Volume controls.
  50. const unsigned int PLUGIN_CAN_BALANCE = 0x40; //!< Plugin can make use of Left & Right Balance controls.
  51. /**@}*/
  52. /*!
  53. * @defgroup ParameterHints Parameter Hints
  54. *
  55. * Various parameter hints.
  56. * \see CarlaPlugin::parameterData()
  57. * @{
  58. */
  59. const unsigned int PARAMETER_IS_BOOLEAN = 0x01; //!< Parameter value is of boolean type (always at minimum or maximum).
  60. const unsigned int PARAMETER_IS_INTEGER = 0x02; //!< Parameter values are always integer.
  61. const unsigned int PARAMETER_IS_LOGARITHMIC = 0x04; //!< Parameter is logarithmic (informative only, not really implemented).
  62. const unsigned int PARAMETER_IS_ENABLED = 0x08; //!< Parameter is enabled and will be shown in the host built-in editor.
  63. const unsigned int PARAMETER_IS_AUTOMABLE = 0x10; //!< Parameter is automable (realtime safe)
  64. const unsigned int PARAMETER_USES_SAMPLERATE = 0x20; //!< Parameter needs sample rate to work (value and ranges are multiplied by SR, and divided by SR on save).
  65. const unsigned int PARAMETER_USES_SCALEPOINTS = 0x40; //!< Parameter uses scalepoints to define internal values in a meaninful way.
  66. const unsigned int PARAMETER_USES_CUSTOM_TEXT = 0x80; //!< Parameter uses custom text for displaying its value.\see CarlaPlugin::getParameterText()
  67. /**@}*/
  68. /*!
  69. * The binary type of a plugin.
  70. */
  71. enum BinaryType {
  72. BINARY_NONE = 0, //!< Null binary type.
  73. BINARY_UNIX32 = 1, //!< Unix 32bit.
  74. BINARY_UNIX64 = 2, //!< Unix 64bit.
  75. BINARY_WIN32 = 3, //!< Windows 32bit.
  76. BINARY_WIN64 = 4 //!< Windows 64bit.
  77. };
  78. /*!
  79. * All the available plugin types, as provided by subclasses of CarlaPlugin.\n
  80. * \note Some plugin classes might provide more than 1 plugin type.
  81. */
  82. enum PluginType {
  83. PLUGIN_NONE = 0, //!< Null plugin type.
  84. PLUGIN_LADSPA = 1, //!< LADSPA plugin.\see LadspaPlugin
  85. PLUGIN_DSSI = 2, //!< DSSI plugin.\see DssiPlugin
  86. PLUGIN_LV2 = 3, //!< LV2 plugin.\see Lv2Plugin
  87. PLUGIN_VST = 4, //!< VST plugin.\see VstPlugin
  88. PLUGIN_GIG = 5, //!< GIG sound kit, implemented via LinuxSampler.\see LinuxSamplerPlugin
  89. PLUGIN_SF2 = 6, //!< SF2 sound kit (aka SoundFont), implemented via FluidSynth.\see FluidSynthPlugin
  90. PLUGIN_SFZ = 7 //!< SFZ sound kit, implemented via LinuxSampler.\see LinuxSamplerPlugin
  91. };
  92. enum PluginCategory {
  93. PLUGIN_CATEGORY_NONE = 0, //!< Null plugin category.
  94. PLUGIN_CATEGORY_SYNTH = 1, //!< A synthesizer or generator.
  95. PLUGIN_CATEGORY_DELAY = 2, //!< A delay or reverberator.
  96. PLUGIN_CATEGORY_EQ = 3, //!< An equalizer.
  97. PLUGIN_CATEGORY_FILTER = 4, //!< A filter.
  98. PLUGIN_CATEGORY_DYNAMICS = 5, //!< A 'dynamic' plugin (amplifier, compressor, gate, etc).
  99. PLUGIN_CATEGORY_MODULATOR = 6, //!< A 'modulator' plugin (chorus, flanger, phaser, etc).
  100. PLUGIN_CATEGORY_UTILITY = 7, //!< An 'utility' plugin (analyzer, converter, mixer, etc).
  101. PLUGIN_CATEGORY_OTHER = 8 //!< Misc plugin (used to check if the plugin has a category).
  102. };
  103. enum ParameterType {
  104. PARAMETER_UNKNOWN = 0,
  105. PARAMETER_INPUT = 1,
  106. PARAMETER_OUTPUT = 2,
  107. PARAMETER_LATENCY = 3
  108. };
  109. enum InternalParametersIndex {
  110. PARAMETER_ACTIVE = -1,
  111. PARAMETER_DRYWET = -2,
  112. PARAMETER_VOLUME = -3,
  113. PARAMETER_BALANCE_LEFT = -4,
  114. PARAMETER_BALANCE_RIGHT = -5
  115. };
  116. enum CustomDataType {
  117. CUSTOM_DATA_INVALID = 0,
  118. CUSTOM_DATA_STRING = 1,
  119. CUSTOM_DATA_PATH = 2,
  120. CUSTOM_DATA_CHUNK = 3,
  121. CUSTOM_DATA_BINARY = 4
  122. };
  123. enum GuiType {
  124. GUI_NONE = 0,
  125. GUI_INTERNAL_QT4 = 1,
  126. GUI_INTERNAL_COCOA = 2,
  127. GUI_INTERNAL_HWND = 3,
  128. GUI_INTERNAL_X11 = 4,
  129. GUI_EXTERNAL_LV2 = 5,
  130. GUI_EXTERNAL_SUIL = 6,
  131. GUI_EXTERNAL_OSC = 7
  132. };
  133. /*!
  134. * Options used in the setOption() call.\n
  135. * These options must be set before calling CarlaEngine::init() or after CarlaEngine::close().
  136. */
  137. enum OptionsType {
  138. /*!
  139. * Set the engine processing mode.\n
  140. * Default is PROCESS_MODE_MULTIPLE_CLIENTS.
  141. *
  142. * \see ProcessModeType
  143. */
  144. OPTION_PROCESS_MODE = 1,
  145. /*!
  146. * Maximum number of parameters allowed.\n
  147. * Default is MAX_PARAMETERS.
  148. */
  149. OPTION_MAX_PARAMETERS = 2,
  150. /*!
  151. * Use OSC-UI bridges whenever possible, otherwise UIs will be handled in the main thread.\n
  152. * Default is yes.
  153. */
  154. OPTION_PREFER_UI_BRIDGES = 3,
  155. /*!
  156. * Force mono plugins as stereo, by running 2 instances at the same time.\n
  157. * Not supported in VST plugins.
  158. */
  159. OPTION_FORCE_STEREO = 4,
  160. /*!
  161. * High-Precision processing mode.\n
  162. * When enabled, audio will be processed by blocks of 8 samples at a time, indenpendently of the buffer size.\n
  163. * Default is off.\n
  164. * EXPERIMENTAL!
  165. */
  166. OPTION_PROCESS_HIGH_PRECISION = 5,
  167. /*!
  168. * Timeout value in ms for how much to wait for OSC-GUIs to respond.\n
  169. * Default is 4000 ms (4 secs).
  170. */
  171. OPTION_OSC_GUI_TIMEOUT = 6,
  172. /*!
  173. * Use (unofficial) dssi-vst chunks feature.\n
  174. * Default is no.
  175. * EXPERIMENTAL!
  176. */
  177. OPTION_USE_DSSI_CHUNKS = 7,
  178. /*!
  179. * Set LADSPA_PATH environment variable.\n
  180. * Default undefined.
  181. */
  182. OPTION_PATH_LADSPA = 8,
  183. /*!
  184. * Set DSSI_PATH environment variable.\n
  185. * Default undefined.
  186. */
  187. OPTION_PATH_DSSI = 9,
  188. /*!
  189. * Set LV2_PATH environment variable.\n
  190. * Default undefined.
  191. */
  192. OPTION_PATH_LV2 = 10,
  193. /*!
  194. * Set VST_PATH environment variable.\n
  195. * Default undefined.
  196. */
  197. OPTION_PATH_VST = 11,
  198. /*!
  199. * Set GIG_PATH environment variable.\n
  200. * Default undefined.
  201. */
  202. OPTION_PATH_GIG = 12,
  203. /*!
  204. * Set SF2_PATH environment variable.\n
  205. * Default undefined.
  206. */
  207. OPTION_PATH_SF2 = 13,
  208. /*!
  209. * Set SFZ_PATH environment variable.\n
  210. * Default undefined.
  211. */
  212. OPTION_PATH_SFZ = 14,
  213. /*!
  214. * Set path to the Unix 32bit plugin bridge executable.\n
  215. * Default unset.
  216. */
  217. OPTION_PATH_BRIDGE_UNIX32 = 15,
  218. /*!
  219. * Set path to the Unix 64bit plugin bridge executable.\n
  220. * Default unset.
  221. */
  222. OPTION_PATH_BRIDGE_UNIX64 = 16,
  223. /*!
  224. * Set path to the Windows 32bit plugin bridge executable.\n
  225. * Default unset.
  226. */
  227. OPTION_PATH_BRIDGE_WIN32 = 17,
  228. /*!
  229. * Set path to the Windows 64bit plugin bridge executable.\n
  230. * Default unset.
  231. */
  232. OPTION_PATH_BRIDGE_WIN64 = 18,
  233. /*!
  234. * Set path to the LV2 Gtk2 UI bridge executable.\n
  235. * Default unset.
  236. */
  237. OPTION_PATH_BRIDGE_LV2_GTK2 = 19,
  238. /*!
  239. * Set path to the LV2 Qt4 UI bridge executable.\n
  240. * Default unset.
  241. */
  242. OPTION_PATH_BRIDGE_LV2_QT4 = 20,
  243. /*!
  244. * Set path to the LV2 X11 UI bridge executable.\n
  245. * Default unset.
  246. */
  247. OPTION_PATH_BRIDGE_LV2_X11 = 21,
  248. /*!
  249. * Set path to the VST X11 UI bridge executable.\n
  250. * Default unset.
  251. */
  252. OPTION_PATH_BRIDGE_VST_X11 = 22
  253. };
  254. /*!
  255. * Opcodes sent from the engine callback, as defined by CallbackFunc.
  256. *
  257. * \see CarlaEngine::setCallback()
  258. */
  259. enum CallbackType {
  260. /*!
  261. * Debug.\n
  262. * This opcode is undefined and used only for testing purposes.
  263. */
  264. CALLBACK_DEBUG = 0,
  265. /*!
  266. * A parameter has been changed.
  267. *
  268. * \param value1 Parameter index
  269. * \param value3 Value
  270. */
  271. CALLBACK_PARAMETER_VALUE_CHANGED = 1,
  272. /*!
  273. * A parameter's MIDI channel has been changed.
  274. *
  275. * \param value1 Parameter index
  276. * \param value2 MIDI channel
  277. */
  278. CALLBACK_PARAMETER_MIDI_CHANNEL_CHANGED = 2,
  279. /*!
  280. * A parameter's MIDI CC has been changed.
  281. *
  282. * \param value1 Parameter index
  283. * \param value2 MIDI CC
  284. */
  285. CALLBACK_PARAMETER_MIDI_CC_CHANGED = 3,
  286. /*!
  287. * The current program has has been changed.
  288. *
  289. * \param value1 Program index
  290. */
  291. CALLBACK_PROGRAM_CHANGED = 4,
  292. /*!
  293. * The current MIDI program has been changed.
  294. *
  295. * \param value1 MIDI bank
  296. * \param value2 MIDI program
  297. */
  298. CALLBACK_MIDI_PROGRAM_CHANGED = 5,
  299. /*!
  300. * A note has been pressed.
  301. *
  302. * \param value1 Channel
  303. * \param value2 Note
  304. * \param value3 Velocity
  305. */
  306. CALLBACK_NOTE_ON = 6,
  307. /*!
  308. * A note has been released.
  309. *
  310. * \param value1 Channel
  311. * \param value2 Note
  312. */
  313. CALLBACK_NOTE_OFF = 7,
  314. /*!
  315. * The plugin's custom GUI state has changed.
  316. *
  317. * \param value1 State, as follows:.\n
  318. * 0: GUI has been closed or hidden\n
  319. * 1: GUI has been shown\n
  320. * -1: GUI has crashed and should not be shown again\n
  321. */
  322. CALLBACK_SHOW_GUI = 8,
  323. /*!
  324. * The plugin's custom GUI has been resized.
  325. *
  326. * \param value1 Width
  327. * \param value2 Height
  328. */
  329. CALLBACK_RESIZE_GUI = 9,
  330. /*!
  331. * The plugin needs update.
  332. */
  333. CALLBACK_UPDATE = 10,
  334. /*!
  335. * The plugin's data/information has changed.
  336. */
  337. CALLBACK_RELOAD_INFO = 11,
  338. /*!
  339. * The plugin's parameters have changed.
  340. */
  341. CALLBACK_RELOAD_PARAMETERS = 12,
  342. /*!
  343. * The plugin's programs have changed.
  344. */
  345. CALLBACK_RELOAD_PROGRAMS = 13,
  346. /*!
  347. * The plugin's state has changed.
  348. */
  349. CALLBACK_RELOAD_ALL = 14,
  350. /*!
  351. * The engine has crashed or malfunctioned and will no longer work.
  352. */
  353. CALLBACK_QUIT = 15
  354. };
  355. /*!
  356. * Engine process mode, changed using setOption().
  357. *
  358. * \see OPTION_PROCESS_MODE
  359. */
  360. enum ProcessModeType {
  361. PROCESS_MODE_SINGLE_CLIENT = 0, //!< Single client mode (dynamic audio input/outputs as needed by plugins)
  362. PROCESS_MODE_MULTIPLE_CLIENTS = 1, //!< Multiple client mode (1 client per plugin)
  363. PROCESS_MODE_CONTINUOUS_RACK = 2 //!< Single client, "rack" mode. Processes plugins in order of id, with forced stereo.
  364. };
  365. /*!
  366. * Callback function the backend will call when something interesting happens.
  367. *
  368. * \see CarlaEngine::setCallback()
  369. */
  370. typedef void (*CallbackFunc)(CallbackType action, unsigned short pluginId, int value1, int value2, double value3);
  371. struct midi_program_t {
  372. quint32 bank;
  373. quint32 program;
  374. const char* name;
  375. midi_program_t()
  376. : bank(0),
  377. program(0),
  378. name(nullptr) {}
  379. };
  380. struct ParameterData {
  381. ParameterType type;
  382. qint32 index;
  383. qint32 rindex;
  384. qint32 hints;
  385. quint8 midiChannel;
  386. qint16 midiCC;
  387. ParameterData()
  388. : type(PARAMETER_UNKNOWN),
  389. index(-1),
  390. rindex(-1),
  391. hints(0),
  392. midiChannel(0),
  393. midiCC(-1) {}
  394. };
  395. struct ParameterRanges {
  396. double def;
  397. double min;
  398. double max;
  399. double step;
  400. double stepSmall;
  401. double stepLarge;
  402. ParameterRanges()
  403. : def(0.0),
  404. min(0.0),
  405. max(1.0),
  406. step(0.01),
  407. stepSmall(0.0001),
  408. stepLarge(0.1) {}
  409. };
  410. struct CustomData {
  411. CustomDataType type;
  412. const char* key;
  413. const char* value;
  414. CustomData()
  415. : type(CUSTOM_DATA_INVALID),
  416. key(nullptr),
  417. value(nullptr) {}
  418. };
  419. /**@}*/
  420. class CarlaEngine;
  421. class CarlaPlugin;
  422. class CarlaOsc;
  423. CARLA_BACKEND_END_NAMESPACE
  424. #endif // CARLA_BACKEND_H