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.

620 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. case PLUGIN_JACK:
  100. return "PLUGIN_JACK";
  101. }
  102. carla_stderr("CarlaBackend::PluginType2Str(%i) - invalid type", type);
  103. return nullptr;
  104. }
  105. static inline
  106. const char* PluginCategory2Str(const PluginCategory category) noexcept
  107. {
  108. switch (category)
  109. {
  110. case PLUGIN_CATEGORY_NONE:
  111. return "PLUGIN_CATEGORY_NONE";
  112. case PLUGIN_CATEGORY_SYNTH:
  113. return "PLUGIN_CATEGORY_SYNTH";
  114. case PLUGIN_CATEGORY_DELAY:
  115. return "PLUGIN_CATEGORY_DELAY";
  116. case PLUGIN_CATEGORY_EQ:
  117. return "PLUGIN_CATEGORY_EQ";
  118. case PLUGIN_CATEGORY_FILTER:
  119. return "PLUGIN_CATEGORY_FILTER";
  120. case PLUGIN_CATEGORY_DISTORTION:
  121. return "PLUGIN_CATEGORY_DISTORTION";
  122. case PLUGIN_CATEGORY_DYNAMICS:
  123. return "PLUGIN_CATEGORY_DYNAMICS";
  124. case PLUGIN_CATEGORY_MODULATOR:
  125. return "PLUGIN_CATEGORY_MODULATOR";
  126. case PLUGIN_CATEGORY_UTILITY:
  127. return "PLUGIN_CATEGORY_UTILITY";
  128. case PLUGIN_CATEGORY_OTHER:
  129. return "PLUGIN_CATEGORY_OTHER";
  130. }
  131. carla_stderr("CarlaBackend::PluginCategory2Str(%i) - invalid category", category);
  132. return nullptr;
  133. }
  134. static inline
  135. const char* ParameterType2Str(const ParameterType type) noexcept
  136. {
  137. switch (type)
  138. {
  139. case PARAMETER_UNKNOWN:
  140. return "PARAMETER_UNKNOWN";
  141. case PARAMETER_INPUT:
  142. return "PARAMETER_INPUT";
  143. case PARAMETER_OUTPUT:
  144. return "PARAMETER_OUTPUT";
  145. }
  146. carla_stderr("CarlaBackend::ParameterType2Str(%i) - invalid type", type);
  147. return nullptr;
  148. }
  149. static inline
  150. const char* InternalParameterIndex2Str(const InternalParameterIndex index) noexcept
  151. {
  152. switch (index)
  153. {
  154. case PARAMETER_NULL:
  155. return "PARAMETER_NULL";
  156. #ifndef BUILD_BRIDGE
  157. case PARAMETER_ACTIVE:
  158. return "PARAMETER_ACTIVE";
  159. case PARAMETER_DRYWET:
  160. return "PARAMETER_DRYWET";
  161. case PARAMETER_VOLUME:
  162. return "PARAMETER_VOLUME";
  163. case PARAMETER_BALANCE_LEFT:
  164. return "PARAMETER_BALANCE_LEFT";
  165. case PARAMETER_BALANCE_RIGHT:
  166. return "PARAMETER_BALANCE_RIGHT";
  167. case PARAMETER_PANNING:
  168. return "PARAMETER_PANNING";
  169. case PARAMETER_CTRL_CHANNEL:
  170. return "PARAMETER_CTRL_CHANNEL";
  171. #endif
  172. case PARAMETER_MAX:
  173. return "PARAMETER_MAX";
  174. }
  175. carla_stderr("CarlaBackend::InternalParameterIndex2Str(%i) - invalid index", index);
  176. return nullptr;
  177. }
  178. static inline
  179. const char* EngineCallbackOpcode2Str(const EngineCallbackOpcode opcode) noexcept
  180. {
  181. switch (opcode)
  182. {
  183. case ENGINE_CALLBACK_DEBUG:
  184. return "ENGINE_CALLBACK_DEBUG";
  185. case ENGINE_CALLBACK_PLUGIN_ADDED:
  186. return "ENGINE_CALLBACK_PLUGIN_ADDED";
  187. case ENGINE_CALLBACK_PLUGIN_REMOVED:
  188. return "ENGINE_CALLBACK_PLUGIN_REMOVED";
  189. case ENGINE_CALLBACK_PLUGIN_RENAMED:
  190. return "ENGINE_CALLBACK_PLUGIN_RENAMED";
  191. case ENGINE_CALLBACK_PLUGIN_UNAVAILABLE:
  192. return "ENGINE_CALLBACK_PLUGIN_UNAVAILABLE";
  193. case ENGINE_CALLBACK_PARAMETER_VALUE_CHANGED:
  194. return "ENGINE_CALLBACK_PARAMETER_VALUE_CHANGED";
  195. case ENGINE_CALLBACK_PARAMETER_DEFAULT_CHANGED:
  196. return "ENGINE_CALLBACK_PARAMETER_DEFAULT_CHANGED";
  197. #ifndef BUILD_BRIDGE
  198. case ENGINE_CALLBACK_PARAMETER_MIDI_CHANNEL_CHANGED:
  199. return "ENGINE_CALLBACK_PARAMETER_MIDI_CHANNEL_CHANGED";
  200. case ENGINE_CALLBACK_PARAMETER_MIDI_CC_CHANGED:
  201. return "ENGINE_CALLBACK_PARAMETER_MIDI_CC_CHANGED";
  202. case ENGINE_CALLBACK_OPTION_CHANGED:
  203. return "ENGINE_CALLBACK_OPTION_CHANGED";
  204. #endif
  205. case ENGINE_CALLBACK_PROGRAM_CHANGED:
  206. return "ENGINE_CALLBACK_PROGRAM_CHANGED";
  207. case ENGINE_CALLBACK_MIDI_PROGRAM_CHANGED:
  208. return "ENGINE_CALLBACK_MIDI_PROGRAM_CHANGED";
  209. case ENGINE_CALLBACK_UI_STATE_CHANGED:
  210. return "ENGINE_CALLBACK_UI_STATE_CHANGED";
  211. case ENGINE_CALLBACK_NOTE_ON:
  212. return "ENGINE_CALLBACK_NOTE_ON";
  213. case ENGINE_CALLBACK_NOTE_OFF:
  214. return "ENGINE_CALLBACK_NOTE_OFF";
  215. case ENGINE_CALLBACK_UPDATE:
  216. return "ENGINE_CALLBACK_UPDATE";
  217. case ENGINE_CALLBACK_RELOAD_INFO:
  218. return "ENGINE_CALLBACK_RELOAD_INFO";
  219. case ENGINE_CALLBACK_RELOAD_PARAMETERS:
  220. return "ENGINE_CALLBACK_RELOAD_PARAMETERS";
  221. case ENGINE_CALLBACK_RELOAD_PROGRAMS:
  222. return "ENGINE_CALLBACK_RELOAD_PROGRAMS";
  223. case ENGINE_CALLBACK_RELOAD_ALL:
  224. return "ENGINE_CALLBACK_RELOAD_ALL";
  225. #ifndef BUILD_BRIDGE
  226. case ENGINE_CALLBACK_PATCHBAY_CLIENT_ADDED:
  227. return "ENGINE_CALLBACK_PATCHBAY_CLIENT_ADDED";
  228. case ENGINE_CALLBACK_PATCHBAY_CLIENT_REMOVED:
  229. return "ENGINE_CALLBACK_PATCHBAY_CLIENT_REMOVED";
  230. case ENGINE_CALLBACK_PATCHBAY_CLIENT_RENAMED:
  231. return "ENGINE_CALLBACK_PATCHBAY_CLIENT_RENAMED";
  232. case ENGINE_CALLBACK_PATCHBAY_CLIENT_DATA_CHANGED:
  233. return "ENGINE_CALLBACK_PATCHBAY_CLIENT_DATA_CHANGED";
  234. case ENGINE_CALLBACK_PATCHBAY_PORT_ADDED:
  235. return "ENGINE_CALLBACK_PATCHBAY_PORT_ADDED";
  236. case ENGINE_CALLBACK_PATCHBAY_PORT_REMOVED:
  237. return "ENGINE_CALLBACK_PATCHBAY_PORT_REMOVED";
  238. case ENGINE_CALLBACK_PATCHBAY_PORT_RENAMED:
  239. return "ENGINE_CALLBACK_PATCHBAY_PORT_RENAMED";
  240. case ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED:
  241. return "ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED";
  242. case ENGINE_CALLBACK_PATCHBAY_CONNECTION_REMOVED:
  243. return "ENGINE_CALLBACK_PATCHBAY_CONNECTION_REMOVED";
  244. #endif
  245. case ENGINE_CALLBACK_ENGINE_STARTED:
  246. return "ENGINE_CALLBACK_ENGINE_STARTED";
  247. case ENGINE_CALLBACK_ENGINE_STOPPED:
  248. return "ENGINE_CALLBACK_ENGINE_STOPPED";
  249. case ENGINE_CALLBACK_PROCESS_MODE_CHANGED:
  250. return "ENGINE_CALLBACK_PROCESS_MODE_CHANGED";
  251. case ENGINE_CALLBACK_TRANSPORT_MODE_CHANGED:
  252. return "ENGINE_CALLBACK_TRANSPORT_MODE_CHANGED";
  253. case ENGINE_CALLBACK_BUFFER_SIZE_CHANGED:
  254. return "ENGINE_CALLBACK_BUFFER_SIZE_CHANGED";
  255. case ENGINE_CALLBACK_SAMPLE_RATE_CHANGED:
  256. return "ENGINE_CALLBACK_SAMPLE_RATE_CHANGED";
  257. case ENGINE_CALLBACK_NSM:
  258. return "ENGINE_CALLBACK_NSM";
  259. case ENGINE_CALLBACK_IDLE:
  260. return "ENGINE_CALLBACK_IDLE";
  261. case ENGINE_CALLBACK_INFO:
  262. return "ENGINE_CALLBACK_INFO";
  263. case ENGINE_CALLBACK_ERROR:
  264. return "ENGINE_CALLBACK_ERROR";
  265. case ENGINE_CALLBACK_QUIT:
  266. return "ENGINE_CALLBACK_QUIT";
  267. }
  268. carla_stderr("CarlaBackend::EngineCallbackOpcode2Str(%i) - invalid opcode", opcode);
  269. return nullptr;
  270. }
  271. static inline
  272. const char* EngineOption2Str(const EngineOption option) noexcept
  273. {
  274. switch (option)
  275. {
  276. case ENGINE_OPTION_DEBUG:
  277. return "ENGINE_OPTION_DEBUG";
  278. case ENGINE_OPTION_PROCESS_MODE:
  279. return "ENGINE_OPTION_PROCESS_MODE";
  280. case ENGINE_OPTION_TRANSPORT_MODE:
  281. return "ENGINE_OPTION_TRANSPORT_MODE";
  282. case ENGINE_OPTION_FORCE_STEREO:
  283. return "ENGINE_OPTION_FORCE_STEREO";
  284. case ENGINE_OPTION_PREFER_PLUGIN_BRIDGES:
  285. return "ENGINE_OPTION_PREFER_PLUGIN_BRIDGES";
  286. case ENGINE_OPTION_PREFER_UI_BRIDGES:
  287. return "ENGINE_OPTION_PREFER_UI_BRIDGES";
  288. case ENGINE_OPTION_UIS_ALWAYS_ON_TOP:
  289. return "ENGINE_OPTION_UIS_ALWAYS_ON_TOP";
  290. case ENGINE_OPTION_MAX_PARAMETERS:
  291. return "ENGINE_OPTION_MAX_PARAMETERS";
  292. case ENGINE_OPTION_UI_BRIDGES_TIMEOUT:
  293. return "ENGINE_OPTION_UI_BRIDGES_TIMEOUT";
  294. case ENGINE_OPTION_AUDIO_NUM_PERIODS:
  295. return "ENGINE_OPTION_AUDIO_NUM_PERIODS";
  296. case ENGINE_OPTION_AUDIO_BUFFER_SIZE:
  297. return "ENGINE_OPTION_AUDIO_BUFFER_SIZE";
  298. case ENGINE_OPTION_AUDIO_SAMPLE_RATE:
  299. return "ENGINE_OPTION_AUDIO_SAMPLE_RATE";
  300. case ENGINE_OPTION_AUDIO_DEVICE:
  301. return "ENGINE_OPTION_AUDIO_DEVICE";
  302. case ENGINE_OPTION_PLUGIN_PATH:
  303. return "ENGINE_OPTION_PLUGIN_PATH";
  304. case ENGINE_OPTION_PATH_BINARIES:
  305. return "ENGINE_OPTION_PATH_BINARIES";
  306. case ENGINE_OPTION_PATH_RESOURCES:
  307. return "ENGINE_OPTION_PATH_RESOURCES";
  308. case ENGINE_OPTION_PREVENT_BAD_BEHAVIOUR:
  309. return "ENGINE_OPTION_PREVENT_BAD_BEHAVIOUR";
  310. case ENGINE_OPTION_FRONTEND_WIN_ID:
  311. return "ENGINE_OPTION_FRONTEND_WIN_ID";
  312. case ENGINE_OPTION_DEBUG_CONSOLE_OUTPUT:
  313. return "ENGINE_OPTION_DEBUG_CONSOLE_OUTPUT";
  314. }
  315. carla_stderr("CarlaBackend::EngineOption2Str(%i) - invalid option", option);
  316. return nullptr;
  317. }
  318. static inline
  319. const char* EngineProcessMode2Str(const EngineProcessMode mode) noexcept
  320. {
  321. switch (mode)
  322. {
  323. case ENGINE_PROCESS_MODE_SINGLE_CLIENT:
  324. return "ENGINE_PROCESS_MODE_SINGLE_CLIENT";
  325. case ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS:
  326. return "ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS";
  327. case ENGINE_PROCESS_MODE_CONTINUOUS_RACK:
  328. return "ENGINE_PROCESS_MODE_CONTINUOUS_RACK";
  329. case ENGINE_PROCESS_MODE_PATCHBAY:
  330. return "ENGINE_PROCESS_MODE_PATCHBAY";
  331. case ENGINE_PROCESS_MODE_BRIDGE:
  332. return "ENGINE_PROCESS_MODE_BRIDGE";
  333. }
  334. carla_stderr("CarlaBackend::EngineProcessMode2Str(%i) - invalid mode", mode);
  335. return nullptr;
  336. }
  337. static inline
  338. const char* EngineTransportMode2Str(const EngineTransportMode mode) noexcept
  339. {
  340. switch (mode)
  341. {
  342. case ENGINE_TRANSPORT_MODE_INTERNAL:
  343. return "ENGINE_TRANSPORT_MODE_INTERNAL";
  344. case ENGINE_TRANSPORT_MODE_JACK:
  345. return "ENGINE_TRANSPORT_MODE_JACK";
  346. case ENGINE_TRANSPORT_MODE_PLUGIN:
  347. return "ENGINE_TRANSPORT_MODE_PLUGIN";
  348. case ENGINE_TRANSPORT_MODE_BRIDGE:
  349. return "ENGINE_TRANSPORT_MODE_BRIDGE";
  350. }
  351. carla_stderr("CarlaBackend::EngineTransportMode2Str(%i) - invalid mode", mode);
  352. return nullptr;
  353. }
  354. static inline
  355. const char* FileCallbackOpcode2Str(const FileCallbackOpcode opcode) noexcept
  356. {
  357. switch (opcode)
  358. {
  359. case FILE_CALLBACK_DEBUG:
  360. return "FILE_CALLBACK_DEBUG";
  361. case FILE_CALLBACK_OPEN:
  362. return "FILE_CALLBACK_OPEN";
  363. case FILE_CALLBACK_SAVE:
  364. return "FILE_CALLBACK_SAVE";
  365. }
  366. carla_stderr("CarlaBackend::FileCallbackOpcode2Str(%i) - invalid opcode", opcode);
  367. return nullptr;
  368. }
  369. static inline
  370. const char* PatchbayIcon2Str(const PatchbayIcon icon) noexcept
  371. {
  372. switch (icon)
  373. {
  374. case PATCHBAY_ICON_APPLICATION:
  375. return "PATCHBAY_ICON_APPLICATION";
  376. case PATCHBAY_ICON_PLUGIN:
  377. return "PATCHBAY_ICON_PLUGIN";
  378. case PATCHBAY_ICON_HARDWARE:
  379. return "PATCHBAY_ICON_HARDWARE";
  380. case PATCHBAY_ICON_CARLA:
  381. return "PATCHBAY_ICON_CARLA";
  382. case PATCHBAY_ICON_DISTRHO:
  383. return "PATCHBAY_ICON_DISTRHO";
  384. case PATCHBAY_ICON_FILE:
  385. return "PATCHBAY_ICON_FILE";
  386. }
  387. carla_stderr("CarlaBackend::PatchbayIcon2Str(%i) - invalid icon", icon);
  388. return nullptr;
  389. }
  390. // -----------------------------------------------------------------------
  391. static inline
  392. BinaryType getBinaryTypeFromString(const char* const ctype) noexcept
  393. {
  394. CARLA_SAFE_ASSERT_RETURN(ctype != nullptr && ctype[0] != '\0', BINARY_NONE);
  395. carla_debug("CarlaBackend::getBinaryTypeFromString(\"%s\")", ctype);
  396. CarlaString stype(ctype);
  397. if (stype.isEmpty())
  398. return BINARY_NONE;
  399. stype.toLower();
  400. if (stype == "none")
  401. return BINARY_NONE;
  402. if (stype == "native")
  403. return BINARY_NATIVE;
  404. if (stype == "posix32" || stype == "linux32" || stype == "mac32")
  405. return BINARY_POSIX32;
  406. if (stype == "posix64" || stype == "linux64" || stype == "mac64")
  407. return BINARY_POSIX64;
  408. if (stype == "win32")
  409. return BINARY_WIN32;
  410. if (stype == "win64")
  411. return BINARY_WIN64;
  412. carla_stderr("CarlaBackend::getBinaryTypeFromString(\"%s\") - invalid string type", ctype);
  413. return BINARY_NONE;
  414. }
  415. // -----------------------------------------------------------------------
  416. static inline
  417. const char* getPluginTypeAsString(const PluginType type) noexcept
  418. {
  419. carla_debug("CarlaBackend::getPluginTypeAsString(%i:%s)", type, PluginType2Str(type));
  420. switch (type)
  421. {
  422. case PLUGIN_NONE:
  423. return "NONE";
  424. case PLUGIN_INTERNAL:
  425. return "INTERNAL";
  426. case PLUGIN_LADSPA:
  427. return "LADSPA";
  428. case PLUGIN_DSSI:
  429. return "DSSI";
  430. case PLUGIN_LV2:
  431. return "LV2";
  432. case PLUGIN_VST2:
  433. return "VST2";
  434. case PLUGIN_VST3:
  435. return "VST3";
  436. case PLUGIN_AU:
  437. return "AU";;
  438. case PLUGIN_GIG:
  439. return "GIG";
  440. case PLUGIN_SF2:
  441. return "SF2";
  442. case PLUGIN_SFZ:
  443. return "SFZ";
  444. case PLUGIN_JACK:
  445. return "JACK";
  446. }
  447. carla_stderr("CarlaBackend::getPluginTypeAsString(%i) - invalid type", type);
  448. return "NONE";
  449. }
  450. static inline
  451. PluginType getPluginTypeFromString(const char* const ctype) noexcept
  452. {
  453. CARLA_SAFE_ASSERT_RETURN(ctype != nullptr && ctype[0] != '\0', PLUGIN_NONE);
  454. carla_debug("CarlaBackend::getPluginTypeFromString(\"%s\")", ctype);
  455. CarlaString stype(ctype);
  456. if (stype.isEmpty())
  457. return PLUGIN_NONE;
  458. stype.toLower();
  459. if (stype == "none")
  460. return PLUGIN_NONE;
  461. if (stype == "internal" || stype == "native")
  462. return PLUGIN_INTERNAL;
  463. if (stype == "ladspa")
  464. return PLUGIN_LADSPA;
  465. if (stype == "dssi")
  466. return PLUGIN_DSSI;
  467. if (stype == "lv2")
  468. return PLUGIN_LV2;
  469. if (stype == "vst2" || stype == "vst")
  470. return PLUGIN_VST2;
  471. if (stype == "vst3")
  472. return PLUGIN_VST3;
  473. if (stype == "au" || stype == "audiounit")
  474. return PLUGIN_AU;
  475. if (stype == "gig")
  476. return PLUGIN_GIG;
  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