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.

544 lines
15KB

  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. #ifdef BUILD_BRIDGE
  31. const unsigned short MAX_PLUGINS = 1;
  32. #else
  33. const unsigned short MAX_PLUGINS = 99; //!< Maximum number of loadable plugins
  34. #endif
  35. const unsigned int MAX_PARAMETERS = 200; //!< Default value for maximum number of parameters the callback can handle.\see OPTION_MAX_PARAMETERS
  36. /*!
  37. * @defgroup PluginHints Plugin Hints
  38. *
  39. * Various plugin hints.
  40. * \see CarlaPlugin::hints
  41. * @{
  42. */
  43. 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.
  44. const unsigned int PLUGIN_IS_SYNTH = 0x02; //!< Plugin is a synthesizer (produces sound).
  45. const unsigned int PLUGIN_HAS_GUI = 0x04; //!< Plugin has its own custom GUI.
  46. const unsigned int PLUGIN_USES_CHUNKS = 0x08; //!< Plugin uses chunks to save internal data.\see CarlaPlugin::chunkData()
  47. const unsigned int PLUGIN_CAN_DRYWET = 0x10; //!< Plugin can make use of Dry/Wet controls.
  48. const unsigned int PLUGIN_CAN_VOLUME = 0x20; //!< Plugin can make use of Volume controls.
  49. const unsigned int PLUGIN_CAN_BALANCE = 0x40; //!< Plugin can make use of Left & Right Balance controls.
  50. /**@}*/
  51. /*!
  52. * @defgroup ParameterHints Parameter Hints
  53. *
  54. * Various parameter hints.
  55. * \see CarlaPlugin::paramData()
  56. * @{
  57. */
  58. const unsigned int PARAMETER_IS_BOOLEAN = 0x01; //!< Parameter value is of boolean type (always at minimum or maximum).
  59. const unsigned int PARAMETER_IS_INTEGER = 0x02; //!< Parameter values are always integer.
  60. const unsigned int PARAMETER_IS_LOGARITHMIC = 0x04; //!< Parameter is logarithmic (informative only, not really implemented).
  61. const unsigned int PARAMETER_IS_ENABLED = 0x08; //!< Parameter is enabled and will be shown in the host built-in editor.
  62. const unsigned int PARAMETER_IS_AUTOMABLE = 0x10; //!< Parameter is automable (realtime safe)
  63. 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).
  64. const unsigned int PARAMETER_USES_SCALEPOINTS = 0x40; //!< Parameter uses scalepoints to define internal values in a meaninful way.
  65. const unsigned int PARAMETER_USES_CUSTOM_TEXT = 0x80; //!< Parameter uses custom text for displaying its value.\see CarlaPlugin::getParameterText()
  66. /**@}*/
  67. /*!
  68. * The binary type of a plugin.
  69. * \see BridgePlugin
  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, 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, provided by LinuxSampler.\see LinuxSamplerPlugin
  89. PLUGIN_SF2 = 6, //!< SF2 sound kit (aka SoundFont), provided by FluidSynth.\see FluidSynthPlugin
  90. PLUGIN_SFZ = 7 //!< SFZ sound kit, provided by LinuxSampler.\see LinuxSamplerPlugin
  91. };
  92. enum PluginCategory {
  93. PLUGIN_CATEGORY_NONE = 0, //!< Unknown or undefined 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 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 set_option().\n
  135. * These options must be set before calling CarlaEngine::init() or after CarlaEngine::close().
  136. *
  137. * \see set_option()
  138. */
  139. enum OptionsType {
  140. /*!
  141. * Set the engine processing mode.\n
  142. * Default is PROCESS_MODE_MULTIPLE_CLIENTS.
  143. *
  144. * \param value A value from ProcessModeType
  145. * \param valueStr Unused
  146. * \see ProcessModeType
  147. */
  148. OPTION_PROCESS_MODE = 1,
  149. /*!
  150. * Maximum number of parameters the callback can handle.\n
  151. * Default is MAX_PARAMETERS.
  152. *
  153. * \param value The new value
  154. * \param valueStr Unused
  155. */
  156. OPTION_MAX_PARAMETERS = 2,
  157. /*!
  158. * Wherever to use OSC-UI bridges when possible, otherwise UIs will be handled in the main thread.\n
  159. * Default is yes.
  160. *
  161. * \param value Boolean for yes/no
  162. * \param valueStr Unused
  163. */
  164. OPTION_PREFER_UI_BRIDGES = 3,
  165. /*!
  166. * Force mono plugins as stereo, by running instances at the same time.\n
  167. * Supported in LADSPA, DSSI and LV2 plugin types.
  168. *
  169. * \param value Boolean for yes/no
  170. * \param valueStr Unused
  171. */
  172. OPTION_FORCE_STEREO = 4,
  173. /*!
  174. * High-Precision processing mode.\n
  175. * When enabled, audio will be processed by blocks 8 samples at a time, no matter what the real buffer size is.\n
  176. * Default is no (EXPERIMENTAL!).
  177. *
  178. * \param value Boolean for yes/no
  179. * \param valueStr Unused
  180. */
  181. OPTION_PROCESS_HIGH_PRECISION = 5,
  182. /*!
  183. * Timeout value for how many miliseconds to wait for OSC-GUIs to respond.\n
  184. * Default is 4000 ms (4 secs).
  185. *
  186. * \param value The new value
  187. * \param valueStr Unused
  188. */
  189. OPTION_OSC_GUI_TIMEOUT = 6,
  190. /*!
  191. * Wherever to use unofficial dssi-vst chunks feature.\n
  192. * Default is no. (EXPERIMENTAL!).
  193. *
  194. * \param value Boolean for yes/no
  195. * \param valueStr Unused
  196. */
  197. OPTION_USE_DSSI_CHUNKS = 7,
  198. /*!
  199. * Set LADSPA_PATH environment variable.\n
  200. * Default undefined.
  201. *
  202. * \param value Unused
  203. * \param valueStr The new path, separated by ":" on Unix or ";" on Windows
  204. */
  205. OPTION_PATH_LADSPA = 8,
  206. /*!
  207. * Set DSSI_PATH environment variable.\n
  208. * Default undefined.
  209. *
  210. * \param value Unused
  211. * \param valueStr The new path, separated by ":" on Unix or ";" on Windows
  212. */
  213. OPTION_PATH_DSSI = 9,
  214. /*!
  215. * Set LV2_PATH environment variable.\n
  216. * Default undefined.
  217. *
  218. * \param value Unused
  219. * \param valueStr The new path, separated by ":" on Unix or ";" on Windows
  220. */
  221. OPTION_PATH_LV2 = 10,
  222. /*!
  223. * Set VST_PATH environment variable.\n
  224. * Default undefined.
  225. *
  226. * \param value Unused
  227. * \param valueStr The new path, separated by ":" on Unix or ";" on Windows
  228. */
  229. OPTION_PATH_VST = 11,
  230. /*!
  231. * Set GIG_PATH environment variable.\n
  232. * Default undefined.
  233. *
  234. * \param value Unused
  235. * \param valueStr The new path, separated by ":" on Unix or ";" on Windows
  236. */
  237. OPTION_PATH_GIG = 12,
  238. /*!
  239. * Set SF2_PATH environment variable.\n
  240. * Default undefined.
  241. *
  242. * \param value Unused
  243. * \param valueStr The new path, separated by ":" on Unix or ";" on Windows
  244. */
  245. OPTION_PATH_SF2 = 13,
  246. /*!
  247. * Set SFZ_PATH environment variable.\n
  248. * Default undefined.
  249. *
  250. * \param value Unused
  251. * \param valueStr The new path, separated by ":" on Unix or ";" on Windows
  252. */
  253. OPTION_PATH_SFZ = 14,
  254. /*!
  255. * Set path to the Unix 32bit plugin bridge.\n
  256. * Default unset.
  257. *
  258. * \param value Unused
  259. * \param valueStr The new path
  260. */
  261. OPTION_PATH_BRIDGE_UNIX32 = 15,
  262. /*!
  263. * Set path to the Unix 64bit plugin bridge.\n
  264. * Default unset.
  265. *
  266. * \param value Unused
  267. * \param valueStr The new path
  268. */
  269. OPTION_PATH_BRIDGE_UNIX64 = 16,
  270. /*!
  271. * Set path to the Windows 32bit plugin bridge.\n
  272. * Default unset.
  273. *
  274. * \param value Unused
  275. * \param valueStr The new path
  276. */
  277. OPTION_PATH_BRIDGE_WIN32 = 17,
  278. /*!
  279. * Set path to the Windows 64bit plugin bridge.\n
  280. * Default unset.
  281. *
  282. * \param value Unused
  283. * \param valueStr The new path
  284. */
  285. OPTION_PATH_BRIDGE_WIN64 = 18,
  286. /*!
  287. * Set path to the LV2 Gtk2 UI bridge.\n
  288. * Default unset.
  289. *
  290. * \param value Unused
  291. * \param valueStr The new path
  292. */
  293. OPTION_PATH_BRIDGE_LV2_GTK2 = 19,
  294. /*!
  295. * Set path to the LV2 Qt4 UI bridge.\n
  296. * Default unset.
  297. *
  298. * \param value Unused
  299. * \param valueStr The new path
  300. */
  301. OPTION_PATH_BRIDGE_LV2_QT4 = 20,
  302. /*!
  303. * Set path to the LV2 X11 UI bridge.\n
  304. * Default unset.
  305. *
  306. * \param value Unused
  307. * \param valueStr The new path
  308. */
  309. OPTION_PATH_BRIDGE_LV2_X11 = 21,
  310. /*!
  311. * Set path to the VST X11 UI bridge.\n
  312. * Default unset.
  313. *
  314. * \param value Unused
  315. * \param valueStr The new path
  316. */
  317. OPTION_PATH_BRIDGE_VST_X11 = 22
  318. };
  319. /*!
  320. * Opcodes sent to the callback, defined by CallbackFunc.
  321. *
  322. * \see CarlaEngine::setCallback()
  323. */
  324. enum CallbackType {
  325. /*!
  326. * Debug.\n
  327. * This opcode is undefined and used only for testing purposes.
  328. *
  329. * \param value1 Undefined
  330. * \param value2 Undefined
  331. * \param value3 Undefined
  332. */
  333. CALLBACK_DEBUG = 0,
  334. /*!
  335. * A parameter has been changed.
  336. *
  337. * \param value1 The parameter Id
  338. * \param value3 The new value
  339. */
  340. CALLBACK_PARAMETER_CHANGED = 1,
  341. /*!
  342. * The current program has has been changed.
  343. *
  344. * \param value1 The new program index
  345. */
  346. CALLBACK_PROGRAM_CHANGED = 2,
  347. /*!
  348. * The current MIDI program has been changed.
  349. *
  350. * \param value1 The new MIDI program's bank
  351. * \param value2 The new MIDI program's program
  352. */
  353. CALLBACK_MIDI_PROGRAM_CHANGED = 3,
  354. /*!
  355. * A note has been pressed.
  356. *
  357. * \param value1 The note
  358. * \param value2 Velocity of the note
  359. */
  360. CALLBACK_NOTE_ON = 4,
  361. /*!
  362. * A note has been released.
  363. *
  364. * \param value1 The note
  365. */
  366. CALLBACK_NOTE_OFF = 5,
  367. /*!
  368. * The plugin's custom GUI state has changed.
  369. *
  370. * \param value1 The new state is as follows:.\n
  371. * 0: GUI has been closed or hidden\n
  372. * 1: GUI has been shown\n
  373. * -1: GUI has crashed and should not be shown again\n
  374. */
  375. CALLBACK_SHOW_GUI = 6,
  376. /*!
  377. * The plugin's custom GUI has been resized.
  378. *
  379. * \param value1 The new width
  380. * \param value2 The new height
  381. */
  382. CALLBACK_RESIZE_GUI = 7,
  383. /*!
  384. * The plugin needs repaint and/or update.
  385. */
  386. CALLBACK_UPDATE = 8,
  387. /*!
  388. * The plugin's data/information has been changed.
  389. */
  390. CALLBACK_RELOAD_INFO = 9,
  391. /*!
  392. * The plugin's parameters have been changed.
  393. */
  394. CALLBACK_RELOAD_PARAMETERS = 10,
  395. /*!
  396. * The plugin's programs have been changed.
  397. */
  398. CALLBACK_RELOAD_PROGRAMS = 11,
  399. /*!
  400. * The plugin's state have been changed.
  401. */
  402. CALLBACK_RELOAD_ALL = 12,
  403. /*!
  404. * The engine has crashed or malfunctioned and will no longer work.
  405. */
  406. CALLBACK_QUIT = 13
  407. };
  408. /*!
  409. * Engine processing mode, changed using set_option().
  410. *
  411. * \see ProcessModeType
  412. */
  413. enum ProcessModeType {
  414. PROCESS_MODE_SINGLE_CLIENT = 0, //!< Single client mode (dynamic input/outputs as needed by plugins)
  415. PROCESS_MODE_MULTIPLE_CLIENTS = 1, //!< Multiple client mode
  416. PROCESS_MODE_CONTINUOUS_RACK = 2 //!< Single client "rack" mode. Processes plugins in order of id, with forced stereo input/output.
  417. };
  418. /*!
  419. * Callback function the backend will call when something interesting happens.
  420. *
  421. * \see CallbackType
  422. * \see CarlaEngine::setCallback()
  423. */
  424. typedef void (*CallbackFunc)(CallbackType action, unsigned short plugin_id, int value1, int value2, double value3);
  425. struct midi_program_t {
  426. uint32_t bank;
  427. uint32_t program;
  428. const char* name;
  429. midi_program_t()
  430. : bank(0),
  431. program(0),
  432. name(nullptr) {}
  433. };
  434. struct ParameterData {
  435. ParameterType type;
  436. qint32 index;
  437. qint32 rindex;
  438. qint32 hints;
  439. quint8 midiChannel;
  440. qint16 midiCC;
  441. ParameterData()
  442. : type(PARAMETER_UNKNOWN),
  443. index(-1),
  444. rindex(-1),
  445. hints(0),
  446. midiChannel(0),
  447. midiCC(-1) {}
  448. };
  449. struct ParameterRanges {
  450. double def;
  451. double min;
  452. double max;
  453. double step;
  454. double stepSmall;
  455. double stepLarge;
  456. ParameterRanges()
  457. : def(0.0),
  458. min(0.0),
  459. max(1.0),
  460. step(0.01),
  461. stepSmall(0.0001),
  462. stepLarge(0.1) {}
  463. };
  464. struct CustomData {
  465. CustomDataType type;
  466. const char* key;
  467. const char* value;
  468. CustomData()
  469. : type(CUSTOM_DATA_INVALID),
  470. key(nullptr),
  471. value(nullptr) {}
  472. };
  473. /**@}*/
  474. class CarlaEngine;
  475. class CarlaPlugin;
  476. CARLA_BACKEND_END_NAMESPACE
  477. #endif // CARLA_BACKEND_H