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.

563 lines
15KB

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