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.

634 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_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_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. }
  270. carla_stderr("CarlaBackend::EngineCallbackOpcode2Str(%i) - invalid opcode", opcode);
  271. return nullptr;
  272. }
  273. static inline
  274. const char* EngineOption2Str(const EngineOption option) noexcept
  275. {
  276. switch (option)
  277. {
  278. case ENGINE_OPTION_DEBUG:
  279. return "ENGINE_OPTION_DEBUG";
  280. case ENGINE_OPTION_PROCESS_MODE:
  281. return "ENGINE_OPTION_PROCESS_MODE";
  282. case ENGINE_OPTION_TRANSPORT_MODE:
  283. return "ENGINE_OPTION_TRANSPORT_MODE";
  284. case ENGINE_OPTION_FORCE_STEREO:
  285. return "ENGINE_OPTION_FORCE_STEREO";
  286. case ENGINE_OPTION_PREFER_PLUGIN_BRIDGES:
  287. return "ENGINE_OPTION_PREFER_PLUGIN_BRIDGES";
  288. case ENGINE_OPTION_PREFER_UI_BRIDGES:
  289. return "ENGINE_OPTION_PREFER_UI_BRIDGES";
  290. case ENGINE_OPTION_UIS_ALWAYS_ON_TOP:
  291. return "ENGINE_OPTION_UIS_ALWAYS_ON_TOP";
  292. case ENGINE_OPTION_MAX_PARAMETERS:
  293. return "ENGINE_OPTION_MAX_PARAMETERS";
  294. case ENGINE_OPTION_UI_BRIDGES_TIMEOUT:
  295. return "ENGINE_OPTION_UI_BRIDGES_TIMEOUT";
  296. case ENGINE_OPTION_AUDIO_NUM_PERIODS:
  297. return "ENGINE_OPTION_AUDIO_NUM_PERIODS";
  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_DEVICE:
  303. return "ENGINE_OPTION_AUDIO_DEVICE";
  304. case ENGINE_OPTION_PLUGIN_PATH:
  305. return "ENGINE_OPTION_PLUGIN_PATH";
  306. case ENGINE_OPTION_PATH_BINARIES:
  307. return "ENGINE_OPTION_PATH_BINARIES";
  308. case ENGINE_OPTION_PATH_RESOURCES:
  309. return "ENGINE_OPTION_PATH_RESOURCES";
  310. case ENGINE_OPTION_PREVENT_BAD_BEHAVIOUR:
  311. return "ENGINE_OPTION_PREVENT_BAD_BEHAVIOUR";
  312. case ENGINE_OPTION_FRONTEND_WIN_ID:
  313. return "ENGINE_OPTION_FRONTEND_WIN_ID";
  314. case ENGINE_OPTION_WINE_EXECUTABLE:
  315. return "ENGINE_OPTION_WINE_EXECUTABLE";
  316. case ENGINE_OPTION_WINE_AUTO_PREFIX:
  317. return "ENGINE_OPTION_WINE_AUTO_PREFIX";
  318. case ENGINE_OPTION_WINE_FALLBACK_PREFIX:
  319. return "ENGINE_OPTION_WINE_FALLBACK_PREFIX";
  320. case ENGINE_OPTION_WINE_RT_PRIO_ENABLED:
  321. return "ENGINE_OPTION_WINE_RT_PRIO_ENABLED";
  322. case ENGINE_OPTION_WINE_BASE_RT_PRIO:
  323. return "ENGINE_OPTION_WINE_BASE_RT_PRIO";
  324. case ENGINE_OPTION_WINE_SERVER_RT_PRIO:
  325. return "ENGINE_OPTION_WINE_SERVER_RT_PRIO";
  326. case ENGINE_OPTION_DEBUG_CONSOLE_OUTPUT:
  327. return "ENGINE_OPTION_DEBUG_CONSOLE_OUTPUT";
  328. }
  329. carla_stderr("CarlaBackend::EngineOption2Str(%i) - invalid option", option);
  330. return nullptr;
  331. }
  332. static inline
  333. const char* EngineProcessMode2Str(const EngineProcessMode mode) noexcept
  334. {
  335. switch (mode)
  336. {
  337. case ENGINE_PROCESS_MODE_SINGLE_CLIENT:
  338. return "ENGINE_PROCESS_MODE_SINGLE_CLIENT";
  339. case ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS:
  340. return "ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS";
  341. case ENGINE_PROCESS_MODE_CONTINUOUS_RACK:
  342. return "ENGINE_PROCESS_MODE_CONTINUOUS_RACK";
  343. case ENGINE_PROCESS_MODE_PATCHBAY:
  344. return "ENGINE_PROCESS_MODE_PATCHBAY";
  345. case ENGINE_PROCESS_MODE_BRIDGE:
  346. return "ENGINE_PROCESS_MODE_BRIDGE";
  347. }
  348. carla_stderr("CarlaBackend::EngineProcessMode2Str(%i) - invalid mode", mode);
  349. return nullptr;
  350. }
  351. static inline
  352. const char* EngineTransportMode2Str(const EngineTransportMode mode) noexcept
  353. {
  354. switch (mode)
  355. {
  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_VST3:
  449. return "VST3";
  450. case PLUGIN_AU:
  451. return "AU";;
  452. case PLUGIN_GIG:
  453. return "GIG";
  454. case PLUGIN_SF2:
  455. return "SF2";
  456. case PLUGIN_SFZ:
  457. return "SFZ";
  458. case PLUGIN_JACK:
  459. return "JACK";
  460. }
  461. carla_stderr("CarlaBackend::getPluginTypeAsString(%i) - invalid type", type);
  462. return "NONE";
  463. }
  464. static inline
  465. PluginType getPluginTypeFromString(const char* const ctype) noexcept
  466. {
  467. CARLA_SAFE_ASSERT_RETURN(ctype != nullptr && ctype[0] != '\0', PLUGIN_NONE);
  468. carla_debug("CarlaBackend::getPluginTypeFromString(\"%s\")", ctype);
  469. CarlaString stype(ctype);
  470. if (stype.isEmpty())
  471. return PLUGIN_NONE;
  472. stype.toLower();
  473. if (stype == "none")
  474. return PLUGIN_NONE;
  475. if (stype == "internal" || stype == "native")
  476. return PLUGIN_INTERNAL;
  477. if (stype == "ladspa")
  478. return PLUGIN_LADSPA;
  479. if (stype == "dssi")
  480. return PLUGIN_DSSI;
  481. if (stype == "lv2")
  482. return PLUGIN_LV2;
  483. if (stype == "vst2" || stype == "vst")
  484. return PLUGIN_VST2;
  485. if (stype == "vst3")
  486. return PLUGIN_VST3;
  487. if (stype == "au" || stype == "audiounit")
  488. return PLUGIN_AU;
  489. if (stype == "gig")
  490. return PLUGIN_GIG;
  491. if (stype == "sf2")
  492. return PLUGIN_SF2;
  493. if (stype == "sfz")
  494. return PLUGIN_SFZ;
  495. if (stype == "jack")
  496. return PLUGIN_JACK;
  497. carla_stderr("CarlaBackend::getPluginTypeFromString(\"%s\") - invalid string type", ctype);
  498. return PLUGIN_NONE;
  499. }
  500. // -----------------------------------------------------------------------
  501. static inline
  502. PluginCategory getPluginCategoryFromName(const char* const name) noexcept
  503. {
  504. CARLA_SAFE_ASSERT_RETURN(name != nullptr && name[0] != '\0', PLUGIN_CATEGORY_NONE);
  505. carla_debug("CarlaBackend::getPluginCategoryFromName(\"%s\")", name);
  506. CarlaString sname(name);
  507. if (sname.isEmpty())
  508. return PLUGIN_CATEGORY_NONE;
  509. sname.toLower();
  510. // generic tags first
  511. if (sname.contains("delay"))
  512. return PLUGIN_CATEGORY_DELAY;
  513. if (sname.contains("reverb"))
  514. return PLUGIN_CATEGORY_DELAY;
  515. // filter
  516. if (sname.contains("filter"))
  517. return PLUGIN_CATEGORY_FILTER;
  518. // distortion
  519. if (sname.contains("distortion"))
  520. return PLUGIN_CATEGORY_DISTORTION;
  521. // dynamics
  522. if (sname.contains("dynamics"))
  523. return PLUGIN_CATEGORY_DYNAMICS;
  524. if (sname.contains("amplifier"))
  525. return PLUGIN_CATEGORY_DYNAMICS;
  526. if (sname.contains("compressor"))
  527. return PLUGIN_CATEGORY_DYNAMICS;
  528. if (sname.contains("enhancer"))
  529. return PLUGIN_CATEGORY_DYNAMICS;
  530. if (sname.contains("exciter"))
  531. return PLUGIN_CATEGORY_DYNAMICS;
  532. if (sname.contains("gate"))
  533. return PLUGIN_CATEGORY_DYNAMICS;
  534. if (sname.contains("limiter"))
  535. return PLUGIN_CATEGORY_DYNAMICS;
  536. // modulator
  537. if (sname.contains("modulator"))
  538. return PLUGIN_CATEGORY_MODULATOR;
  539. if (sname.contains("chorus"))
  540. return PLUGIN_CATEGORY_MODULATOR;
  541. if (sname.contains("flanger"))
  542. return PLUGIN_CATEGORY_MODULATOR;
  543. if (sname.contains("phaser"))
  544. return PLUGIN_CATEGORY_MODULATOR;
  545. if (sname.contains("saturator"))
  546. return PLUGIN_CATEGORY_MODULATOR;
  547. // utility
  548. if (sname.contains("utility"))
  549. return PLUGIN_CATEGORY_UTILITY;
  550. if (sname.contains("analyzer"))
  551. return PLUGIN_CATEGORY_UTILITY;
  552. if (sname.contains("converter"))
  553. return PLUGIN_CATEGORY_UTILITY;
  554. if (sname.contains("deesser"))
  555. return PLUGIN_CATEGORY_UTILITY;
  556. if (sname.contains("mixer"))
  557. return PLUGIN_CATEGORY_UTILITY;
  558. // common tags
  559. if (sname.contains("verb"))
  560. return PLUGIN_CATEGORY_DELAY;
  561. if (sname.contains("eq"))
  562. return PLUGIN_CATEGORY_EQ;
  563. if (sname.contains("tool"))
  564. return PLUGIN_CATEGORY_UTILITY;
  565. return PLUGIN_CATEGORY_NONE;
  566. }
  567. // -----------------------------------------------------------------------
  568. CARLA_BACKEND_END_NAMESPACE
  569. #endif // CARLA_BACKEND_UTILS_HPP_INCLUDED