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.

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