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.

626 lines
20KB

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