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.

529 lines
14KB

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