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-2018 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_SF2:
  94. return "PLUGIN_SF2";
  95. case PLUGIN_SFZ:
  96. return "PLUGIN_SFZ";
  97. case PLUGIN_JACK:
  98. return "PLUGIN_JACK";
  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_ALTERNATIVE_ARCH
  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_ALTERNATIVE_ARCH
  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_ALTERNATIVE_ARCH
  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_CANCELABLE_ACTION:
  256. return "ENGINE_CALLBACK_CANCELABLE_ACTION";
  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_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_TRIPLE_BUFFER:
  301. return "ENGINE_OPTION_AUDIO_TRIPLE_BUFFER";
  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. #if !defined(BUILD_BRIDGE_ALTERNATIVE_ARCH) && !defined(CARLA_OS_WIN)
  315. case ENGINE_OPTION_WINE_EXECUTABLE:
  316. return "ENGINE_OPTION_WINE_EXECUTABLE";
  317. case ENGINE_OPTION_WINE_AUTO_PREFIX:
  318. return "ENGINE_OPTION_WINE_AUTO_PREFIX";
  319. case ENGINE_OPTION_WINE_FALLBACK_PREFIX:
  320. return "ENGINE_OPTION_WINE_FALLBACK_PREFIX";
  321. case ENGINE_OPTION_WINE_RT_PRIO_ENABLED:
  322. return "ENGINE_OPTION_WINE_RT_PRIO_ENABLED";
  323. case ENGINE_OPTION_WINE_BASE_RT_PRIO:
  324. return "ENGINE_OPTION_WINE_BASE_RT_PRIO";
  325. case ENGINE_OPTION_WINE_SERVER_RT_PRIO:
  326. return "ENGINE_OPTION_WINE_SERVER_RT_PRIO";
  327. #endif
  328. case ENGINE_OPTION_DEBUG_CONSOLE_OUTPUT:
  329. return "ENGINE_OPTION_DEBUG_CONSOLE_OUTPUT";
  330. }
  331. carla_stderr("CarlaBackend::EngineOption2Str(%i) - invalid option", option);
  332. return nullptr;
  333. }
  334. static inline
  335. const char* EngineProcessMode2Str(const EngineProcessMode mode) noexcept
  336. {
  337. switch (mode)
  338. {
  339. case ENGINE_PROCESS_MODE_SINGLE_CLIENT:
  340. return "ENGINE_PROCESS_MODE_SINGLE_CLIENT";
  341. case ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS:
  342. return "ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS";
  343. case ENGINE_PROCESS_MODE_CONTINUOUS_RACK:
  344. return "ENGINE_PROCESS_MODE_CONTINUOUS_RACK";
  345. case ENGINE_PROCESS_MODE_PATCHBAY:
  346. return "ENGINE_PROCESS_MODE_PATCHBAY";
  347. case ENGINE_PROCESS_MODE_BRIDGE:
  348. return "ENGINE_PROCESS_MODE_BRIDGE";
  349. }
  350. carla_stderr("CarlaBackend::EngineProcessMode2Str(%i) - invalid mode", mode);
  351. return nullptr;
  352. }
  353. static inline
  354. const char* EngineTransportMode2Str(const EngineTransportMode mode) noexcept
  355. {
  356. switch (mode)
  357. {
  358. case ENGINE_TRANSPORT_MODE_DISABLED:
  359. return "ENGINE_TRANSPORT_MODE_DISABLED";
  360. case ENGINE_TRANSPORT_MODE_INTERNAL:
  361. return "ENGINE_TRANSPORT_MODE_INTERNAL";
  362. case ENGINE_TRANSPORT_MODE_JACK:
  363. return "ENGINE_TRANSPORT_MODE_JACK";
  364. case ENGINE_TRANSPORT_MODE_PLUGIN:
  365. return "ENGINE_TRANSPORT_MODE_PLUGIN";
  366. case ENGINE_TRANSPORT_MODE_BRIDGE:
  367. return "ENGINE_TRANSPORT_MODE_BRIDGE";
  368. }
  369. carla_stderr("CarlaBackend::EngineTransportMode2Str(%i) - invalid mode", mode);
  370. return nullptr;
  371. }
  372. static inline
  373. const char* FileCallbackOpcode2Str(const FileCallbackOpcode opcode) noexcept
  374. {
  375. switch (opcode)
  376. {
  377. case FILE_CALLBACK_DEBUG:
  378. return "FILE_CALLBACK_DEBUG";
  379. case FILE_CALLBACK_OPEN:
  380. return "FILE_CALLBACK_OPEN";
  381. case FILE_CALLBACK_SAVE:
  382. return "FILE_CALLBACK_SAVE";
  383. }
  384. carla_stderr("CarlaBackend::FileCallbackOpcode2Str(%i) - invalid opcode", opcode);
  385. return nullptr;
  386. }
  387. static inline
  388. const char* PatchbayIcon2Str(const PatchbayIcon icon) noexcept
  389. {
  390. switch (icon)
  391. {
  392. case PATCHBAY_ICON_APPLICATION:
  393. return "PATCHBAY_ICON_APPLICATION";
  394. case PATCHBAY_ICON_PLUGIN:
  395. return "PATCHBAY_ICON_PLUGIN";
  396. case PATCHBAY_ICON_HARDWARE:
  397. return "PATCHBAY_ICON_HARDWARE";
  398. case PATCHBAY_ICON_CARLA:
  399. return "PATCHBAY_ICON_CARLA";
  400. case PATCHBAY_ICON_DISTRHO:
  401. return "PATCHBAY_ICON_DISTRHO";
  402. case PATCHBAY_ICON_FILE:
  403. return "PATCHBAY_ICON_FILE";
  404. }
  405. carla_stderr("CarlaBackend::PatchbayIcon2Str(%i) - invalid icon", icon);
  406. return nullptr;
  407. }
  408. // -----------------------------------------------------------------------
  409. static inline
  410. BinaryType getBinaryTypeFromString(const char* const ctype) noexcept
  411. {
  412. CARLA_SAFE_ASSERT_RETURN(ctype != nullptr && ctype[0] != '\0', BINARY_NONE);
  413. carla_debug("CarlaBackend::getBinaryTypeFromString(\"%s\")", ctype);
  414. CarlaString stype(ctype);
  415. if (stype.isEmpty())
  416. return BINARY_NONE;
  417. stype.toLower();
  418. if (stype == "none")
  419. return BINARY_NONE;
  420. if (stype == "native")
  421. return BINARY_NATIVE;
  422. if (stype == "posix32" || stype == "linux32" || stype == "mac32")
  423. return BINARY_POSIX32;
  424. if (stype == "posix64" || stype == "linux64" || stype == "mac64")
  425. return BINARY_POSIX64;
  426. if (stype == "win32")
  427. return BINARY_WIN32;
  428. if (stype == "win64")
  429. return BINARY_WIN64;
  430. carla_stderr("CarlaBackend::getBinaryTypeFromString(\"%s\") - invalid string type", ctype);
  431. return BINARY_NONE;
  432. }
  433. // -----------------------------------------------------------------------
  434. static inline
  435. const char* getPluginTypeAsString(const PluginType type) noexcept
  436. {
  437. carla_debug("CarlaBackend::getPluginTypeAsString(%i:%s)", type, PluginType2Str(type));
  438. switch (type)
  439. {
  440. case PLUGIN_NONE:
  441. return "NONE";
  442. case PLUGIN_INTERNAL:
  443. return "INTERNAL";
  444. case PLUGIN_LADSPA:
  445. return "LADSPA";
  446. case PLUGIN_DSSI:
  447. return "DSSI";
  448. case PLUGIN_LV2:
  449. return "LV2";
  450. case PLUGIN_VST2:
  451. return "VST2";
  452. case PLUGIN_VST3:
  453. return "VST3";
  454. case PLUGIN_AU:
  455. return "AU";;
  456. case PLUGIN_SF2:
  457. return "SF2";
  458. case PLUGIN_SFZ:
  459. return "SFZ";
  460. case PLUGIN_JACK:
  461. return "JACK";
  462. }
  463. carla_stderr("CarlaBackend::getPluginTypeAsString(%i) - invalid type", type);
  464. return "NONE";
  465. }
  466. static inline
  467. PluginType getPluginTypeFromString(const char* const ctype) noexcept
  468. {
  469. CARLA_SAFE_ASSERT_RETURN(ctype != nullptr && ctype[0] != '\0', PLUGIN_NONE);
  470. carla_debug("CarlaBackend::getPluginTypeFromString(\"%s\")", ctype);
  471. CarlaString stype(ctype);
  472. if (stype.isEmpty())
  473. return PLUGIN_NONE;
  474. stype.toLower();
  475. if (stype == "none")
  476. return PLUGIN_NONE;
  477. if (stype == "internal" || stype == "native")
  478. return PLUGIN_INTERNAL;
  479. if (stype == "ladspa")
  480. return PLUGIN_LADSPA;
  481. if (stype == "dssi")
  482. return PLUGIN_DSSI;
  483. if (stype == "lv2")
  484. return PLUGIN_LV2;
  485. if (stype == "vst2" || stype == "vst")
  486. return PLUGIN_VST2;
  487. if (stype == "vst3")
  488. return PLUGIN_VST3;
  489. if (stype == "au" || stype == "audiounit")
  490. return PLUGIN_AU;
  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