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.

622 lines
19KB

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