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.

496 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. BINARY_OTHER = 5 //!< Other.
  78. };
  79. /*!
  80. * All the available plugin types, as provided by subclasses of CarlaPlugin.\n
  81. * \note Some plugin classes might provide more than 1 plugin type.
  82. */
  83. enum PluginType {
  84. PLUGIN_NONE = 0, //!< Null plugin type.
  85. PLUGIN_LADSPA = 1, //!< LADSPA plugin.\see LadspaPlugin
  86. PLUGIN_DSSI = 2, //!< DSSI plugin.\see DssiPlugin
  87. PLUGIN_LV2 = 3, //!< LV2 plugin.\see Lv2Plugin
  88. PLUGIN_VST = 4, //!< VST plugin.\see VstPlugin
  89. PLUGIN_GIG = 5, //!< GIG sound kit, implemented via LinuxSampler.\see LinuxSamplerPlugin
  90. PLUGIN_SF2 = 6, //!< SF2 sound kit (aka SoundFont), implemented via FluidSynth.\see FluidSynthPlugin
  91. PLUGIN_SFZ = 7 //!< SFZ sound kit, implemented via LinuxSampler.\see LinuxSamplerPlugin
  92. };
  93. enum PluginCategory {
  94. PLUGIN_CATEGORY_NONE = 0, //!< Null plugin category.
  95. PLUGIN_CATEGORY_SYNTH = 1, //!< A synthesizer or generator.
  96. PLUGIN_CATEGORY_DELAY = 2, //!< A delay or reverberator.
  97. PLUGIN_CATEGORY_EQ = 3, //!< An equalizer.
  98. PLUGIN_CATEGORY_FILTER = 4, //!< A filter.
  99. PLUGIN_CATEGORY_DYNAMICS = 5, //!< A 'dynamic' plugin (amplifier, compressor, gate, etc).
  100. PLUGIN_CATEGORY_MODULATOR = 6, //!< A 'modulator' plugin (chorus, flanger, phaser, etc).
  101. PLUGIN_CATEGORY_UTILITY = 7, //!< An 'utility' plugin (analyzer, converter, mixer, etc).
  102. PLUGIN_CATEGORY_OTHER = 8 //!< Misc plugin (used to check if the plugin has a category).
  103. };
  104. enum ParameterType {
  105. PARAMETER_UNKNOWN = 0,
  106. PARAMETER_INPUT = 1,
  107. PARAMETER_OUTPUT = 2,
  108. PARAMETER_LATENCY = 3,
  109. PARAMETER_SAMPLE_RATE = 4
  110. };
  111. enum InternalParametersIndex {
  112. PARAMETER_NULL = -1,
  113. PARAMETER_ACTIVE = -2,
  114. PARAMETER_DRYWET = -3,
  115. PARAMETER_VOLUME = -4,
  116. PARAMETER_BALANCE_LEFT = -5,
  117. PARAMETER_BALANCE_RIGHT = -6
  118. };
  119. enum CustomDataType {
  120. CUSTOM_DATA_INVALID = 0,
  121. CUSTOM_DATA_STRING = 1,
  122. CUSTOM_DATA_PATH = 2,
  123. CUSTOM_DATA_CHUNK = 3,
  124. CUSTOM_DATA_BINARY = 4
  125. };
  126. enum GuiType {
  127. GUI_NONE = 0,
  128. GUI_INTERNAL_QT4 = 1,
  129. GUI_INTERNAL_COCOA = 2,
  130. GUI_INTERNAL_HWND = 3,
  131. GUI_INTERNAL_X11 = 4,
  132. GUI_EXTERNAL_LV2 = 5,
  133. GUI_EXTERNAL_SUIL = 6,
  134. GUI_EXTERNAL_OSC = 7
  135. };
  136. /*!
  137. * Options used in the setOption() call.\n
  138. * These options must be set before calling CarlaEngine::init() or after CarlaEngine::close().
  139. */
  140. enum OptionsType {
  141. /*!
  142. * Set the engine processing mode.\n
  143. * Default is PROCESS_MODE_MULTIPLE_CLIENTS.
  144. *
  145. * \see ProcessModeType
  146. */
  147. OPTION_PROCESS_MODE = 1,
  148. /*!
  149. * Maximum number of parameters allowed.\n
  150. * Default is MAX_PARAMETERS.
  151. */
  152. OPTION_MAX_PARAMETERS = 2,
  153. /*!
  154. * Use OSC-UI bridges whenever possible, otherwise UIs will be handled in the main thread.\n
  155. * Default is yes.
  156. */
  157. OPTION_PREFER_UI_BRIDGES = 3,
  158. /*!
  159. * Force mono plugins as stereo, by running 2 instances at the same time.\n
  160. * Not supported in VST plugins.
  161. */
  162. OPTION_FORCE_STEREO = 4,
  163. /*!
  164. * High-Precision processing mode.\n
  165. * When enabled, audio will be processed by blocks of 8 samples at a time, indenpendently of the buffer size.\n
  166. * Default is off.\n
  167. * EXPERIMENTAL!
  168. */
  169. OPTION_PROCESS_HIGH_PRECISION = 5,
  170. /*!
  171. * Timeout value in ms for how much to wait for OSC-GUIs to respond.\n
  172. * Default is 4000 ms (4 secs).
  173. */
  174. OPTION_OSC_GUI_TIMEOUT = 6,
  175. /*!
  176. * Use (unofficial) dssi-vst chunks feature.\n
  177. * Default is no.
  178. * EXPERIMENTAL!
  179. */
  180. OPTION_USE_DSSI_CHUNKS = 7,
  181. /*!
  182. * Set LADSPA_PATH environment variable.\n
  183. * Default undefined.
  184. */
  185. OPTION_PATH_LADSPA = 8,
  186. /*!
  187. * Set DSSI_PATH environment variable.\n
  188. * Default undefined.
  189. */
  190. OPTION_PATH_DSSI = 9,
  191. /*!
  192. * Set LV2_PATH environment variable.\n
  193. * Default undefined.
  194. */
  195. OPTION_PATH_LV2 = 10,
  196. /*!
  197. * Set VST_PATH environment variable.\n
  198. * Default undefined.
  199. */
  200. OPTION_PATH_VST = 11,
  201. /*!
  202. * Set GIG_PATH environment variable.\n
  203. * Default undefined.
  204. */
  205. OPTION_PATH_GIG = 12,
  206. /*!
  207. * Set SF2_PATH environment variable.\n
  208. * Default undefined.
  209. */
  210. OPTION_PATH_SF2 = 13,
  211. /*!
  212. * Set SFZ_PATH environment variable.\n
  213. * Default undefined.
  214. */
  215. OPTION_PATH_SFZ = 14,
  216. /*!
  217. * Set path to the Unix 32bit plugin bridge executable.\n
  218. * Default unset.
  219. */
  220. OPTION_PATH_BRIDGE_UNIX32 = 15,
  221. /*!
  222. * Set path to the Unix 64bit plugin bridge executable.\n
  223. * Default unset.
  224. */
  225. OPTION_PATH_BRIDGE_UNIX64 = 16,
  226. /*!
  227. * Set path to the Windows 32bit plugin bridge executable.\n
  228. * Default unset.
  229. */
  230. OPTION_PATH_BRIDGE_WIN32 = 17,
  231. /*!
  232. * Set path to the Windows 64bit plugin bridge executable.\n
  233. * Default unset.
  234. */
  235. OPTION_PATH_BRIDGE_WIN64 = 18,
  236. /*!
  237. * Set path to the LV2 Gtk2 UI bridge executable.\n
  238. * Default unset.
  239. */
  240. OPTION_PATH_BRIDGE_LV2_GTK2 = 19,
  241. /*!
  242. * Set path to the LV2 Qt4 UI bridge executable.\n
  243. * Default unset.
  244. */
  245. OPTION_PATH_BRIDGE_LV2_QT4 = 20,
  246. /*!
  247. * Set path to the LV2 X11 UI bridge executable.\n
  248. * Default unset.
  249. */
  250. OPTION_PATH_BRIDGE_LV2_X11 = 21,
  251. /*!
  252. * Set path to the VST X11 UI bridge executable.\n
  253. * Default unset.
  254. */
  255. OPTION_PATH_BRIDGE_VST_X11 = 22
  256. };
  257. /*!
  258. * Opcodes sent from the engine callback, as defined by CallbackFunc.
  259. *
  260. * \see CarlaEngine::setCallback()
  261. */
  262. enum CallbackType {
  263. /*!
  264. * Debug.\n
  265. * This opcode is undefined and used only for testing purposes.
  266. */
  267. CALLBACK_DEBUG = 0,
  268. /*!
  269. * A parameter has been changed.
  270. *
  271. * \param value1 Parameter index
  272. * \param value3 Value
  273. */
  274. CALLBACK_PARAMETER_VALUE_CHANGED = 1,
  275. /*!
  276. * A parameter's MIDI channel has been changed.
  277. *
  278. * \param value1 Parameter index
  279. * \param value2 MIDI channel
  280. */
  281. CALLBACK_PARAMETER_MIDI_CHANNEL_CHANGED = 2,
  282. /*!
  283. * A parameter's MIDI CC has been changed.
  284. *
  285. * \param value1 Parameter index
  286. * \param value2 MIDI CC
  287. */
  288. CALLBACK_PARAMETER_MIDI_CC_CHANGED = 3,
  289. /*!
  290. * The current program has has been changed.
  291. *
  292. * \param value1 Program index
  293. */
  294. CALLBACK_PROGRAM_CHANGED = 4,
  295. /*!
  296. * The current MIDI program has been changed.
  297. *
  298. * \param value1 MIDI bank
  299. * \param value2 MIDI program
  300. */
  301. CALLBACK_MIDI_PROGRAM_CHANGED = 5,
  302. /*!
  303. * A note has been pressed.
  304. *
  305. * \param value1 Channel
  306. * \param value2 Note
  307. * \param value3 Velocity
  308. */
  309. CALLBACK_NOTE_ON = 6,
  310. /*!
  311. * A note has been released.
  312. *
  313. * \param value1 Channel
  314. * \param value2 Note
  315. */
  316. CALLBACK_NOTE_OFF = 7,
  317. /*!
  318. * The plugin's custom GUI state has changed.
  319. *
  320. * \param value1 State, as follows:.\n
  321. * 0: GUI has been closed or hidden\n
  322. * 1: GUI has been shown\n
  323. * -1: GUI has crashed and should not be shown again\n
  324. */
  325. CALLBACK_SHOW_GUI = 8,
  326. /*!
  327. * The plugin's custom GUI has been resized.
  328. *
  329. * \param value1 Width
  330. * \param value2 Height
  331. */
  332. CALLBACK_RESIZE_GUI = 9,
  333. /*!
  334. * The plugin needs update.
  335. */
  336. CALLBACK_UPDATE = 10,
  337. /*!
  338. * The plugin's data/information has changed.
  339. */
  340. CALLBACK_RELOAD_INFO = 11,
  341. /*!
  342. * The plugin's parameters have changed.
  343. */
  344. CALLBACK_RELOAD_PARAMETERS = 12,
  345. /*!
  346. * The plugin's programs have changed.
  347. */
  348. CALLBACK_RELOAD_PROGRAMS = 13,
  349. /*!
  350. * The plugin's state has changed.
  351. */
  352. CALLBACK_RELOAD_ALL = 14,
  353. /*!
  354. * The engine has crashed or malfunctioned and will no longer work.
  355. */
  356. CALLBACK_QUIT = 15
  357. };
  358. /*!
  359. * Engine process mode, changed using setOption().
  360. *
  361. * \see OPTION_PROCESS_MODE
  362. */
  363. enum ProcessModeType {
  364. PROCESS_MODE_SINGLE_CLIENT = 0, //!< Single client mode (dynamic audio input/outputs as needed by plugins)
  365. PROCESS_MODE_MULTIPLE_CLIENTS = 1, //!< Multiple client mode (1 client per plugin)
  366. PROCESS_MODE_CONTINUOUS_RACK = 2 //!< Single client, "rack" mode. Processes plugins in order of id, with forced stereo.
  367. };
  368. /*!
  369. * Callback function the backend will call when something interesting happens.
  370. *
  371. * \see CarlaEngine::setCallback()
  372. */
  373. typedef void (*CallbackFunc)(CallbackType action, unsigned short pluginId, int value1, int value2, double value3);
  374. struct midi_program_t {
  375. quint32 bank;
  376. quint32 program;
  377. const char* name;
  378. midi_program_t()
  379. : bank(0),
  380. program(0),
  381. name(nullptr) {}
  382. };
  383. struct ParameterData {
  384. ParameterType type;
  385. qint32 index;
  386. qint32 rindex;
  387. qint32 hints;
  388. quint8 midiChannel;
  389. qint16 midiCC;
  390. ParameterData()
  391. : type(PARAMETER_UNKNOWN),
  392. index(-1),
  393. rindex(-1),
  394. hints(0),
  395. midiChannel(0),
  396. midiCC(-1) {}
  397. };
  398. struct ParameterRanges {
  399. double def;
  400. double min;
  401. double max;
  402. double step;
  403. double stepSmall;
  404. double stepLarge;
  405. ParameterRanges()
  406. : def(0.0),
  407. min(0.0),
  408. max(1.0),
  409. step(0.01),
  410. stepSmall(0.0001),
  411. stepLarge(0.1) {}
  412. };
  413. struct CustomData {
  414. CustomDataType type;
  415. const char* key;
  416. const char* value;
  417. CustomData()
  418. : type(CUSTOM_DATA_INVALID),
  419. key(nullptr),
  420. value(nullptr) {}
  421. };
  422. /**@}*/
  423. class CarlaEngine;
  424. class CarlaPlugin;
  425. class CarlaOsc;
  426. CARLA_BACKEND_END_NAMESPACE
  427. #endif // CARLA_BACKEND_H