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.

541 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_POSIX32 = 1, //!< POSIX 32bit.
  75. BINARY_POSIX64 = 2, //!< POSIX 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 POSIX 32bit plugin bridge executable.\n
  229. * Default unset.
  230. */
  231. OPTION_PATH_BRIDGE_POSIX32 = 17,
  232. /*!
  233. * Set path to the POSIX 64bit plugin bridge executable.\n
  234. * Default unset.
  235. */
  236. OPTION_PATH_BRIDGE_POSIX64 = 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 Gtk3 UI bridge executable.\n
  254. * Default unset.
  255. */
  256. OPTION_PATH_BRIDGE_LV2_GTK3 = 22,
  257. /*!
  258. * Set path to the LV2 Qt4 UI bridge executable.\n
  259. * Default unset.
  260. */
  261. OPTION_PATH_BRIDGE_LV2_QT4 = 23,
  262. /*!
  263. * Set path to the LV2 X11 UI bridge executable.\n
  264. * Default unset.
  265. */
  266. OPTION_PATH_BRIDGE_LV2_X11 = 24,
  267. /*!
  268. * Set path to the VST HWND UI bridge executable.\n
  269. * Default unset.
  270. */
  271. OPTION_PATH_BRIDGE_VST_HWND = 25,
  272. /*!
  273. * Set path to the VST X11 UI bridge executable.\n
  274. * Default unset.
  275. */
  276. OPTION_PATH_BRIDGE_VST_X11 = 26
  277. };
  278. /*!
  279. * Opcodes sent from the engine callback, as defined by CallbackFunc.
  280. *
  281. * \see CarlaEngine::setCallback()
  282. */
  283. enum CallbackType {
  284. /*!
  285. * Debug.\n
  286. * This opcode is undefined and used only for testing purposes.
  287. */
  288. CALLBACK_DEBUG = 0,
  289. /*!
  290. * A parameter has been changed.
  291. *
  292. * \param value1 Parameter index
  293. * \param value3 Value
  294. */
  295. CALLBACK_PARAMETER_VALUE_CHANGED = 1,
  296. /*!
  297. * A parameter's MIDI channel has been changed.
  298. *
  299. * \param value1 Parameter index
  300. * \param value2 MIDI channel
  301. */
  302. CALLBACK_PARAMETER_MIDI_CHANNEL_CHANGED = 2,
  303. /*!
  304. * A parameter's MIDI CC has been changed.
  305. *
  306. * \param value1 Parameter index
  307. * \param value2 MIDI CC
  308. */
  309. CALLBACK_PARAMETER_MIDI_CC_CHANGED = 3,
  310. /*!
  311. * The current program has has been changed.
  312. *
  313. * \param value1 Program index
  314. */
  315. CALLBACK_PROGRAM_CHANGED = 4,
  316. /*!
  317. * The current MIDI program has been changed.
  318. *
  319. * \param value1 MIDI bank
  320. * \param value2 MIDI program
  321. */
  322. CALLBACK_MIDI_PROGRAM_CHANGED = 5,
  323. /*!
  324. * A note has been pressed.
  325. *
  326. * \param value1 Channel
  327. * \param value2 Note
  328. * \param value3 Velocity
  329. */
  330. CALLBACK_NOTE_ON = 6,
  331. /*!
  332. * A note has been released.
  333. *
  334. * \param value1 Channel
  335. * \param value2 Note
  336. */
  337. CALLBACK_NOTE_OFF = 7,
  338. /*!
  339. * The plugin's custom GUI state has changed.
  340. *
  341. * \param value1 State, as follows:.\n
  342. * 0: GUI has been closed or hidden\n
  343. * 1: GUI has been shown\n
  344. * -1: GUI has crashed and should not be shown again\n
  345. */
  346. CALLBACK_SHOW_GUI = 8,
  347. /*!
  348. * The plugin's custom GUI has been resized.
  349. *
  350. * \param value1 Width
  351. * \param value2 Height
  352. */
  353. CALLBACK_RESIZE_GUI = 9,
  354. /*!
  355. * The plugin needs update.
  356. */
  357. CALLBACK_UPDATE = 10,
  358. /*!
  359. * The plugin's data/information has changed.
  360. */
  361. CALLBACK_RELOAD_INFO = 11,
  362. /*!
  363. * The plugin's parameters have changed.
  364. */
  365. CALLBACK_RELOAD_PARAMETERS = 12,
  366. /*!
  367. * The plugin's programs have changed.
  368. */
  369. CALLBACK_RELOAD_PROGRAMS = 13,
  370. /*!
  371. * The plugin's state has changed.
  372. */
  373. CALLBACK_RELOAD_ALL = 14,
  374. /*!
  375. * Non-Session-Manager Announce message.
  376. */
  377. CALLBACK_NSM_ANNOUNCE = 15,
  378. /*!
  379. * Non-Session-Manager Open message.
  380. */
  381. CALLBACK_NSM_OPEN1 = 16,
  382. /*!
  383. * Non-Session-Manager Open message.
  384. */
  385. CALLBACK_NSM_OPEN2 = 17,
  386. /*!
  387. * Non-Session-Manager Save message.
  388. */
  389. CALLBACK_NSM_SAVE = 18,
  390. /*!
  391. * The engine has crashed or malfunctioned and will no longer work.
  392. */
  393. CALLBACK_QUIT = 19
  394. };
  395. /*!
  396. * Engine process mode, changed using setOption().
  397. *
  398. * \see OPTION_PROCESS_MODE
  399. */
  400. enum ProcessModeType {
  401. PROCESS_MODE_SINGLE_CLIENT = 0, //!< Single client mode (dynamic audio input/outputs as needed by plugins)
  402. PROCESS_MODE_MULTIPLE_CLIENTS = 1, //!< Multiple client mode (1 client per plugin)
  403. PROCESS_MODE_CONTINUOUS_RACK = 2 //!< Single client, "rack" mode. Processes plugins in order of id, with forced stereo.
  404. };
  405. /*!
  406. * Callback function the backend will call when something interesting happens.
  407. *
  408. * \see CarlaEngine::setCallback()
  409. */
  410. typedef void (*CallbackFunc)(void* ptr, CallbackType action, unsigned short pluginId, int value1, int value2, double value3);
  411. struct midi_program_t {
  412. uint32_t bank;
  413. uint32_t program;
  414. const char* name;
  415. midi_program_t()
  416. : bank(0),
  417. program(0),
  418. name(nullptr) {}
  419. };
  420. struct ParameterData {
  421. ParameterType type;
  422. int32_t index;
  423. int32_t rindex;
  424. int32_t hints;
  425. uint8_t midiChannel;
  426. int16_t midiCC;
  427. ParameterData()
  428. : type(PARAMETER_UNKNOWN),
  429. index(-1),
  430. rindex(-1),
  431. hints(0),
  432. midiChannel(0),
  433. midiCC(-1) {}
  434. };
  435. struct ParameterRanges {
  436. double def;
  437. double min;
  438. double max;
  439. double step;
  440. double stepSmall;
  441. double stepLarge;
  442. ParameterRanges()
  443. : def(0.0),
  444. min(0.0),
  445. max(1.0),
  446. step(0.01),
  447. stepSmall(0.0001),
  448. stepLarge(0.1) {}
  449. };
  450. struct CustomData {
  451. CustomDataType type;
  452. const char* key;
  453. const char* value;
  454. CustomData()
  455. : type(CUSTOM_DATA_INVALID),
  456. key(nullptr),
  457. value(nullptr) {}
  458. };
  459. /**@}*/
  460. class CarlaEngine;
  461. class CarlaPlugin;
  462. class CarlaOsc;
  463. CARLA_BACKEND_END_NAMESPACE
  464. #endif // CARLA_BACKEND_H