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.

612 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_VST3:
  90. return "PLUGIN_VST3";
  91. case PLUGIN_AU:
  92. return "PLUGIN_AU";
  93. case PLUGIN_GIG:
  94. return "PLUGIN_GIG";
  95. case PLUGIN_SF2:
  96. return "PLUGIN_SF2";
  97. case PLUGIN_SFZ:
  98. return "PLUGIN_SFZ";
  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
  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
  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
  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_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. }
  311. carla_stderr("CarlaBackend::EngineOption2Str(%i) - invalid option", option);
  312. return nullptr;
  313. }
  314. static inline
  315. const char* EngineProcessMode2Str(const EngineProcessMode mode) noexcept
  316. {
  317. switch (mode)
  318. {
  319. case ENGINE_PROCESS_MODE_SINGLE_CLIENT:
  320. return "ENGINE_PROCESS_MODE_SINGLE_CLIENT";
  321. case ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS:
  322. return "ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS";
  323. case ENGINE_PROCESS_MODE_CONTINUOUS_RACK:
  324. return "ENGINE_PROCESS_MODE_CONTINUOUS_RACK";
  325. case ENGINE_PROCESS_MODE_PATCHBAY:
  326. return "ENGINE_PROCESS_MODE_PATCHBAY";
  327. case ENGINE_PROCESS_MODE_BRIDGE:
  328. return "ENGINE_PROCESS_MODE_BRIDGE";
  329. }
  330. carla_stderr("CarlaBackend::EngineProcessMode2Str(%i) - invalid mode", mode);
  331. return nullptr;
  332. }
  333. static inline
  334. const char* EngineTransportMode2Str(const EngineTransportMode mode) noexcept
  335. {
  336. switch (mode)
  337. {
  338. case ENGINE_TRANSPORT_MODE_INTERNAL:
  339. return "ENGINE_TRANSPORT_MODE_INTERNAL";
  340. case ENGINE_TRANSPORT_MODE_JACK:
  341. return "ENGINE_TRANSPORT_MODE_JACK";
  342. case ENGINE_TRANSPORT_MODE_PLUGIN:
  343. return "ENGINE_TRANSPORT_MODE_PLUGIN";
  344. case ENGINE_TRANSPORT_MODE_BRIDGE:
  345. return "ENGINE_TRANSPORT_MODE_BRIDGE";
  346. }
  347. carla_stderr("CarlaBackend::EngineTransportMode2Str(%i) - invalid mode", mode);
  348. return nullptr;
  349. }
  350. static inline
  351. const char* FileCallbackOpcode2Str(const FileCallbackOpcode opcode) noexcept
  352. {
  353. switch (opcode)
  354. {
  355. case FILE_CALLBACK_DEBUG:
  356. return "FILE_CALLBACK_DEBUG";
  357. case FILE_CALLBACK_OPEN:
  358. return "FILE_CALLBACK_OPEN";
  359. case FILE_CALLBACK_SAVE:
  360. return "FILE_CALLBACK_SAVE";
  361. }
  362. carla_stderr("CarlaBackend::FileCallbackOpcode2Str(%i) - invalid opcode", opcode);
  363. return nullptr;
  364. }
  365. static inline
  366. const char* PatchbayIcon2Str(const PatchbayIcon icon) noexcept
  367. {
  368. switch (icon)
  369. {
  370. case PATCHBAY_ICON_APPLICATION:
  371. return "PATCHBAY_ICON_APPLICATION";
  372. case PATCHBAY_ICON_PLUGIN:
  373. return "PATCHBAY_ICON_PLUGIN";
  374. case PATCHBAY_ICON_HARDWARE:
  375. return "PATCHBAY_ICON_HARDWARE";
  376. case PATCHBAY_ICON_CARLA:
  377. return "PATCHBAY_ICON_CARLA";
  378. case PATCHBAY_ICON_DISTRHO:
  379. return "PATCHBAY_ICON_DISTRHO";
  380. case PATCHBAY_ICON_FILE:
  381. return "PATCHBAY_ICON_FILE";
  382. }
  383. carla_stderr("CarlaBackend::PatchbayIcon2Str(%i) - invalid icon", icon);
  384. return nullptr;
  385. }
  386. // -----------------------------------------------------------------------
  387. static inline
  388. BinaryType getBinaryTypeFromString(const char* const ctype) noexcept
  389. {
  390. CARLA_SAFE_ASSERT_RETURN(ctype != nullptr && ctype[0] != '\0', BINARY_NONE);
  391. carla_debug("CarlaBackend::getBinaryTypeFromString(\"%s\")", ctype);
  392. CarlaString stype(ctype);
  393. if (stype.isEmpty())
  394. return BINARY_NONE;
  395. stype.toLower();
  396. if (stype == "none")
  397. return BINARY_NONE;
  398. if (stype == "native")
  399. return BINARY_NATIVE;
  400. if (stype == "posix32" || stype == "linux32" || stype == "mac32")
  401. return BINARY_POSIX32;
  402. if (stype == "posix64" || stype == "linux64" || stype == "mac64")
  403. return BINARY_POSIX64;
  404. if (stype == "win32")
  405. return BINARY_WIN32;
  406. if (stype == "win64")
  407. return BINARY_WIN64;
  408. carla_stderr("CarlaBackend::getBinaryTypeFromString(\"%s\") - invalid string type", ctype);
  409. return BINARY_NONE;
  410. }
  411. // -----------------------------------------------------------------------
  412. static inline
  413. const char* getPluginTypeAsString(const PluginType type) noexcept
  414. {
  415. carla_debug("CarlaBackend::getPluginTypeAsString(%i:%s)", type, PluginType2Str(type));
  416. switch (type)
  417. {
  418. case PLUGIN_NONE:
  419. return "NONE";
  420. case PLUGIN_INTERNAL:
  421. return "INTERNAL";
  422. case PLUGIN_LADSPA:
  423. return "LADSPA";
  424. case PLUGIN_DSSI:
  425. return "DSSI";
  426. case PLUGIN_LV2:
  427. return "LV2";
  428. case PLUGIN_VST2:
  429. return "VST2";
  430. case PLUGIN_VST3:
  431. return "VST3";
  432. case PLUGIN_AU:
  433. return "AU";;
  434. case PLUGIN_GIG:
  435. return "GIG";
  436. case PLUGIN_SF2:
  437. return "SF2";
  438. case PLUGIN_SFZ:
  439. return "SFZ";
  440. }
  441. carla_stderr("CarlaBackend::getPluginTypeAsString(%i) - invalid type", type);
  442. return "NONE";
  443. }
  444. static inline
  445. PluginType getPluginTypeFromString(const char* const ctype) noexcept
  446. {
  447. CARLA_SAFE_ASSERT_RETURN(ctype != nullptr && ctype[0] != '\0', PLUGIN_NONE);
  448. carla_debug("CarlaBackend::getPluginTypeFromString(\"%s\")", ctype);
  449. CarlaString stype(ctype);
  450. if (stype.isEmpty())
  451. return PLUGIN_NONE;
  452. stype.toLower();
  453. if (stype == "none")
  454. return PLUGIN_NONE;
  455. if (stype == "internal" || stype == "native")
  456. return PLUGIN_INTERNAL;
  457. if (stype == "ladspa")
  458. return PLUGIN_LADSPA;
  459. if (stype == "dssi")
  460. return PLUGIN_DSSI;
  461. if (stype == "lv2")
  462. return PLUGIN_LV2;
  463. if (stype == "vst2" || stype == "vst")
  464. return PLUGIN_VST2;
  465. if (stype == "vst3")
  466. return PLUGIN_VST3;
  467. if (stype == "au" || stype == "audiounit")
  468. return PLUGIN_AU;
  469. if (stype == "gig")
  470. return PLUGIN_GIG;
  471. if (stype == "sf2")
  472. return PLUGIN_SF2;
  473. if (stype == "sfz")
  474. return PLUGIN_SFZ;
  475. carla_stderr("CarlaBackend::getPluginTypeFromString(\"%s\") - invalid string type", ctype);
  476. return PLUGIN_NONE;
  477. }
  478. // -----------------------------------------------------------------------
  479. static inline
  480. PluginCategory getPluginCategoryFromName(const char* const name) noexcept
  481. {
  482. CARLA_SAFE_ASSERT_RETURN(name != nullptr && name[0] != '\0', PLUGIN_CATEGORY_NONE);
  483. carla_debug("CarlaBackend::getPluginCategoryFromName(\"%s\")", name);
  484. CarlaString sname(name);
  485. if (sname.isEmpty())
  486. return PLUGIN_CATEGORY_NONE;
  487. sname.toLower();
  488. // generic tags first
  489. if (sname.contains("delay"))
  490. return PLUGIN_CATEGORY_DELAY;
  491. if (sname.contains("reverb"))
  492. return PLUGIN_CATEGORY_DELAY;
  493. // filter
  494. if (sname.contains("filter"))
  495. return PLUGIN_CATEGORY_FILTER;
  496. // distortion
  497. if (sname.contains("distortion"))
  498. return PLUGIN_CATEGORY_DISTORTION;
  499. // dynamics
  500. if (sname.contains("dynamics"))
  501. return PLUGIN_CATEGORY_DYNAMICS;
  502. if (sname.contains("amplifier"))
  503. return PLUGIN_CATEGORY_DYNAMICS;
  504. if (sname.contains("compressor"))
  505. return PLUGIN_CATEGORY_DYNAMICS;
  506. if (sname.contains("enhancer"))
  507. return PLUGIN_CATEGORY_DYNAMICS;
  508. if (sname.contains("exciter"))
  509. return PLUGIN_CATEGORY_DYNAMICS;
  510. if (sname.contains("gate"))
  511. return PLUGIN_CATEGORY_DYNAMICS;
  512. if (sname.contains("limiter"))
  513. return PLUGIN_CATEGORY_DYNAMICS;
  514. // modulator
  515. if (sname.contains("modulator"))
  516. return PLUGIN_CATEGORY_MODULATOR;
  517. if (sname.contains("chorus"))
  518. return PLUGIN_CATEGORY_MODULATOR;
  519. if (sname.contains("flanger"))
  520. return PLUGIN_CATEGORY_MODULATOR;
  521. if (sname.contains("phaser"))
  522. return PLUGIN_CATEGORY_MODULATOR;
  523. if (sname.contains("saturator"))
  524. return PLUGIN_CATEGORY_MODULATOR;
  525. // utility
  526. if (sname.contains("utility"))
  527. return PLUGIN_CATEGORY_UTILITY;
  528. if (sname.contains("analyzer"))
  529. return PLUGIN_CATEGORY_UTILITY;
  530. if (sname.contains("converter"))
  531. return PLUGIN_CATEGORY_UTILITY;
  532. if (sname.contains("deesser"))
  533. return PLUGIN_CATEGORY_UTILITY;
  534. if (sname.contains("mixer"))
  535. return PLUGIN_CATEGORY_UTILITY;
  536. // common tags
  537. if (sname.contains("verb"))
  538. return PLUGIN_CATEGORY_DELAY;
  539. if (sname.contains("eq"))
  540. return PLUGIN_CATEGORY_EQ;
  541. if (sname.contains("tool"))
  542. return PLUGIN_CATEGORY_UTILITY;
  543. return PLUGIN_CATEGORY_NONE;
  544. }
  545. // -----------------------------------------------------------------------
  546. CARLA_BACKEND_END_NAMESPACE
  547. #endif // CARLA_BACKEND_UTILS_HPP_INCLUDED