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.

550 lines
14KB

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