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.

546 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 Channel
  358. * \param value2 Note
  359. * \param value3 Velocity
  360. */
  361. CALLBACK_NOTE_ON = 4,
  362. /*!
  363. * A note has been released.
  364. *
  365. * \param value1 Channel
  366. * \param value2 Note
  367. */
  368. CALLBACK_NOTE_OFF = 5,
  369. /*!
  370. * The plugin's custom GUI state has changed.
  371. *
  372. * \param value1 The new state is as follows:.\n
  373. * 0: GUI has been closed or hidden\n
  374. * 1: GUI has been shown\n
  375. * -1: GUI has crashed and should not be shown again\n
  376. */
  377. CALLBACK_SHOW_GUI = 6,
  378. /*!
  379. * The plugin's custom GUI has been resized.
  380. *
  381. * \param value1 The new width
  382. * \param value2 The new height
  383. */
  384. CALLBACK_RESIZE_GUI = 7,
  385. /*!
  386. * The plugin needs repaint and/or update.
  387. */
  388. CALLBACK_UPDATE = 8,
  389. /*!
  390. * The plugin's data/information has been changed.
  391. */
  392. CALLBACK_RELOAD_INFO = 9,
  393. /*!
  394. * The plugin's parameters have been changed.
  395. */
  396. CALLBACK_RELOAD_PARAMETERS = 10,
  397. /*!
  398. * The plugin's programs have been changed.
  399. */
  400. CALLBACK_RELOAD_PROGRAMS = 11,
  401. /*!
  402. * The plugin's state have been changed.
  403. */
  404. CALLBACK_RELOAD_ALL = 12,
  405. /*!
  406. * The engine has crashed or malfunctioned and will no longer work.
  407. */
  408. CALLBACK_QUIT = 13
  409. };
  410. /*!
  411. * Engine processing mode, changed using set_option().
  412. *
  413. * \see ProcessModeType
  414. */
  415. enum ProcessModeType {
  416. PROCESS_MODE_SINGLE_CLIENT = 0, //!< Single client mode (dynamic input/outputs as needed by plugins)
  417. PROCESS_MODE_MULTIPLE_CLIENTS = 1, //!< Multiple client mode
  418. PROCESS_MODE_CONTINUOUS_RACK = 2 //!< Single client "rack" mode. Processes plugins in order of id, with forced stereo input/output.
  419. };
  420. /*!
  421. * Callback function the backend will call when something interesting happens.
  422. *
  423. * \see CallbackType
  424. * \see CarlaEngine::setCallback()
  425. */
  426. typedef void (*CallbackFunc)(CallbackType action, unsigned short plugin_id, int value1, int value2, double value3);
  427. struct midi_program_t {
  428. uint32_t bank;
  429. uint32_t program;
  430. const char* name;
  431. midi_program_t()
  432. : bank(0),
  433. program(0),
  434. name(nullptr) {}
  435. };
  436. struct ParameterData {
  437. ParameterType type;
  438. qint32 index;
  439. qint32 rindex;
  440. qint32 hints;
  441. quint8 midiChannel;
  442. qint16 midiCC;
  443. ParameterData()
  444. : type(PARAMETER_UNKNOWN),
  445. index(-1),
  446. rindex(-1),
  447. hints(0),
  448. midiChannel(0),
  449. midiCC(-1) {}
  450. };
  451. struct ParameterRanges {
  452. double def;
  453. double min;
  454. double max;
  455. double step;
  456. double stepSmall;
  457. double stepLarge;
  458. ParameterRanges()
  459. : def(0.0),
  460. min(0.0),
  461. max(1.0),
  462. step(0.01),
  463. stepSmall(0.0001),
  464. stepLarge(0.1) {}
  465. };
  466. struct CustomData {
  467. CustomDataType type;
  468. const char* key;
  469. const char* value;
  470. CustomData()
  471. : type(CUSTOM_DATA_INVALID),
  472. key(nullptr),
  473. value(nullptr) {}
  474. };
  475. /**@}*/
  476. class CarlaEngine;
  477. class CarlaPlugin;
  478. CARLA_BACKEND_END_NAMESPACE
  479. #endif // CARLA_BACKEND_H