Audio plugin host https://kx.studio/carla
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.

CarlaBackendUtils.hpp 24KB

11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779
  1. /*
  2. * Carla Backend utils
  3. * Copyright (C) 2011-2021 Filipe Coelho <falktx@falktx.com>
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License as
  7. * published by the Free Software Foundation; either version 2 of
  8. * the License, or 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 doc/GPL.txt file.
  16. */
  17. #ifndef CARLA_BACKEND_UTILS_HPP_INCLUDED
  18. #define CARLA_BACKEND_UTILS_HPP_INCLUDED
  19. #include "CarlaBackend.h"
  20. #include "CarlaString.hpp"
  21. CARLA_BACKEND_START_NAMESPACE
  22. // -----------------------------------------------------------------------
  23. static inline
  24. const char* PluginOption2Str(const uint option) noexcept
  25. {
  26. switch (option)
  27. {
  28. case PLUGIN_OPTION_FIXED_BUFFERS:
  29. return "PLUGIN_OPTION_FIXED_BUFFERS";
  30. case PLUGIN_OPTION_FORCE_STEREO:
  31. return "PLUGIN_OPTION_FORCE_STEREO";
  32. case PLUGIN_OPTION_MAP_PROGRAM_CHANGES:
  33. return "PLUGIN_OPTION_MAP_PROGRAM_CHANGES";
  34. case PLUGIN_OPTION_USE_CHUNKS:
  35. return "PLUGIN_OPTION_USE_CHUNKS";
  36. case PLUGIN_OPTION_SEND_CONTROL_CHANGES:
  37. return "PLUGIN_OPTION_SEND_CONTROL_CHANGES";
  38. case PLUGIN_OPTION_SEND_CHANNEL_PRESSURE:
  39. return "PLUGIN_OPTION_SEND_CHANNEL_PRESSURE";
  40. case PLUGIN_OPTION_SEND_NOTE_AFTERTOUCH:
  41. return "PLUGIN_OPTION_SEND_NOTE_AFTERTOUCH";
  42. case PLUGIN_OPTION_SEND_PITCHBEND:
  43. return "PLUGIN_OPTION_SEND_PITCHBEND";
  44. case PLUGIN_OPTION_SEND_ALL_SOUND_OFF:
  45. return "PLUGIN_OPTION_SEND_ALL_SOUND_OFF";
  46. }
  47. carla_stderr("CarlaBackend::PluginOption2Str(%i) - invalid option", option);
  48. return nullptr;
  49. }
  50. // -----------------------------------------------------------------------
  51. static inline
  52. const char* BinaryType2Str(const BinaryType type) noexcept
  53. {
  54. switch (type)
  55. {
  56. case BINARY_NONE:
  57. return "BINARY_NONE";
  58. case BINARY_POSIX32:
  59. return "BINARY_POSIX32";
  60. case BINARY_POSIX64:
  61. return "BINARY_POSIX64";
  62. case BINARY_WIN32:
  63. return "BINARY_WIN32";
  64. case BINARY_WIN64:
  65. return "BINARY_WIN64";
  66. case BINARY_OTHER:
  67. return "BINARY_OTHER";
  68. }
  69. carla_stderr("CarlaBackend::BinaryType2Str(%i) - invalid type", type);
  70. return nullptr;
  71. }
  72. static inline
  73. const char* FileType2Str(const FileType type) noexcept
  74. {
  75. switch (type)
  76. {
  77. case FILE_NONE:
  78. return "FILE_NONE";
  79. case FILE_AUDIO:
  80. return "FILE_AUDIO";
  81. case FILE_MIDI:
  82. return "FILE_MIDI";
  83. }
  84. carla_stderr("CarlaBackend::FileType2Str(%i) - invalid type", type);
  85. return nullptr;
  86. }
  87. static inline
  88. const char* PluginType2Str(const PluginType type) noexcept
  89. {
  90. switch (type)
  91. {
  92. case PLUGIN_NONE:
  93. return "PLUGIN_NONE";
  94. case PLUGIN_INTERNAL:
  95. return "PLUGIN_INTERNAL";
  96. case PLUGIN_LADSPA:
  97. return "PLUGIN_LADSPA";
  98. case PLUGIN_DSSI:
  99. return "PLUGIN_DSSI";
  100. case PLUGIN_LV2:
  101. return "PLUGIN_LV2";
  102. case PLUGIN_VST2:
  103. return "PLUGIN_VST2";
  104. case PLUGIN_VST3:
  105. return "PLUGIN_VST3";
  106. case PLUGIN_AU:
  107. return "PLUGIN_AU";
  108. case PLUGIN_DLS:
  109. return "PLUGIN_DLS";
  110. case PLUGIN_GIG:
  111. return "PLUGIN_GIG";
  112. case PLUGIN_SF2:
  113. return "PLUGIN_SF2";
  114. case PLUGIN_SFZ:
  115. return "PLUGIN_SFZ";
  116. case PLUGIN_JACK:
  117. return "PLUGIN_JACK";
  118. case PLUGIN_JSFX:
  119. return "PLUGIN_JSFX";
  120. case PLUGIN_CLAP:
  121. return "PLUGIN_CLAP";
  122. }
  123. carla_stderr("CarlaBackend::PluginType2Str(%i) - invalid type", type);
  124. return nullptr;
  125. }
  126. static inline
  127. const char* PluginCategory2Str(const PluginCategory category) noexcept
  128. {
  129. switch (category)
  130. {
  131. case PLUGIN_CATEGORY_NONE:
  132. return "PLUGIN_CATEGORY_NONE";
  133. case PLUGIN_CATEGORY_SYNTH:
  134. return "PLUGIN_CATEGORY_SYNTH";
  135. case PLUGIN_CATEGORY_DELAY:
  136. return "PLUGIN_CATEGORY_DELAY";
  137. case PLUGIN_CATEGORY_EQ:
  138. return "PLUGIN_CATEGORY_EQ";
  139. case PLUGIN_CATEGORY_FILTER:
  140. return "PLUGIN_CATEGORY_FILTER";
  141. case PLUGIN_CATEGORY_DISTORTION:
  142. return "PLUGIN_CATEGORY_DISTORTION";
  143. case PLUGIN_CATEGORY_DYNAMICS:
  144. return "PLUGIN_CATEGORY_DYNAMICS";
  145. case PLUGIN_CATEGORY_MODULATOR:
  146. return "PLUGIN_CATEGORY_MODULATOR";
  147. case PLUGIN_CATEGORY_UTILITY:
  148. return "PLUGIN_CATEGORY_UTILITY";
  149. case PLUGIN_CATEGORY_OTHER:
  150. return "PLUGIN_CATEGORY_OTHER";
  151. }
  152. carla_stderr("CarlaBackend::PluginCategory2Str(%i) - invalid category", category);
  153. return nullptr;
  154. }
  155. static inline
  156. const char* ParameterType2Str(const ParameterType type) noexcept
  157. {
  158. switch (type)
  159. {
  160. case PARAMETER_UNKNOWN:
  161. return "PARAMETER_UNKNOWN";
  162. case PARAMETER_INPUT:
  163. return "PARAMETER_INPUT";
  164. case PARAMETER_OUTPUT:
  165. return "PARAMETER_OUTPUT";
  166. }
  167. carla_stderr("CarlaBackend::ParameterType2Str(%i) - invalid type", type);
  168. return nullptr;
  169. }
  170. static inline
  171. const char* InternalParameterIndex2Str(const InternalParameterIndex index) noexcept
  172. {
  173. switch (index)
  174. {
  175. case PARAMETER_NULL:
  176. return "PARAMETER_NULL";
  177. #ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
  178. case PARAMETER_ACTIVE:
  179. return "PARAMETER_ACTIVE";
  180. case PARAMETER_DRYWET:
  181. return "PARAMETER_DRYWET";
  182. case PARAMETER_VOLUME:
  183. return "PARAMETER_VOLUME";
  184. case PARAMETER_BALANCE_LEFT:
  185. return "PARAMETER_BALANCE_LEFT";
  186. case PARAMETER_BALANCE_RIGHT:
  187. return "PARAMETER_BALANCE_RIGHT";
  188. case PARAMETER_PANNING:
  189. return "PARAMETER_PANNING";
  190. case PARAMETER_CTRL_CHANNEL:
  191. return "PARAMETER_CTRL_CHANNEL";
  192. #endif
  193. case PARAMETER_MAX:
  194. return "PARAMETER_MAX";
  195. }
  196. carla_stderr("CarlaBackend::InternalParameterIndex2Str(%i) - invalid index", index);
  197. return nullptr;
  198. }
  199. static inline
  200. const char* EngineCallbackOpcode2Str(const EngineCallbackOpcode opcode) noexcept
  201. {
  202. switch (opcode)
  203. {
  204. case ENGINE_CALLBACK_DEBUG:
  205. return "ENGINE_CALLBACK_DEBUG";
  206. case ENGINE_CALLBACK_PLUGIN_ADDED:
  207. return "ENGINE_CALLBACK_PLUGIN_ADDED";
  208. case ENGINE_CALLBACK_PLUGIN_REMOVED:
  209. return "ENGINE_CALLBACK_PLUGIN_REMOVED";
  210. case ENGINE_CALLBACK_PLUGIN_RENAMED:
  211. return "ENGINE_CALLBACK_PLUGIN_RENAMED";
  212. case ENGINE_CALLBACK_PLUGIN_UNAVAILABLE:
  213. return "ENGINE_CALLBACK_PLUGIN_UNAVAILABLE";
  214. case ENGINE_CALLBACK_PARAMETER_VALUE_CHANGED:
  215. return "ENGINE_CALLBACK_PARAMETER_VALUE_CHANGED";
  216. case ENGINE_CALLBACK_PARAMETER_DEFAULT_CHANGED:
  217. return "ENGINE_CALLBACK_PARAMETER_DEFAULT_CHANGED";
  218. #ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
  219. case ENGINE_CALLBACK_PARAMETER_MAPPED_CONTROL_INDEX_CHANGED:
  220. return "ENGINE_CALLBACK_PARAMETER_MAPPED_CONTROL_INDEX_CHANGED";
  221. case ENGINE_CALLBACK_PARAMETER_MIDI_CHANNEL_CHANGED:
  222. return "ENGINE_CALLBACK_PARAMETER_MIDI_CHANNEL_CHANGED";
  223. case ENGINE_CALLBACK_OPTION_CHANGED:
  224. return "ENGINE_CALLBACK_OPTION_CHANGED";
  225. #endif
  226. case ENGINE_CALLBACK_PROGRAM_CHANGED:
  227. return "ENGINE_CALLBACK_PROGRAM_CHANGED";
  228. case ENGINE_CALLBACK_MIDI_PROGRAM_CHANGED:
  229. return "ENGINE_CALLBACK_MIDI_PROGRAM_CHANGED";
  230. case ENGINE_CALLBACK_UI_STATE_CHANGED:
  231. return "ENGINE_CALLBACK_UI_STATE_CHANGED";
  232. case ENGINE_CALLBACK_NOTE_ON:
  233. return "ENGINE_CALLBACK_NOTE_ON";
  234. case ENGINE_CALLBACK_NOTE_OFF:
  235. return "ENGINE_CALLBACK_NOTE_OFF";
  236. case ENGINE_CALLBACK_UPDATE:
  237. return "ENGINE_CALLBACK_UPDATE";
  238. case ENGINE_CALLBACK_RELOAD_INFO:
  239. return "ENGINE_CALLBACK_RELOAD_INFO";
  240. case ENGINE_CALLBACK_RELOAD_PARAMETERS:
  241. return "ENGINE_CALLBACK_RELOAD_PARAMETERS";
  242. case ENGINE_CALLBACK_RELOAD_PROGRAMS:
  243. return "ENGINE_CALLBACK_RELOAD_PROGRAMS";
  244. case ENGINE_CALLBACK_RELOAD_ALL:
  245. return "ENGINE_CALLBACK_RELOAD_ALL";
  246. #ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
  247. case ENGINE_CALLBACK_PATCHBAY_CLIENT_ADDED:
  248. return "ENGINE_CALLBACK_PATCHBAY_CLIENT_ADDED";
  249. case ENGINE_CALLBACK_PATCHBAY_CLIENT_REMOVED:
  250. return "ENGINE_CALLBACK_PATCHBAY_CLIENT_REMOVED";
  251. case ENGINE_CALLBACK_PATCHBAY_CLIENT_RENAMED:
  252. return "ENGINE_CALLBACK_PATCHBAY_CLIENT_RENAMED";
  253. case ENGINE_CALLBACK_PATCHBAY_CLIENT_DATA_CHANGED:
  254. return "ENGINE_CALLBACK_PATCHBAY_CLIENT_DATA_CHANGED";
  255. case ENGINE_CALLBACK_PATCHBAY_PORT_ADDED:
  256. return "ENGINE_CALLBACK_PATCHBAY_PORT_ADDED";
  257. case ENGINE_CALLBACK_PATCHBAY_PORT_REMOVED:
  258. return "ENGINE_CALLBACK_PATCHBAY_PORT_REMOVED";
  259. case ENGINE_CALLBACK_PATCHBAY_PORT_CHANGED:
  260. return "ENGINE_CALLBACK_PATCHBAY_PORT_CHANGED";
  261. case ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED:
  262. return "ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED";
  263. case ENGINE_CALLBACK_PATCHBAY_CONNECTION_REMOVED:
  264. return "ENGINE_CALLBACK_PATCHBAY_CONNECTION_REMOVED";
  265. #endif
  266. case ENGINE_CALLBACK_ENGINE_STARTED:
  267. return "ENGINE_CALLBACK_ENGINE_STARTED";
  268. case ENGINE_CALLBACK_ENGINE_STOPPED:
  269. return "ENGINE_CALLBACK_ENGINE_STOPPED";
  270. case ENGINE_CALLBACK_PROCESS_MODE_CHANGED:
  271. return "ENGINE_CALLBACK_PROCESS_MODE_CHANGED";
  272. case ENGINE_CALLBACK_TRANSPORT_MODE_CHANGED:
  273. return "ENGINE_CALLBACK_TRANSPORT_MODE_CHANGED";
  274. case ENGINE_CALLBACK_BUFFER_SIZE_CHANGED:
  275. return "ENGINE_CALLBACK_BUFFER_SIZE_CHANGED";
  276. case ENGINE_CALLBACK_SAMPLE_RATE_CHANGED:
  277. return "ENGINE_CALLBACK_SAMPLE_RATE_CHANGED";
  278. case ENGINE_CALLBACK_CANCELABLE_ACTION:
  279. return "ENGINE_CALLBACK_CANCELABLE_ACTION";
  280. case ENGINE_CALLBACK_PROJECT_LOAD_FINISHED:
  281. return "ENGINE_CALLBACK_PROJECT_LOAD_FINISHED";
  282. case ENGINE_CALLBACK_NSM:
  283. return "ENGINE_CALLBACK_NSM";
  284. case ENGINE_CALLBACK_IDLE:
  285. return "ENGINE_CALLBACK_IDLE";
  286. case ENGINE_CALLBACK_INFO:
  287. return "ENGINE_CALLBACK_INFO";
  288. case ENGINE_CALLBACK_ERROR:
  289. return "ENGINE_CALLBACK_ERROR";
  290. case ENGINE_CALLBACK_QUIT:
  291. return "ENGINE_CALLBACK_QUIT";
  292. case ENGINE_CALLBACK_INLINE_DISPLAY_REDRAW:
  293. return "ENGINE_CALLBACK_INLINE_DISPLAY_REDRAW";
  294. case ENGINE_CALLBACK_PATCHBAY_PORT_GROUP_ADDED:
  295. return "ENGINE_CALLBACK_PATCHBAY_PORT_GROUP_ADDED";
  296. case ENGINE_CALLBACK_PATCHBAY_PORT_GROUP_REMOVED:
  297. return "ENGINE_CALLBACK_PATCHBAY_PORT_GROUP_REMOVED";
  298. case ENGINE_CALLBACK_PATCHBAY_PORT_GROUP_CHANGED:
  299. return "ENGINE_CALLBACK_PATCHBAY_PORT_GROUP_CHANGED";
  300. case ENGINE_CALLBACK_PARAMETER_MAPPED_RANGE_CHANGED:
  301. return "ENGINE_CALLBACK_PARAMETER_MAPPED_RANGE_CHANGED";
  302. case ENGINE_CALLBACK_PATCHBAY_CLIENT_POSITION_CHANGED:
  303. return "ENGINE_CALLBACK_PATCHBAY_CLIENT_POSITION_CHANGED";
  304. case ENGINE_CALLBACK_EMBED_UI_RESIZED:
  305. return "ENGINE_CALLBACK_EMBED_UI_RESIZED";
  306. }
  307. carla_stderr("CarlaBackend::EngineCallbackOpcode2Str(%i) - invalid opcode", opcode);
  308. return nullptr;
  309. }
  310. static inline
  311. const char* EngineOption2Str(const EngineOption option) noexcept
  312. {
  313. switch (option)
  314. {
  315. case ENGINE_OPTION_DEBUG:
  316. return "ENGINE_OPTION_DEBUG";
  317. case ENGINE_OPTION_PROCESS_MODE:
  318. return "ENGINE_OPTION_PROCESS_MODE";
  319. case ENGINE_OPTION_TRANSPORT_MODE:
  320. return "ENGINE_OPTION_TRANSPORT_MODE";
  321. case ENGINE_OPTION_FORCE_STEREO:
  322. return "ENGINE_OPTION_FORCE_STEREO";
  323. case ENGINE_OPTION_PREFER_PLUGIN_BRIDGES:
  324. return "ENGINE_OPTION_PREFER_PLUGIN_BRIDGES";
  325. case ENGINE_OPTION_PREFER_UI_BRIDGES:
  326. return "ENGINE_OPTION_PREFER_UI_BRIDGES";
  327. case ENGINE_OPTION_UIS_ALWAYS_ON_TOP:
  328. return "ENGINE_OPTION_UIS_ALWAYS_ON_TOP";
  329. case ENGINE_OPTION_MAX_PARAMETERS:
  330. return "ENGINE_OPTION_MAX_PARAMETERS";
  331. case ENGINE_OPTION_RESET_XRUNS:
  332. return "ENGINE_OPTION_RESET_XRUNS";
  333. case ENGINE_OPTION_UI_BRIDGES_TIMEOUT:
  334. return "ENGINE_OPTION_UI_BRIDGES_TIMEOUT";
  335. case ENGINE_OPTION_AUDIO_BUFFER_SIZE:
  336. return "ENGINE_OPTION_AUDIO_BUFFER_SIZE";
  337. case ENGINE_OPTION_AUDIO_SAMPLE_RATE:
  338. return "ENGINE_OPTION_AUDIO_SAMPLE_RATE";
  339. case ENGINE_OPTION_AUDIO_TRIPLE_BUFFER:
  340. return "ENGINE_OPTION_AUDIO_TRIPLE_BUFFER";
  341. case ENGINE_OPTION_AUDIO_DRIVER:
  342. return "ENGINE_OPTION_AUDIO_DRIVER";
  343. case ENGINE_OPTION_AUDIO_DEVICE:
  344. return "ENGINE_OPTION_AUDIO_DEVICE";
  345. #ifndef BUILD_BRIDGE
  346. case ENGINE_OPTION_OSC_ENABLED:
  347. return "ENGINE_OPTION_OSC_ENABLED";
  348. case ENGINE_OPTION_OSC_PORT_UDP:
  349. return "ENGINE_OPTION_OSC_PORT_UDP";
  350. case ENGINE_OPTION_OSC_PORT_TCP:
  351. return "ENGINE_OPTION_OSC_PORT_TCP";
  352. #endif
  353. case ENGINE_OPTION_FILE_PATH:
  354. return "ENGINE_OPTION_FILE_PATH";
  355. case ENGINE_OPTION_PLUGIN_PATH:
  356. return "ENGINE_OPTION_PLUGIN_PATH";
  357. case ENGINE_OPTION_PATH_BINARIES:
  358. return "ENGINE_OPTION_PATH_BINARIES";
  359. case ENGINE_OPTION_PATH_RESOURCES:
  360. return "ENGINE_OPTION_PATH_RESOURCES";
  361. case ENGINE_OPTION_PREVENT_BAD_BEHAVIOUR:
  362. return "ENGINE_OPTION_PREVENT_BAD_BEHAVIOUR";
  363. case ENGINE_OPTION_FRONTEND_BACKGROUND_COLOR:
  364. return "ENGINE_OPTION_FRONTEND_BACKGROUND_COLOR";
  365. case ENGINE_OPTION_FRONTEND_FOREGROUND_COLOR:
  366. return "ENGINE_OPTION_FRONTEND_FOREGROUND_COLOR";
  367. case ENGINE_OPTION_FRONTEND_UI_SCALE:
  368. return "ENGINE_OPTION_FRONTEND_UI_SCALE";
  369. case ENGINE_OPTION_FRONTEND_WIN_ID:
  370. return "ENGINE_OPTION_FRONTEND_WIN_ID";
  371. #if !defined(BUILD_BRIDGE_ALTERNATIVE_ARCH) && !defined(CARLA_OS_WIN)
  372. case ENGINE_OPTION_WINE_EXECUTABLE:
  373. return "ENGINE_OPTION_WINE_EXECUTABLE";
  374. case ENGINE_OPTION_WINE_AUTO_PREFIX:
  375. return "ENGINE_OPTION_WINE_AUTO_PREFIX";
  376. case ENGINE_OPTION_WINE_FALLBACK_PREFIX:
  377. return "ENGINE_OPTION_WINE_FALLBACK_PREFIX";
  378. case ENGINE_OPTION_WINE_RT_PRIO_ENABLED:
  379. return "ENGINE_OPTION_WINE_RT_PRIO_ENABLED";
  380. case ENGINE_OPTION_WINE_BASE_RT_PRIO:
  381. return "ENGINE_OPTION_WINE_BASE_RT_PRIO";
  382. case ENGINE_OPTION_WINE_SERVER_RT_PRIO:
  383. return "ENGINE_OPTION_WINE_SERVER_RT_PRIO";
  384. #endif
  385. #ifndef BUILD_BRIDGE
  386. case ENGINE_OPTION_DEBUG_CONSOLE_OUTPUT:
  387. return "ENGINE_OPTION_DEBUG_CONSOLE_OUTPUT";
  388. #endif
  389. case ENGINE_OPTION_CLIENT_NAME_PREFIX:
  390. return "ENGINE_OPTION_CLIENT_NAME_PREFIX";
  391. case ENGINE_OPTION_PLUGINS_ARE_STANDALONE:
  392. return "ENGINE_OPTION_PLUGINS_ARE_STANDALONE";
  393. }
  394. carla_stderr("CarlaBackend::EngineOption2Str(%i) - invalid option", option);
  395. return nullptr;
  396. }
  397. static inline
  398. const char* EngineProcessMode2Str(const EngineProcessMode mode) noexcept
  399. {
  400. switch (mode)
  401. {
  402. case ENGINE_PROCESS_MODE_SINGLE_CLIENT:
  403. return "ENGINE_PROCESS_MODE_SINGLE_CLIENT";
  404. case ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS:
  405. return "ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS";
  406. case ENGINE_PROCESS_MODE_CONTINUOUS_RACK:
  407. return "ENGINE_PROCESS_MODE_CONTINUOUS_RACK";
  408. case ENGINE_PROCESS_MODE_PATCHBAY:
  409. return "ENGINE_PROCESS_MODE_PATCHBAY";
  410. case ENGINE_PROCESS_MODE_BRIDGE:
  411. return "ENGINE_PROCESS_MODE_BRIDGE";
  412. }
  413. carla_stderr("CarlaBackend::EngineProcessMode2Str(%i) - invalid mode", mode);
  414. return nullptr;
  415. }
  416. static inline
  417. const char* EngineTransportMode2Str(const EngineTransportMode mode) noexcept
  418. {
  419. switch (mode)
  420. {
  421. case ENGINE_TRANSPORT_MODE_DISABLED:
  422. return "ENGINE_TRANSPORT_MODE_DISABLED";
  423. case ENGINE_TRANSPORT_MODE_INTERNAL:
  424. return "ENGINE_TRANSPORT_MODE_INTERNAL";
  425. case ENGINE_TRANSPORT_MODE_JACK:
  426. return "ENGINE_TRANSPORT_MODE_JACK";
  427. case ENGINE_TRANSPORT_MODE_PLUGIN:
  428. return "ENGINE_TRANSPORT_MODE_PLUGIN";
  429. case ENGINE_TRANSPORT_MODE_BRIDGE:
  430. return "ENGINE_TRANSPORT_MODE_BRIDGE";
  431. }
  432. carla_stderr("CarlaBackend::EngineTransportMode2Str(%i) - invalid mode", mode);
  433. return nullptr;
  434. }
  435. static inline
  436. const char* FileCallbackOpcode2Str(const FileCallbackOpcode opcode) noexcept
  437. {
  438. switch (opcode)
  439. {
  440. case FILE_CALLBACK_DEBUG:
  441. return "FILE_CALLBACK_DEBUG";
  442. case FILE_CALLBACK_OPEN:
  443. return "FILE_CALLBACK_OPEN";
  444. case FILE_CALLBACK_SAVE:
  445. return "FILE_CALLBACK_SAVE";
  446. }
  447. carla_stderr("CarlaBackend::FileCallbackOpcode2Str(%i) - invalid opcode", opcode);
  448. return nullptr;
  449. }
  450. static inline
  451. const char* PatchbayIcon2Str(const PatchbayIcon icon) noexcept
  452. {
  453. switch (icon)
  454. {
  455. case PATCHBAY_ICON_APPLICATION:
  456. return "PATCHBAY_ICON_APPLICATION";
  457. case PATCHBAY_ICON_PLUGIN:
  458. return "PATCHBAY_ICON_PLUGIN";
  459. case PATCHBAY_ICON_HARDWARE:
  460. return "PATCHBAY_ICON_HARDWARE";
  461. case PATCHBAY_ICON_CARLA:
  462. return "PATCHBAY_ICON_CARLA";
  463. case PATCHBAY_ICON_DISTRHO:
  464. return "PATCHBAY_ICON_DISTRHO";
  465. case PATCHBAY_ICON_FILE:
  466. return "PATCHBAY_ICON_FILE";
  467. }
  468. carla_stderr("CarlaBackend::PatchbayIcon2Str(%i) - invalid icon", icon);
  469. return nullptr;
  470. }
  471. // -----------------------------------------------------------------------
  472. static inline
  473. BinaryType getBinaryTypeFromString(const char* const ctype) noexcept
  474. {
  475. CARLA_SAFE_ASSERT_RETURN(ctype != nullptr && ctype[0] != '\0', BINARY_NONE);
  476. carla_debug("CarlaBackend::getBinaryTypeFromString(\"%s\")", ctype);
  477. CarlaString stype(ctype);
  478. if (stype.isEmpty())
  479. return BINARY_NONE;
  480. stype.toLower();
  481. if (stype == "none")
  482. return BINARY_NONE;
  483. if (stype == "native")
  484. return BINARY_NATIVE;
  485. if (stype == "posix32" || stype == "linux32" || stype == "mac32")
  486. return BINARY_POSIX32;
  487. if (stype == "posix64" || stype == "linux64" || stype == "mac64")
  488. return BINARY_POSIX64;
  489. if (stype == "win32")
  490. return BINARY_WIN32;
  491. if (stype == "win64")
  492. return BINARY_WIN64;
  493. carla_stderr("CarlaBackend::getBinaryTypeFromString(\"%s\") - invalid string type", ctype);
  494. return BINARY_NONE;
  495. }
  496. // -----------------------------------------------------------------------
  497. static inline
  498. const char* getPluginCategoryAsString(const PluginCategory category) noexcept
  499. {
  500. carla_debug("CarlaBackend::getPluginCategoryAsString(%i:%s)", category, PluginCategory2Str(category));
  501. switch (category)
  502. {
  503. case PLUGIN_CATEGORY_NONE:
  504. return "none";
  505. case PLUGIN_CATEGORY_SYNTH:
  506. return "synth";
  507. case PLUGIN_CATEGORY_DELAY:
  508. return "delay";
  509. case PLUGIN_CATEGORY_EQ:
  510. return "eq";
  511. case PLUGIN_CATEGORY_FILTER:
  512. return "filter";
  513. case PLUGIN_CATEGORY_DISTORTION:
  514. return "distortion";
  515. case PLUGIN_CATEGORY_DYNAMICS:
  516. return "dynamics";
  517. case PLUGIN_CATEGORY_MODULATOR:
  518. return "modulator";
  519. case PLUGIN_CATEGORY_UTILITY:
  520. return "utility";
  521. case PLUGIN_CATEGORY_OTHER:
  522. return "other";
  523. }
  524. carla_stderr("CarlaBackend::getPluginCategoryAsString(%i) - invalid category", category);
  525. return "NONE";
  526. }
  527. static inline
  528. const char* getPluginTypeAsString(const PluginType type) noexcept
  529. {
  530. carla_debug("CarlaBackend::getPluginTypeAsString(%i:%s)", type, PluginType2Str(type));
  531. switch (type)
  532. {
  533. case PLUGIN_NONE:
  534. return "NONE";
  535. case PLUGIN_INTERNAL:
  536. return "INTERNAL";
  537. case PLUGIN_LADSPA:
  538. return "LADSPA";
  539. case PLUGIN_DSSI:
  540. return "DSSI";
  541. case PLUGIN_LV2:
  542. return "LV2";
  543. case PLUGIN_VST2:
  544. return "VST2";
  545. case PLUGIN_VST3:
  546. return "VST3";
  547. case PLUGIN_AU:
  548. return "AU";
  549. case PLUGIN_DLS:
  550. return "DLS";
  551. case PLUGIN_GIG:
  552. return "GIG";
  553. case PLUGIN_SF2:
  554. return "SF2";
  555. case PLUGIN_SFZ:
  556. return "SFZ";
  557. case PLUGIN_JACK:
  558. return "JACK";
  559. case PLUGIN_JSFX:
  560. return "JSFX";
  561. case PLUGIN_CLAP:
  562. return "CLAP";
  563. }
  564. carla_stderr("CarlaBackend::getPluginTypeAsString(%i) - invalid type", type);
  565. return "NONE";
  566. }
  567. static inline
  568. PluginType getPluginTypeFromString(const char* const ctype) noexcept
  569. {
  570. CARLA_SAFE_ASSERT_RETURN(ctype != nullptr && ctype[0] != '\0', PLUGIN_NONE);
  571. carla_debug("CarlaBackend::getPluginTypeFromString(\"%s\")", ctype);
  572. CarlaString stype(ctype);
  573. if (stype.isEmpty())
  574. return PLUGIN_NONE;
  575. stype.toLower();
  576. if (stype == "none")
  577. return PLUGIN_NONE;
  578. if (stype == "internal" || stype == "native")
  579. return PLUGIN_INTERNAL;
  580. if (stype == "ladspa")
  581. return PLUGIN_LADSPA;
  582. if (stype == "dssi")
  583. return PLUGIN_DSSI;
  584. if (stype == "lv2")
  585. return PLUGIN_LV2;
  586. if (stype == "vst2" || stype == "vst")
  587. return PLUGIN_VST2;
  588. if (stype == "vst3")
  589. return PLUGIN_VST3;
  590. if (stype == "au" || stype == "audiounit")
  591. return PLUGIN_AU;
  592. if (stype == "dls")
  593. return PLUGIN_DLS;
  594. if (stype == "gig")
  595. return PLUGIN_GIG;
  596. if (stype == "sf2" || stype == "sf3")
  597. return PLUGIN_SF2;
  598. if (stype == "sfz")
  599. return PLUGIN_SFZ;
  600. if (stype == "jack")
  601. return PLUGIN_JACK;
  602. if (stype == "jsfx")
  603. return PLUGIN_JSFX;
  604. if (stype == "clap")
  605. return PLUGIN_CLAP;
  606. carla_stderr("CarlaBackend::getPluginTypeFromString(\"%s\") - invalid string type", ctype);
  607. return PLUGIN_NONE;
  608. }
  609. // -----------------------------------------------------------------------
  610. static inline
  611. PluginCategory getPluginCategoryFromName(const char* const name) noexcept
  612. {
  613. CARLA_SAFE_ASSERT_RETURN(name != nullptr && name[0] != '\0', PLUGIN_CATEGORY_NONE);
  614. carla_debug("CarlaBackend::getPluginCategoryFromName(\"%s\")", name);
  615. CarlaString sname(name);
  616. if (sname.isEmpty())
  617. return PLUGIN_CATEGORY_NONE;
  618. sname.toLower();
  619. // generic tags first
  620. if (sname.contains("delay"))
  621. return PLUGIN_CATEGORY_DELAY;
  622. if (sname.contains("reverb"))
  623. return PLUGIN_CATEGORY_DELAY;
  624. // filter
  625. if (sname.contains("filter"))
  626. return PLUGIN_CATEGORY_FILTER;
  627. // distortion
  628. if (sname.contains("distortion"))
  629. return PLUGIN_CATEGORY_DISTORTION;
  630. // dynamics
  631. if (sname.contains("dynamics"))
  632. return PLUGIN_CATEGORY_DYNAMICS;
  633. if (sname.contains("amplifier"))
  634. return PLUGIN_CATEGORY_DYNAMICS;
  635. if (sname.contains("compressor"))
  636. return PLUGIN_CATEGORY_DYNAMICS;
  637. if (sname.contains("enhancer"))
  638. return PLUGIN_CATEGORY_DYNAMICS;
  639. if (sname.contains("exciter"))
  640. return PLUGIN_CATEGORY_DYNAMICS;
  641. if (sname.contains("gate"))
  642. return PLUGIN_CATEGORY_DYNAMICS;
  643. if (sname.contains("limiter"))
  644. return PLUGIN_CATEGORY_DYNAMICS;
  645. // modulator
  646. if (sname.contains("modulator"))
  647. return PLUGIN_CATEGORY_MODULATOR;
  648. if (sname.contains("chorus"))
  649. return PLUGIN_CATEGORY_MODULATOR;
  650. if (sname.contains("flanger"))
  651. return PLUGIN_CATEGORY_MODULATOR;
  652. if (sname.contains("phaser"))
  653. return PLUGIN_CATEGORY_MODULATOR;
  654. if (sname.contains("saturator"))
  655. return PLUGIN_CATEGORY_MODULATOR;
  656. // utility
  657. if (sname.contains("utility"))
  658. return PLUGIN_CATEGORY_UTILITY;
  659. if (sname.contains("analyzer"))
  660. return PLUGIN_CATEGORY_UTILITY;
  661. if (sname.contains("converter"))
  662. return PLUGIN_CATEGORY_UTILITY;
  663. if (sname.contains("deesser"))
  664. return PLUGIN_CATEGORY_UTILITY;
  665. if (sname.contains("mixer"))
  666. return PLUGIN_CATEGORY_UTILITY;
  667. // common tags
  668. if (sname.contains("verb"))
  669. return PLUGIN_CATEGORY_DELAY;
  670. if (sname.contains("eq"))
  671. return PLUGIN_CATEGORY_EQ;
  672. if (sname.contains("tool"))
  673. return PLUGIN_CATEGORY_UTILITY;
  674. // synth
  675. if (sname.contains("synth"))
  676. return PLUGIN_CATEGORY_SYNTH;
  677. // other
  678. if (sname.contains("misc"))
  679. return PLUGIN_CATEGORY_OTHER;
  680. if (sname.contains("other"))
  681. return PLUGIN_CATEGORY_OTHER;
  682. return PLUGIN_CATEGORY_NONE;
  683. }
  684. // -----------------------------------------------------------------------
  685. static inline
  686. bool isPluginOptionEnabled(const uint options, const uint option)
  687. {
  688. if (options == PLUGIN_OPTIONS_NULL)
  689. return true;
  690. if (options & option)
  691. return true;
  692. return false;
  693. }
  694. static inline
  695. bool isPluginOptionInverseEnabled(const uint options, const uint option)
  696. {
  697. if (options == PLUGIN_OPTIONS_NULL)
  698. return false;
  699. if (options & option)
  700. return true;
  701. return false;
  702. }
  703. // -----------------------------------------------------------------------
  704. CARLA_BACKEND_END_NAMESPACE
  705. #endif // CARLA_BACKEND_UTILS_HPP_INCLUDED