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.

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