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.

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