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.

507 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. * High-Precision processing mode.\n
  151. * When enabled, audio will be processed by blocks of 8 samples at a time, indenpendently of the buffer size.\n
  152. * Default is off.\n
  153. * EXPERIMENTAL!
  154. */
  155. OPTION_PROCESS_HIGH_PRECISION = 2,
  156. /*!
  157. * Maximum number of parameters allowed.\n
  158. * Default is MAX_PARAMETERS.
  159. */
  160. OPTION_MAX_PARAMETERS = 3,
  161. /*!
  162. * Prefered buffer size.
  163. */
  164. OPTION_PREFERRED_BUFFER_SIZE = 4,
  165. /*!
  166. * Prefered sample rate.
  167. */
  168. OPTION_PREFERRED_SAMPLE_RATE = 5,
  169. /*!
  170. * Force mono plugins as stereo, by running 2 instances at the same time.\n
  171. * Not supported in VST plugins.
  172. */
  173. OPTION_FORCE_STEREO = 6,
  174. /*!
  175. * Use (unofficial) dssi-vst chunks feature.\n
  176. * Default is no.
  177. * EXPERIMENTAL!
  178. */
  179. OPTION_USE_DSSI_VST_CHUNKS = 7,
  180. /*!
  181. * Use OSC-UI bridges whenever possible, otherwise UIs will be handled in the main thread.\n
  182. * Default is yes.
  183. */
  184. OPTION_PREFER_UI_BRIDGES = 8,
  185. /*!
  186. * Timeout value in ms for how much to wait for OSC-UIs to respond.\n
  187. * Default is 4000 ms (4 secs).
  188. */
  189. OPTION_OSC_UI_TIMEOUT = 9,
  190. /*!
  191. * Set LADSPA_PATH environment variable.\n
  192. * Default undefined.
  193. */
  194. OPTION_PATH_LADSPA = 10,
  195. /*!
  196. * Set DSSI_PATH environment variable.\n
  197. * Default undefined.
  198. */
  199. OPTION_PATH_DSSI = 11,
  200. /*!
  201. * Set LV2_PATH environment variable.\n
  202. * Default undefined.
  203. */
  204. OPTION_PATH_LV2 = 12,
  205. /*!
  206. * Set VST_PATH environment variable.\n
  207. * Default undefined.
  208. */
  209. OPTION_PATH_VST = 13,
  210. /*!
  211. * Set GIG_PATH environment variable.\n
  212. * Default undefined.
  213. */
  214. OPTION_PATH_GIG = 14,
  215. /*!
  216. * Set SF2_PATH environment variable.\n
  217. * Default undefined.
  218. */
  219. OPTION_PATH_SF2 = 15,
  220. /*!
  221. * Set SFZ_PATH environment variable.\n
  222. * Default undefined.
  223. */
  224. OPTION_PATH_SFZ = 16,
  225. /*!
  226. * Set path to the Unix 32bit plugin bridge executable.\n
  227. * Default unset.
  228. */
  229. OPTION_PATH_BRIDGE_UNIX32 = 17,
  230. /*!
  231. * Set path to the Unix 64bit plugin bridge executable.\n
  232. * Default unset.
  233. */
  234. OPTION_PATH_BRIDGE_UNIX64 = 18,
  235. /*!
  236. * Set path to the Windows 32bit plugin bridge executable.\n
  237. * Default unset.
  238. */
  239. OPTION_PATH_BRIDGE_WIN32 = 19,
  240. /*!
  241. * Set path to the Windows 64bit plugin bridge executable.\n
  242. * Default unset.
  243. */
  244. OPTION_PATH_BRIDGE_WIN64 = 20,
  245. /*!
  246. * Set path to the LV2 Gtk2 UI bridge executable.\n
  247. * Default unset.
  248. */
  249. OPTION_PATH_BRIDGE_LV2_GTK2 = 21,
  250. /*!
  251. * Set path to the LV2 Qt4 UI bridge executable.\n
  252. * Default unset.
  253. */
  254. OPTION_PATH_BRIDGE_LV2_QT4 = 22,
  255. /*!
  256. * Set path to the LV2 X11 UI bridge executable.\n
  257. * Default unset.
  258. */
  259. OPTION_PATH_BRIDGE_LV2_X11 = 23,
  260. /*!
  261. * Set path to the VST X11 UI bridge executable.\n
  262. * Default unset.
  263. */
  264. OPTION_PATH_BRIDGE_VST_X11 = 24
  265. };
  266. /*!
  267. * Opcodes sent from the engine callback, as defined by CallbackFunc.
  268. *
  269. * \see CarlaEngine::setCallback()
  270. */
  271. enum CallbackType {
  272. /*!
  273. * Debug.\n
  274. * This opcode is undefined and used only for testing purposes.
  275. */
  276. CALLBACK_DEBUG = 0,
  277. /*!
  278. * A parameter has been changed.
  279. *
  280. * \param value1 Parameter index
  281. * \param value3 Value
  282. */
  283. CALLBACK_PARAMETER_VALUE_CHANGED = 1,
  284. /*!
  285. * A parameter's MIDI channel has been changed.
  286. *
  287. * \param value1 Parameter index
  288. * \param value2 MIDI channel
  289. */
  290. CALLBACK_PARAMETER_MIDI_CHANNEL_CHANGED = 2,
  291. /*!
  292. * A parameter's MIDI CC has been changed.
  293. *
  294. * \param value1 Parameter index
  295. * \param value2 MIDI CC
  296. */
  297. CALLBACK_PARAMETER_MIDI_CC_CHANGED = 3,
  298. /*!
  299. * The current program has has been changed.
  300. *
  301. * \param value1 Program index
  302. */
  303. CALLBACK_PROGRAM_CHANGED = 4,
  304. /*!
  305. * The current MIDI program has been changed.
  306. *
  307. * \param value1 MIDI bank
  308. * \param value2 MIDI program
  309. */
  310. CALLBACK_MIDI_PROGRAM_CHANGED = 5,
  311. /*!
  312. * A note has been pressed.
  313. *
  314. * \param value1 Channel
  315. * \param value2 Note
  316. * \param value3 Velocity
  317. */
  318. CALLBACK_NOTE_ON = 6,
  319. /*!
  320. * A note has been released.
  321. *
  322. * \param value1 Channel
  323. * \param value2 Note
  324. */
  325. CALLBACK_NOTE_OFF = 7,
  326. /*!
  327. * The plugin's custom GUI state has changed.
  328. *
  329. * \param value1 State, as follows:.\n
  330. * 0: GUI has been closed or hidden\n
  331. * 1: GUI has been shown\n
  332. * -1: GUI has crashed and should not be shown again\n
  333. */
  334. CALLBACK_SHOW_GUI = 8,
  335. /*!
  336. * The plugin's custom GUI has been resized.
  337. *
  338. * \param value1 Width
  339. * \param value2 Height
  340. */
  341. CALLBACK_RESIZE_GUI = 9,
  342. /*!
  343. * The plugin needs update.
  344. */
  345. CALLBACK_UPDATE = 10,
  346. /*!
  347. * The plugin's data/information has changed.
  348. */
  349. CALLBACK_RELOAD_INFO = 11,
  350. /*!
  351. * The plugin's parameters have changed.
  352. */
  353. CALLBACK_RELOAD_PARAMETERS = 12,
  354. /*!
  355. * The plugin's programs have changed.
  356. */
  357. CALLBACK_RELOAD_PROGRAMS = 13,
  358. /*!
  359. * The plugin's state has changed.
  360. */
  361. CALLBACK_RELOAD_ALL = 14,
  362. /*!
  363. * The engine has crashed or malfunctioned and will no longer work.
  364. */
  365. CALLBACK_QUIT = 15
  366. };
  367. /*!
  368. * Engine process mode, changed using setOption().
  369. *
  370. * \see OPTION_PROCESS_MODE
  371. */
  372. enum ProcessModeType {
  373. PROCESS_MODE_SINGLE_CLIENT = 0, //!< Single client mode (dynamic audio input/outputs as needed by plugins)
  374. PROCESS_MODE_MULTIPLE_CLIENTS = 1, //!< Multiple client mode (1 client per plugin)
  375. PROCESS_MODE_CONTINUOUS_RACK = 2 //!< Single client, "rack" mode. Processes plugins in order of id, with forced stereo.
  376. };
  377. /*!
  378. * Callback function the backend will call when something interesting happens.
  379. *
  380. * \see CarlaEngine::setCallback()
  381. */
  382. typedef void (*CallbackFunc)(void* ptr, CallbackType action, unsigned short pluginId, int value1, int value2, double value3);
  383. struct midi_program_t {
  384. quint32 bank;
  385. quint32 program;
  386. const char* name;
  387. midi_program_t()
  388. : bank(0),
  389. program(0),
  390. name(nullptr) {}
  391. };
  392. struct ParameterData {
  393. ParameterType type;
  394. qint32 index;
  395. qint32 rindex;
  396. qint32 hints;
  397. quint8 midiChannel;
  398. qint16 midiCC;
  399. ParameterData()
  400. : type(PARAMETER_UNKNOWN),
  401. index(-1),
  402. rindex(-1),
  403. hints(0),
  404. midiChannel(0),
  405. midiCC(-1) {}
  406. };
  407. struct ParameterRanges {
  408. double def;
  409. double min;
  410. double max;
  411. double step;
  412. double stepSmall;
  413. double stepLarge;
  414. ParameterRanges()
  415. : def(0.0),
  416. min(0.0),
  417. max(1.0),
  418. step(0.01),
  419. stepSmall(0.0001),
  420. stepLarge(0.1) {}
  421. };
  422. struct CustomData {
  423. CustomDataType type;
  424. const char* key;
  425. const char* value;
  426. CustomData()
  427. : type(CUSTOM_DATA_INVALID),
  428. key(nullptr),
  429. value(nullptr) {}
  430. };
  431. /**@}*/
  432. class CarlaEngine;
  433. class CarlaPlugin;
  434. class CarlaOsc;
  435. CARLA_BACKEND_END_NAMESPACE
  436. #endif // CARLA_BACKEND_H