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.

642 lines
20KB

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