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 19KB

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
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619
  1. /*
  2. * Carla Backend utils
  3. * Copyright (C) 2011-2018 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* PluginType2Str(const PluginType type) noexcept
  74. {
  75. switch (type)
  76. {
  77. case PLUGIN_NONE:
  78. return "PLUGIN_NONE";
  79. case PLUGIN_INTERNAL:
  80. return "PLUGIN_INTERNAL";
  81. case PLUGIN_LADSPA:
  82. return "PLUGIN_LADSPA";
  83. case PLUGIN_DSSI:
  84. return "PLUGIN_DSSI";
  85. case PLUGIN_LV2:
  86. return "PLUGIN_LV2";
  87. case PLUGIN_VST2:
  88. return "PLUGIN_VST2";
  89. case PLUGIN_SF2:
  90. return "PLUGIN_SF2";
  91. case PLUGIN_SFZ:
  92. return "PLUGIN_SFZ";
  93. case PLUGIN_JACK:
  94. return "PLUGIN_JACK";
  95. }
  96. carla_stderr("CarlaBackend::PluginType2Str(%i) - invalid type", type);
  97. return nullptr;
  98. }
  99. static inline
  100. const char* PluginCategory2Str(const PluginCategory category) noexcept
  101. {
  102. switch (category)
  103. {
  104. case PLUGIN_CATEGORY_NONE:
  105. return "PLUGIN_CATEGORY_NONE";
  106. case PLUGIN_CATEGORY_SYNTH:
  107. return "PLUGIN_CATEGORY_SYNTH";
  108. case PLUGIN_CATEGORY_DELAY:
  109. return "PLUGIN_CATEGORY_DELAY";
  110. case PLUGIN_CATEGORY_EQ:
  111. return "PLUGIN_CATEGORY_EQ";
  112. case PLUGIN_CATEGORY_FILTER:
  113. return "PLUGIN_CATEGORY_FILTER";
  114. case PLUGIN_CATEGORY_DISTORTION:
  115. return "PLUGIN_CATEGORY_DISTORTION";
  116. case PLUGIN_CATEGORY_DYNAMICS:
  117. return "PLUGIN_CATEGORY_DYNAMICS";
  118. case PLUGIN_CATEGORY_MODULATOR:
  119. return "PLUGIN_CATEGORY_MODULATOR";
  120. case PLUGIN_CATEGORY_UTILITY:
  121. return "PLUGIN_CATEGORY_UTILITY";
  122. case PLUGIN_CATEGORY_OTHER:
  123. return "PLUGIN_CATEGORY_OTHER";
  124. }
  125. carla_stderr("CarlaBackend::PluginCategory2Str(%i) - invalid category", category);
  126. return nullptr;
  127. }
  128. static inline
  129. const char* ParameterType2Str(const ParameterType type) noexcept
  130. {
  131. switch (type)
  132. {
  133. case PARAMETER_UNKNOWN:
  134. return "PARAMETER_UNKNOWN";
  135. case PARAMETER_INPUT:
  136. return "PARAMETER_INPUT";
  137. case PARAMETER_OUTPUT:
  138. return "PARAMETER_OUTPUT";
  139. }
  140. carla_stderr("CarlaBackend::ParameterType2Str(%i) - invalid type", type);
  141. return nullptr;
  142. }
  143. static inline
  144. const char* InternalParameterIndex2Str(const InternalParameterIndex index) noexcept
  145. {
  146. switch (index)
  147. {
  148. case PARAMETER_NULL:
  149. return "PARAMETER_NULL";
  150. #ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
  151. case PARAMETER_ACTIVE:
  152. return "PARAMETER_ACTIVE";
  153. case PARAMETER_DRYWET:
  154. return "PARAMETER_DRYWET";
  155. case PARAMETER_VOLUME:
  156. return "PARAMETER_VOLUME";
  157. case PARAMETER_BALANCE_LEFT:
  158. return "PARAMETER_BALANCE_LEFT";
  159. case PARAMETER_BALANCE_RIGHT:
  160. return "PARAMETER_BALANCE_RIGHT";
  161. case PARAMETER_PANNING:
  162. return "PARAMETER_PANNING";
  163. case PARAMETER_CTRL_CHANNEL:
  164. return "PARAMETER_CTRL_CHANNEL";
  165. #endif
  166. case PARAMETER_MAX:
  167. return "PARAMETER_MAX";
  168. }
  169. carla_stderr("CarlaBackend::InternalParameterIndex2Str(%i) - invalid index", index);
  170. return nullptr;
  171. }
  172. static inline
  173. const char* EngineCallbackOpcode2Str(const EngineCallbackOpcode opcode) noexcept
  174. {
  175. switch (opcode)
  176. {
  177. case ENGINE_CALLBACK_DEBUG:
  178. return "ENGINE_CALLBACK_DEBUG";
  179. case ENGINE_CALLBACK_PLUGIN_ADDED:
  180. return "ENGINE_CALLBACK_PLUGIN_ADDED";
  181. case ENGINE_CALLBACK_PLUGIN_REMOVED:
  182. return "ENGINE_CALLBACK_PLUGIN_REMOVED";
  183. case ENGINE_CALLBACK_PLUGIN_RENAMED:
  184. return "ENGINE_CALLBACK_PLUGIN_RENAMED";
  185. case ENGINE_CALLBACK_PLUGIN_UNAVAILABLE:
  186. return "ENGINE_CALLBACK_PLUGIN_UNAVAILABLE";
  187. case ENGINE_CALLBACK_PARAMETER_VALUE_CHANGED:
  188. return "ENGINE_CALLBACK_PARAMETER_VALUE_CHANGED";
  189. case ENGINE_CALLBACK_PARAMETER_DEFAULT_CHANGED:
  190. return "ENGINE_CALLBACK_PARAMETER_DEFAULT_CHANGED";
  191. #ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
  192. case ENGINE_CALLBACK_PARAMETER_MIDI_CHANNEL_CHANGED:
  193. return "ENGINE_CALLBACK_PARAMETER_MIDI_CHANNEL_CHANGED";
  194. case ENGINE_CALLBACK_PARAMETER_MIDI_CC_CHANGED:
  195. return "ENGINE_CALLBACK_PARAMETER_MIDI_CC_CHANGED";
  196. case ENGINE_CALLBACK_OPTION_CHANGED:
  197. return "ENGINE_CALLBACK_OPTION_CHANGED";
  198. #endif
  199. case ENGINE_CALLBACK_PROGRAM_CHANGED:
  200. return "ENGINE_CALLBACK_PROGRAM_CHANGED";
  201. case ENGINE_CALLBACK_MIDI_PROGRAM_CHANGED:
  202. return "ENGINE_CALLBACK_MIDI_PROGRAM_CHANGED";
  203. case ENGINE_CALLBACK_UI_STATE_CHANGED:
  204. return "ENGINE_CALLBACK_UI_STATE_CHANGED";
  205. case ENGINE_CALLBACK_NOTE_ON:
  206. return "ENGINE_CALLBACK_NOTE_ON";
  207. case ENGINE_CALLBACK_NOTE_OFF:
  208. return "ENGINE_CALLBACK_NOTE_OFF";
  209. case ENGINE_CALLBACK_UPDATE:
  210. return "ENGINE_CALLBACK_UPDATE";
  211. case ENGINE_CALLBACK_RELOAD_INFO:
  212. return "ENGINE_CALLBACK_RELOAD_INFO";
  213. case ENGINE_CALLBACK_RELOAD_PARAMETERS:
  214. return "ENGINE_CALLBACK_RELOAD_PARAMETERS";
  215. case ENGINE_CALLBACK_RELOAD_PROGRAMS:
  216. return "ENGINE_CALLBACK_RELOAD_PROGRAMS";
  217. case ENGINE_CALLBACK_RELOAD_ALL:
  218. return "ENGINE_CALLBACK_RELOAD_ALL";
  219. #ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
  220. case ENGINE_CALLBACK_PATCHBAY_CLIENT_ADDED:
  221. return "ENGINE_CALLBACK_PATCHBAY_CLIENT_ADDED";
  222. case ENGINE_CALLBACK_PATCHBAY_CLIENT_REMOVED:
  223. return "ENGINE_CALLBACK_PATCHBAY_CLIENT_REMOVED";
  224. case ENGINE_CALLBACK_PATCHBAY_CLIENT_RENAMED:
  225. return "ENGINE_CALLBACK_PATCHBAY_CLIENT_RENAMED";
  226. case ENGINE_CALLBACK_PATCHBAY_CLIENT_DATA_CHANGED:
  227. return "ENGINE_CALLBACK_PATCHBAY_CLIENT_DATA_CHANGED";
  228. case ENGINE_CALLBACK_PATCHBAY_PORT_ADDED:
  229. return "ENGINE_CALLBACK_PATCHBAY_PORT_ADDED";
  230. case ENGINE_CALLBACK_PATCHBAY_PORT_REMOVED:
  231. return "ENGINE_CALLBACK_PATCHBAY_PORT_REMOVED";
  232. case ENGINE_CALLBACK_PATCHBAY_PORT_RENAMED:
  233. return "ENGINE_CALLBACK_PATCHBAY_PORT_RENAMED";
  234. case ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED:
  235. return "ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED";
  236. case ENGINE_CALLBACK_PATCHBAY_CONNECTION_REMOVED:
  237. return "ENGINE_CALLBACK_PATCHBAY_CONNECTION_REMOVED";
  238. #endif
  239. case ENGINE_CALLBACK_ENGINE_STARTED:
  240. return "ENGINE_CALLBACK_ENGINE_STARTED";
  241. case ENGINE_CALLBACK_ENGINE_STOPPED:
  242. return "ENGINE_CALLBACK_ENGINE_STOPPED";
  243. case ENGINE_CALLBACK_PROCESS_MODE_CHANGED:
  244. return "ENGINE_CALLBACK_PROCESS_MODE_CHANGED";
  245. case ENGINE_CALLBACK_TRANSPORT_MODE_CHANGED:
  246. return "ENGINE_CALLBACK_TRANSPORT_MODE_CHANGED";
  247. case ENGINE_CALLBACK_BUFFER_SIZE_CHANGED:
  248. return "ENGINE_CALLBACK_BUFFER_SIZE_CHANGED";
  249. case ENGINE_CALLBACK_SAMPLE_RATE_CHANGED:
  250. return "ENGINE_CALLBACK_SAMPLE_RATE_CHANGED";
  251. case ENGINE_CALLBACK_PROJECT_LOAD_FINISHED:
  252. return "ENGINE_CALLBACK_PROJECT_LOAD_FINISHED";
  253. case ENGINE_CALLBACK_NSM:
  254. return "ENGINE_CALLBACK_NSM";
  255. case ENGINE_CALLBACK_IDLE:
  256. return "ENGINE_CALLBACK_IDLE";
  257. case ENGINE_CALLBACK_INFO:
  258. return "ENGINE_CALLBACK_INFO";
  259. case ENGINE_CALLBACK_ERROR:
  260. return "ENGINE_CALLBACK_ERROR";
  261. case ENGINE_CALLBACK_QUIT:
  262. return "ENGINE_CALLBACK_QUIT";
  263. }
  264. carla_stderr("CarlaBackend::EngineCallbackOpcode2Str(%i) - invalid opcode", opcode);
  265. return nullptr;
  266. }
  267. static inline
  268. const char* EngineOption2Str(const EngineOption option) noexcept
  269. {
  270. switch (option)
  271. {
  272. case ENGINE_OPTION_DEBUG:
  273. return "ENGINE_OPTION_DEBUG";
  274. case ENGINE_OPTION_PROCESS_MODE:
  275. return "ENGINE_OPTION_PROCESS_MODE";
  276. case ENGINE_OPTION_TRANSPORT_MODE:
  277. return "ENGINE_OPTION_TRANSPORT_MODE";
  278. case ENGINE_OPTION_FORCE_STEREO:
  279. return "ENGINE_OPTION_FORCE_STEREO";
  280. case ENGINE_OPTION_PREFER_PLUGIN_BRIDGES:
  281. return "ENGINE_OPTION_PREFER_PLUGIN_BRIDGES";
  282. case ENGINE_OPTION_PREFER_UI_BRIDGES:
  283. return "ENGINE_OPTION_PREFER_UI_BRIDGES";
  284. case ENGINE_OPTION_UIS_ALWAYS_ON_TOP:
  285. return "ENGINE_OPTION_UIS_ALWAYS_ON_TOP";
  286. case ENGINE_OPTION_MAX_PARAMETERS:
  287. return "ENGINE_OPTION_MAX_PARAMETERS";
  288. case ENGINE_OPTION_UI_BRIDGES_TIMEOUT:
  289. return "ENGINE_OPTION_UI_BRIDGES_TIMEOUT";
  290. case ENGINE_OPTION_AUDIO_BUFFER_SIZE:
  291. return "ENGINE_OPTION_AUDIO_BUFFER_SIZE";
  292. case ENGINE_OPTION_AUDIO_SAMPLE_RATE:
  293. return "ENGINE_OPTION_AUDIO_SAMPLE_RATE";
  294. case ENGINE_OPTION_AUDIO_TRIPLE_BUFFER:
  295. return "ENGINE_OPTION_AUDIO_TRIPLE_BUFFER";
  296. case ENGINE_OPTION_AUDIO_DEVICE:
  297. return "ENGINE_OPTION_AUDIO_DEVICE";
  298. case ENGINE_OPTION_PLUGIN_PATH:
  299. return "ENGINE_OPTION_PLUGIN_PATH";
  300. case ENGINE_OPTION_PATH_BINARIES:
  301. return "ENGINE_OPTION_PATH_BINARIES";
  302. case ENGINE_OPTION_PATH_RESOURCES:
  303. return "ENGINE_OPTION_PATH_RESOURCES";
  304. case ENGINE_OPTION_PREVENT_BAD_BEHAVIOUR:
  305. return "ENGINE_OPTION_PREVENT_BAD_BEHAVIOUR";
  306. case ENGINE_OPTION_FRONTEND_WIN_ID:
  307. return "ENGINE_OPTION_FRONTEND_WIN_ID";
  308. #if !defined(BUILD_BRIDGE_ALTERNATIVE_ARCH) && !defined(CARLA_OS_WIN)
  309. case ENGINE_OPTION_WINE_EXECUTABLE:
  310. return "ENGINE_OPTION_WINE_EXECUTABLE";
  311. case ENGINE_OPTION_WINE_AUTO_PREFIX:
  312. return "ENGINE_OPTION_WINE_AUTO_PREFIX";
  313. case ENGINE_OPTION_WINE_FALLBACK_PREFIX:
  314. return "ENGINE_OPTION_WINE_FALLBACK_PREFIX";
  315. case ENGINE_OPTION_WINE_RT_PRIO_ENABLED:
  316. return "ENGINE_OPTION_WINE_RT_PRIO_ENABLED";
  317. case ENGINE_OPTION_WINE_BASE_RT_PRIO:
  318. return "ENGINE_OPTION_WINE_BASE_RT_PRIO";
  319. case ENGINE_OPTION_WINE_SERVER_RT_PRIO:
  320. return "ENGINE_OPTION_WINE_SERVER_RT_PRIO";
  321. #endif
  322. case ENGINE_OPTION_DEBUG_CONSOLE_OUTPUT:
  323. return "ENGINE_OPTION_DEBUG_CONSOLE_OUTPUT";
  324. }
  325. carla_stderr("CarlaBackend::EngineOption2Str(%i) - invalid option", option);
  326. return nullptr;
  327. }
  328. static inline
  329. const char* EngineProcessMode2Str(const EngineProcessMode mode) noexcept
  330. {
  331. switch (mode)
  332. {
  333. case ENGINE_PROCESS_MODE_SINGLE_CLIENT:
  334. return "ENGINE_PROCESS_MODE_SINGLE_CLIENT";
  335. case ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS:
  336. return "ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS";
  337. case ENGINE_PROCESS_MODE_CONTINUOUS_RACK:
  338. return "ENGINE_PROCESS_MODE_CONTINUOUS_RACK";
  339. case ENGINE_PROCESS_MODE_PATCHBAY:
  340. return "ENGINE_PROCESS_MODE_PATCHBAY";
  341. case ENGINE_PROCESS_MODE_BRIDGE:
  342. return "ENGINE_PROCESS_MODE_BRIDGE";
  343. }
  344. carla_stderr("CarlaBackend::EngineProcessMode2Str(%i) - invalid mode", mode);
  345. return nullptr;
  346. }
  347. static inline
  348. const char* EngineTransportMode2Str(const EngineTransportMode mode) noexcept
  349. {
  350. switch (mode)
  351. {
  352. case ENGINE_TRANSPORT_MODE_DISABLED:
  353. return "ENGINE_TRANSPORT_MODE_DISABLED";
  354. case ENGINE_TRANSPORT_MODE_INTERNAL:
  355. return "ENGINE_TRANSPORT_MODE_INTERNAL";
  356. case ENGINE_TRANSPORT_MODE_JACK:
  357. return "ENGINE_TRANSPORT_MODE_JACK";
  358. case ENGINE_TRANSPORT_MODE_PLUGIN:
  359. return "ENGINE_TRANSPORT_MODE_PLUGIN";
  360. case ENGINE_TRANSPORT_MODE_BRIDGE:
  361. return "ENGINE_TRANSPORT_MODE_BRIDGE";
  362. }
  363. carla_stderr("CarlaBackend::EngineTransportMode2Str(%i) - invalid mode", mode);
  364. return nullptr;
  365. }
  366. static inline
  367. const char* FileCallbackOpcode2Str(const FileCallbackOpcode opcode) noexcept
  368. {
  369. switch (opcode)
  370. {
  371. case FILE_CALLBACK_DEBUG:
  372. return "FILE_CALLBACK_DEBUG";
  373. case FILE_CALLBACK_OPEN:
  374. return "FILE_CALLBACK_OPEN";
  375. case FILE_CALLBACK_SAVE:
  376. return "FILE_CALLBACK_SAVE";
  377. }
  378. carla_stderr("CarlaBackend::FileCallbackOpcode2Str(%i) - invalid opcode", opcode);
  379. return nullptr;
  380. }
  381. static inline
  382. const char* PatchbayIcon2Str(const PatchbayIcon icon) noexcept
  383. {
  384. switch (icon)
  385. {
  386. case PATCHBAY_ICON_APPLICATION:
  387. return "PATCHBAY_ICON_APPLICATION";
  388. case PATCHBAY_ICON_PLUGIN:
  389. return "PATCHBAY_ICON_PLUGIN";
  390. case PATCHBAY_ICON_HARDWARE:
  391. return "PATCHBAY_ICON_HARDWARE";
  392. case PATCHBAY_ICON_CARLA:
  393. return "PATCHBAY_ICON_CARLA";
  394. case PATCHBAY_ICON_DISTRHO:
  395. return "PATCHBAY_ICON_DISTRHO";
  396. case PATCHBAY_ICON_FILE:
  397. return "PATCHBAY_ICON_FILE";
  398. }
  399. carla_stderr("CarlaBackend::PatchbayIcon2Str(%i) - invalid icon", icon);
  400. return nullptr;
  401. }
  402. // -----------------------------------------------------------------------
  403. static inline
  404. BinaryType getBinaryTypeFromString(const char* const ctype) noexcept
  405. {
  406. CARLA_SAFE_ASSERT_RETURN(ctype != nullptr && ctype[0] != '\0', BINARY_NONE);
  407. carla_debug("CarlaBackend::getBinaryTypeFromString(\"%s\")", ctype);
  408. CarlaString stype(ctype);
  409. if (stype.isEmpty())
  410. return BINARY_NONE;
  411. stype.toLower();
  412. if (stype == "none")
  413. return BINARY_NONE;
  414. if (stype == "native")
  415. return BINARY_NATIVE;
  416. if (stype == "posix32" || stype == "linux32" || stype == "mac32")
  417. return BINARY_POSIX32;
  418. if (stype == "posix64" || stype == "linux64" || stype == "mac64")
  419. return BINARY_POSIX64;
  420. if (stype == "win32")
  421. return BINARY_WIN32;
  422. if (stype == "win64")
  423. return BINARY_WIN64;
  424. carla_stderr("CarlaBackend::getBinaryTypeFromString(\"%s\") - invalid string type", ctype);
  425. return BINARY_NONE;
  426. }
  427. // -----------------------------------------------------------------------
  428. static inline
  429. const char* getPluginTypeAsString(const PluginType type) noexcept
  430. {
  431. carla_debug("CarlaBackend::getPluginTypeAsString(%i:%s)", type, PluginType2Str(type));
  432. switch (type)
  433. {
  434. case PLUGIN_NONE:
  435. return "NONE";
  436. case PLUGIN_INTERNAL:
  437. return "INTERNAL";
  438. case PLUGIN_LADSPA:
  439. return "LADSPA";
  440. case PLUGIN_DSSI:
  441. return "DSSI";
  442. case PLUGIN_LV2:
  443. return "LV2";
  444. case PLUGIN_VST2:
  445. return "VST2";
  446. case PLUGIN_SF2:
  447. return "SF2";
  448. case PLUGIN_SFZ:
  449. return "SFZ";
  450. case PLUGIN_JACK:
  451. return "JACK";
  452. }
  453. carla_stderr("CarlaBackend::getPluginTypeAsString(%i) - invalid type", type);
  454. return "NONE";
  455. }
  456. static inline
  457. PluginType getPluginTypeFromString(const char* const ctype) noexcept
  458. {
  459. CARLA_SAFE_ASSERT_RETURN(ctype != nullptr && ctype[0] != '\0', PLUGIN_NONE);
  460. carla_debug("CarlaBackend::getPluginTypeFromString(\"%s\")", ctype);
  461. CarlaString stype(ctype);
  462. if (stype.isEmpty())
  463. return PLUGIN_NONE;
  464. stype.toLower();
  465. if (stype == "none")
  466. return PLUGIN_NONE;
  467. if (stype == "internal" || stype == "native")
  468. return PLUGIN_INTERNAL;
  469. if (stype == "ladspa")
  470. return PLUGIN_LADSPA;
  471. if (stype == "dssi")
  472. return PLUGIN_DSSI;
  473. if (stype == "lv2")
  474. return PLUGIN_LV2;
  475. if (stype == "vst2" || stype == "vst")
  476. return PLUGIN_VST2;
  477. if (stype == "sf2")
  478. return PLUGIN_SF2;
  479. if (stype == "sfz")
  480. return PLUGIN_SFZ;
  481. if (stype == "jack")
  482. return PLUGIN_JACK;
  483. carla_stderr("CarlaBackend::getPluginTypeFromString(\"%s\") - invalid string type", ctype);
  484. return PLUGIN_NONE;
  485. }
  486. // -----------------------------------------------------------------------
  487. static inline
  488. PluginCategory getPluginCategoryFromName(const char* const name) noexcept
  489. {
  490. CARLA_SAFE_ASSERT_RETURN(name != nullptr && name[0] != '\0', PLUGIN_CATEGORY_NONE);
  491. carla_debug("CarlaBackend::getPluginCategoryFromName(\"%s\")", name);
  492. CarlaString sname(name);
  493. if (sname.isEmpty())
  494. return PLUGIN_CATEGORY_NONE;
  495. sname.toLower();
  496. // generic tags first
  497. if (sname.contains("delay"))
  498. return PLUGIN_CATEGORY_DELAY;
  499. if (sname.contains("reverb"))
  500. return PLUGIN_CATEGORY_DELAY;
  501. // filter
  502. if (sname.contains("filter"))
  503. return PLUGIN_CATEGORY_FILTER;
  504. // distortion
  505. if (sname.contains("distortion"))
  506. return PLUGIN_CATEGORY_DISTORTION;
  507. // dynamics
  508. if (sname.contains("dynamics"))
  509. return PLUGIN_CATEGORY_DYNAMICS;
  510. if (sname.contains("amplifier"))
  511. return PLUGIN_CATEGORY_DYNAMICS;
  512. if (sname.contains("compressor"))
  513. return PLUGIN_CATEGORY_DYNAMICS;
  514. if (sname.contains("enhancer"))
  515. return PLUGIN_CATEGORY_DYNAMICS;
  516. if (sname.contains("exciter"))
  517. return PLUGIN_CATEGORY_DYNAMICS;
  518. if (sname.contains("gate"))
  519. return PLUGIN_CATEGORY_DYNAMICS;
  520. if (sname.contains("limiter"))
  521. return PLUGIN_CATEGORY_DYNAMICS;
  522. // modulator
  523. if (sname.contains("modulator"))
  524. return PLUGIN_CATEGORY_MODULATOR;
  525. if (sname.contains("chorus"))
  526. return PLUGIN_CATEGORY_MODULATOR;
  527. if (sname.contains("flanger"))
  528. return PLUGIN_CATEGORY_MODULATOR;
  529. if (sname.contains("phaser"))
  530. return PLUGIN_CATEGORY_MODULATOR;
  531. if (sname.contains("saturator"))
  532. return PLUGIN_CATEGORY_MODULATOR;
  533. // utility
  534. if (sname.contains("utility"))
  535. return PLUGIN_CATEGORY_UTILITY;
  536. if (sname.contains("analyzer"))
  537. return PLUGIN_CATEGORY_UTILITY;
  538. if (sname.contains("converter"))
  539. return PLUGIN_CATEGORY_UTILITY;
  540. if (sname.contains("deesser"))
  541. return PLUGIN_CATEGORY_UTILITY;
  542. if (sname.contains("mixer"))
  543. return PLUGIN_CATEGORY_UTILITY;
  544. // common tags
  545. if (sname.contains("verb"))
  546. return PLUGIN_CATEGORY_DELAY;
  547. if (sname.contains("eq"))
  548. return PLUGIN_CATEGORY_EQ;
  549. if (sname.contains("tool"))
  550. return PLUGIN_CATEGORY_UTILITY;
  551. return PLUGIN_CATEGORY_NONE;
  552. }
  553. // -----------------------------------------------------------------------
  554. CARLA_BACKEND_END_NAMESPACE
  555. #endif // CARLA_BACKEND_UTILS_HPP_INCLUDED