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.

695 lines
22KB

  1. /*
  2. * Carla Backend utils
  3. * Copyright (C) 2011-2019 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* FileType2Str(const FileType type) noexcept
  74. {
  75. switch (type)
  76. {
  77. case FILE_NONE:
  78. return "FILE_NONE";
  79. case FILE_AUDIO:
  80. return "FILE_AUDIO";
  81. case FILE_MIDI:
  82. return "FILE_MIDI";
  83. }
  84. carla_stderr("CarlaBackend::FileType2Str(%i) - invalid type", type);
  85. return nullptr;
  86. }
  87. static inline
  88. const char* PluginType2Str(const PluginType type) noexcept
  89. {
  90. switch (type)
  91. {
  92. case PLUGIN_NONE:
  93. return "PLUGIN_NONE";
  94. case PLUGIN_INTERNAL:
  95. return "PLUGIN_INTERNAL";
  96. case PLUGIN_LADSPA:
  97. return "PLUGIN_LADSPA";
  98. case PLUGIN_DSSI:
  99. return "PLUGIN_DSSI";
  100. case PLUGIN_LV2:
  101. return "PLUGIN_LV2";
  102. case PLUGIN_VST2:
  103. return "PLUGIN_VST2";
  104. case PLUGIN_VST3:
  105. return "PLUGIN_VST3";
  106. case PLUGIN_AU:
  107. return "PLUGIN_AU";
  108. case PLUGIN_DLS:
  109. return "PLUGIN_DLS";
  110. case PLUGIN_GIG:
  111. return "PLUGIN_GIG";
  112. case PLUGIN_SF2:
  113. return "PLUGIN_SF2";
  114. case PLUGIN_SFZ:
  115. return "PLUGIN_SFZ";
  116. case PLUGIN_JACK:
  117. return "PLUGIN_JACK";
  118. }
  119. carla_stderr("CarlaBackend::PluginType2Str(%i) - invalid type", type);
  120. return nullptr;
  121. }
  122. static inline
  123. const char* PluginCategory2Str(const PluginCategory category) noexcept
  124. {
  125. switch (category)
  126. {
  127. case PLUGIN_CATEGORY_NONE:
  128. return "PLUGIN_CATEGORY_NONE";
  129. case PLUGIN_CATEGORY_SYNTH:
  130. return "PLUGIN_CATEGORY_SYNTH";
  131. case PLUGIN_CATEGORY_DELAY:
  132. return "PLUGIN_CATEGORY_DELAY";
  133. case PLUGIN_CATEGORY_EQ:
  134. return "PLUGIN_CATEGORY_EQ";
  135. case PLUGIN_CATEGORY_FILTER:
  136. return "PLUGIN_CATEGORY_FILTER";
  137. case PLUGIN_CATEGORY_DISTORTION:
  138. return "PLUGIN_CATEGORY_DISTORTION";
  139. case PLUGIN_CATEGORY_DYNAMICS:
  140. return "PLUGIN_CATEGORY_DYNAMICS";
  141. case PLUGIN_CATEGORY_MODULATOR:
  142. return "PLUGIN_CATEGORY_MODULATOR";
  143. case PLUGIN_CATEGORY_UTILITY:
  144. return "PLUGIN_CATEGORY_UTILITY";
  145. case PLUGIN_CATEGORY_OTHER:
  146. return "PLUGIN_CATEGORY_OTHER";
  147. }
  148. carla_stderr("CarlaBackend::PluginCategory2Str(%i) - invalid category", category);
  149. return nullptr;
  150. }
  151. static inline
  152. const char* ParameterType2Str(const ParameterType type) noexcept
  153. {
  154. switch (type)
  155. {
  156. case PARAMETER_UNKNOWN:
  157. return "PARAMETER_UNKNOWN";
  158. case PARAMETER_INPUT:
  159. return "PARAMETER_INPUT";
  160. case PARAMETER_OUTPUT:
  161. return "PARAMETER_OUTPUT";
  162. }
  163. carla_stderr("CarlaBackend::ParameterType2Str(%i) - invalid type", type);
  164. return nullptr;
  165. }
  166. static inline
  167. const char* InternalParameterIndex2Str(const InternalParameterIndex index) noexcept
  168. {
  169. switch (index)
  170. {
  171. case PARAMETER_NULL:
  172. return "PARAMETER_NULL";
  173. #ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
  174. case PARAMETER_ACTIVE:
  175. return "PARAMETER_ACTIVE";
  176. case PARAMETER_DRYWET:
  177. return "PARAMETER_DRYWET";
  178. case PARAMETER_VOLUME:
  179. return "PARAMETER_VOLUME";
  180. case PARAMETER_BALANCE_LEFT:
  181. return "PARAMETER_BALANCE_LEFT";
  182. case PARAMETER_BALANCE_RIGHT:
  183. return "PARAMETER_BALANCE_RIGHT";
  184. case PARAMETER_PANNING:
  185. return "PARAMETER_PANNING";
  186. case PARAMETER_CTRL_CHANNEL:
  187. return "PARAMETER_CTRL_CHANNEL";
  188. #endif
  189. case PARAMETER_MAX:
  190. return "PARAMETER_MAX";
  191. }
  192. carla_stderr("CarlaBackend::InternalParameterIndex2Str(%i) - invalid index", index);
  193. return nullptr;
  194. }
  195. static inline
  196. const char* EngineCallbackOpcode2Str(const EngineCallbackOpcode opcode) noexcept
  197. {
  198. switch (opcode)
  199. {
  200. case ENGINE_CALLBACK_DEBUG:
  201. return "ENGINE_CALLBACK_DEBUG";
  202. case ENGINE_CALLBACK_PLUGIN_ADDED:
  203. return "ENGINE_CALLBACK_PLUGIN_ADDED";
  204. case ENGINE_CALLBACK_PLUGIN_REMOVED:
  205. return "ENGINE_CALLBACK_PLUGIN_REMOVED";
  206. case ENGINE_CALLBACK_PLUGIN_RENAMED:
  207. return "ENGINE_CALLBACK_PLUGIN_RENAMED";
  208. case ENGINE_CALLBACK_PLUGIN_UNAVAILABLE:
  209. return "ENGINE_CALLBACK_PLUGIN_UNAVAILABLE";
  210. case ENGINE_CALLBACK_PARAMETER_VALUE_CHANGED:
  211. return "ENGINE_CALLBACK_PARAMETER_VALUE_CHANGED";
  212. case ENGINE_CALLBACK_PARAMETER_DEFAULT_CHANGED:
  213. return "ENGINE_CALLBACK_PARAMETER_DEFAULT_CHANGED";
  214. #ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
  215. case ENGINE_CALLBACK_PARAMETER_MIDI_CHANNEL_CHANGED:
  216. return "ENGINE_CALLBACK_PARAMETER_MIDI_CHANNEL_CHANGED";
  217. case ENGINE_CALLBACK_PARAMETER_MIDI_CC_CHANGED:
  218. return "ENGINE_CALLBACK_PARAMETER_MIDI_CC_CHANGED";
  219. case ENGINE_CALLBACK_OPTION_CHANGED:
  220. return "ENGINE_CALLBACK_OPTION_CHANGED";
  221. #endif
  222. case ENGINE_CALLBACK_PROGRAM_CHANGED:
  223. return "ENGINE_CALLBACK_PROGRAM_CHANGED";
  224. case ENGINE_CALLBACK_MIDI_PROGRAM_CHANGED:
  225. return "ENGINE_CALLBACK_MIDI_PROGRAM_CHANGED";
  226. case ENGINE_CALLBACK_UI_STATE_CHANGED:
  227. return "ENGINE_CALLBACK_UI_STATE_CHANGED";
  228. case ENGINE_CALLBACK_NOTE_ON:
  229. return "ENGINE_CALLBACK_NOTE_ON";
  230. case ENGINE_CALLBACK_NOTE_OFF:
  231. return "ENGINE_CALLBACK_NOTE_OFF";
  232. case ENGINE_CALLBACK_UPDATE:
  233. return "ENGINE_CALLBACK_UPDATE";
  234. case ENGINE_CALLBACK_RELOAD_INFO:
  235. return "ENGINE_CALLBACK_RELOAD_INFO";
  236. case ENGINE_CALLBACK_RELOAD_PARAMETERS:
  237. return "ENGINE_CALLBACK_RELOAD_PARAMETERS";
  238. case ENGINE_CALLBACK_RELOAD_PROGRAMS:
  239. return "ENGINE_CALLBACK_RELOAD_PROGRAMS";
  240. case ENGINE_CALLBACK_RELOAD_ALL:
  241. return "ENGINE_CALLBACK_RELOAD_ALL";
  242. #ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
  243. case ENGINE_CALLBACK_PATCHBAY_CLIENT_ADDED:
  244. return "ENGINE_CALLBACK_PATCHBAY_CLIENT_ADDED";
  245. case ENGINE_CALLBACK_PATCHBAY_CLIENT_REMOVED:
  246. return "ENGINE_CALLBACK_PATCHBAY_CLIENT_REMOVED";
  247. case ENGINE_CALLBACK_PATCHBAY_CLIENT_RENAMED:
  248. return "ENGINE_CALLBACK_PATCHBAY_CLIENT_RENAMED";
  249. case ENGINE_CALLBACK_PATCHBAY_CLIENT_DATA_CHANGED:
  250. return "ENGINE_CALLBACK_PATCHBAY_CLIENT_DATA_CHANGED";
  251. case ENGINE_CALLBACK_PATCHBAY_PORT_ADDED:
  252. return "ENGINE_CALLBACK_PATCHBAY_PORT_ADDED";
  253. case ENGINE_CALLBACK_PATCHBAY_PORT_REMOVED:
  254. return "ENGINE_CALLBACK_PATCHBAY_PORT_REMOVED";
  255. case ENGINE_CALLBACK_PATCHBAY_PORT_CHANGED:
  256. return "ENGINE_CALLBACK_PATCHBAY_PORT_CHANGED";
  257. case ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED:
  258. return "ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED";
  259. case ENGINE_CALLBACK_PATCHBAY_CONNECTION_REMOVED:
  260. return "ENGINE_CALLBACK_PATCHBAY_CONNECTION_REMOVED";
  261. #endif
  262. case ENGINE_CALLBACK_ENGINE_STARTED:
  263. return "ENGINE_CALLBACK_ENGINE_STARTED";
  264. case ENGINE_CALLBACK_ENGINE_STOPPED:
  265. return "ENGINE_CALLBACK_ENGINE_STOPPED";
  266. case ENGINE_CALLBACK_PROCESS_MODE_CHANGED:
  267. return "ENGINE_CALLBACK_PROCESS_MODE_CHANGED";
  268. case ENGINE_CALLBACK_TRANSPORT_MODE_CHANGED:
  269. return "ENGINE_CALLBACK_TRANSPORT_MODE_CHANGED";
  270. case ENGINE_CALLBACK_BUFFER_SIZE_CHANGED:
  271. return "ENGINE_CALLBACK_BUFFER_SIZE_CHANGED";
  272. case ENGINE_CALLBACK_SAMPLE_RATE_CHANGED:
  273. return "ENGINE_CALLBACK_SAMPLE_RATE_CHANGED";
  274. case ENGINE_CALLBACK_CANCELABLE_ACTION:
  275. return "ENGINE_CALLBACK_CANCELABLE_ACTION";
  276. case ENGINE_CALLBACK_PROJECT_LOAD_FINISHED:
  277. return "ENGINE_CALLBACK_PROJECT_LOAD_FINISHED";
  278. case ENGINE_CALLBACK_NSM:
  279. return "ENGINE_CALLBACK_NSM";
  280. case ENGINE_CALLBACK_IDLE:
  281. return "ENGINE_CALLBACK_IDLE";
  282. case ENGINE_CALLBACK_INFO:
  283. return "ENGINE_CALLBACK_INFO";
  284. case ENGINE_CALLBACK_ERROR:
  285. return "ENGINE_CALLBACK_ERROR";
  286. case ENGINE_CALLBACK_QUIT:
  287. return "ENGINE_CALLBACK_QUIT";
  288. case ENGINE_CALLBACK_INLINE_DISPLAY_REDRAW:
  289. return "ENGINE_CALLBACK_INLINE_DISPLAY_REDRAW";
  290. case ENGINE_CALLBACK_PATCHBAY_PORT_GROUP_ADDED:
  291. return "ENGINE_CALLBACK_PATCHBAY_PORT_GROUP_ADDED";
  292. case ENGINE_CALLBACK_PATCHBAY_PORT_GROUP_REMOVED:
  293. return "ENGINE_CALLBACK_PATCHBAY_PORT_GROUP_REMOVED";
  294. case ENGINE_CALLBACK_PATCHBAY_PORT_GROUP_CHANGED:
  295. return "ENGINE_CALLBACK_PATCHBAY_PORT_GROUP_CHANGED";
  296. }
  297. carla_stderr("CarlaBackend::EngineCallbackOpcode2Str(%i) - invalid opcode", opcode);
  298. return nullptr;
  299. }
  300. static inline
  301. const char* EngineOption2Str(const EngineOption option) noexcept
  302. {
  303. switch (option)
  304. {
  305. case ENGINE_OPTION_DEBUG:
  306. return "ENGINE_OPTION_DEBUG";
  307. case ENGINE_OPTION_PROCESS_MODE:
  308. return "ENGINE_OPTION_PROCESS_MODE";
  309. case ENGINE_OPTION_TRANSPORT_MODE:
  310. return "ENGINE_OPTION_TRANSPORT_MODE";
  311. case ENGINE_OPTION_FORCE_STEREO:
  312. return "ENGINE_OPTION_FORCE_STEREO";
  313. case ENGINE_OPTION_PREFER_PLUGIN_BRIDGES:
  314. return "ENGINE_OPTION_PREFER_PLUGIN_BRIDGES";
  315. case ENGINE_OPTION_PREFER_UI_BRIDGES:
  316. return "ENGINE_OPTION_PREFER_UI_BRIDGES";
  317. case ENGINE_OPTION_UIS_ALWAYS_ON_TOP:
  318. return "ENGINE_OPTION_UIS_ALWAYS_ON_TOP";
  319. case ENGINE_OPTION_MAX_PARAMETERS:
  320. return "ENGINE_OPTION_MAX_PARAMETERS";
  321. case ENGINE_OPTION_UI_BRIDGES_TIMEOUT:
  322. return "ENGINE_OPTION_UI_BRIDGES_TIMEOUT";
  323. case ENGINE_OPTION_AUDIO_BUFFER_SIZE:
  324. return "ENGINE_OPTION_AUDIO_BUFFER_SIZE";
  325. case ENGINE_OPTION_AUDIO_SAMPLE_RATE:
  326. return "ENGINE_OPTION_AUDIO_SAMPLE_RATE";
  327. case ENGINE_OPTION_AUDIO_TRIPLE_BUFFER:
  328. return "ENGINE_OPTION_AUDIO_TRIPLE_BUFFER";
  329. case ENGINE_OPTION_AUDIO_DRIVER:
  330. return "ENGINE_OPTION_AUDIO_DRIVER";
  331. case ENGINE_OPTION_AUDIO_DEVICE:
  332. return "ENGINE_OPTION_AUDIO_DEVICE";
  333. case ENGINE_OPTION_OSC_ENABLED:
  334. return "ENGINE_OPTION_OSC_ENABLED";
  335. case ENGINE_OPTION_OSC_PORT_UDP:
  336. return "ENGINE_OPTION_OSC_PORT_UDP";
  337. case ENGINE_OPTION_OSC_PORT_TCP:
  338. return "ENGINE_OPTION_OSC_PORT_TCP";
  339. case ENGINE_OPTION_FILE_PATH:
  340. return "ENGINE_OPTION_FILE_PATH";
  341. case ENGINE_OPTION_PLUGIN_PATH:
  342. return "ENGINE_OPTION_PLUGIN_PATH";
  343. case ENGINE_OPTION_PATH_BINARIES:
  344. return "ENGINE_OPTION_PATH_BINARIES";
  345. case ENGINE_OPTION_PATH_RESOURCES:
  346. return "ENGINE_OPTION_PATH_RESOURCES";
  347. case ENGINE_OPTION_PREVENT_BAD_BEHAVIOUR:
  348. return "ENGINE_OPTION_PREVENT_BAD_BEHAVIOUR";
  349. case ENGINE_OPTION_FRONTEND_UI_SCALE:
  350. return "ENGINE_OPTION_FRONTEND_UI_SCALE";
  351. case ENGINE_OPTION_FRONTEND_WIN_ID:
  352. return "ENGINE_OPTION_FRONTEND_WIN_ID";
  353. #if !defined(BUILD_BRIDGE_ALTERNATIVE_ARCH) && !defined(CARLA_OS_WIN)
  354. case ENGINE_OPTION_WINE_EXECUTABLE:
  355. return "ENGINE_OPTION_WINE_EXECUTABLE";
  356. case ENGINE_OPTION_WINE_AUTO_PREFIX:
  357. return "ENGINE_OPTION_WINE_AUTO_PREFIX";
  358. case ENGINE_OPTION_WINE_FALLBACK_PREFIX:
  359. return "ENGINE_OPTION_WINE_FALLBACK_PREFIX";
  360. case ENGINE_OPTION_WINE_RT_PRIO_ENABLED:
  361. return "ENGINE_OPTION_WINE_RT_PRIO_ENABLED";
  362. case ENGINE_OPTION_WINE_BASE_RT_PRIO:
  363. return "ENGINE_OPTION_WINE_BASE_RT_PRIO";
  364. case ENGINE_OPTION_WINE_SERVER_RT_PRIO:
  365. return "ENGINE_OPTION_WINE_SERVER_RT_PRIO";
  366. #endif
  367. case ENGINE_OPTION_DEBUG_CONSOLE_OUTPUT:
  368. return "ENGINE_OPTION_DEBUG_CONSOLE_OUTPUT";
  369. }
  370. carla_stderr("CarlaBackend::EngineOption2Str(%i) - invalid option", option);
  371. return nullptr;
  372. }
  373. static inline
  374. const char* EngineProcessMode2Str(const EngineProcessMode mode) noexcept
  375. {
  376. switch (mode)
  377. {
  378. case ENGINE_PROCESS_MODE_SINGLE_CLIENT:
  379. return "ENGINE_PROCESS_MODE_SINGLE_CLIENT";
  380. case ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS:
  381. return "ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS";
  382. case ENGINE_PROCESS_MODE_CONTINUOUS_RACK:
  383. return "ENGINE_PROCESS_MODE_CONTINUOUS_RACK";
  384. case ENGINE_PROCESS_MODE_PATCHBAY:
  385. return "ENGINE_PROCESS_MODE_PATCHBAY";
  386. case ENGINE_PROCESS_MODE_BRIDGE:
  387. return "ENGINE_PROCESS_MODE_BRIDGE";
  388. }
  389. carla_stderr("CarlaBackend::EngineProcessMode2Str(%i) - invalid mode", mode);
  390. return nullptr;
  391. }
  392. static inline
  393. const char* EngineTransportMode2Str(const EngineTransportMode mode) noexcept
  394. {
  395. switch (mode)
  396. {
  397. case ENGINE_TRANSPORT_MODE_DISABLED:
  398. return "ENGINE_TRANSPORT_MODE_DISABLED";
  399. case ENGINE_TRANSPORT_MODE_INTERNAL:
  400. return "ENGINE_TRANSPORT_MODE_INTERNAL";
  401. case ENGINE_TRANSPORT_MODE_JACK:
  402. return "ENGINE_TRANSPORT_MODE_JACK";
  403. case ENGINE_TRANSPORT_MODE_PLUGIN:
  404. return "ENGINE_TRANSPORT_MODE_PLUGIN";
  405. case ENGINE_TRANSPORT_MODE_BRIDGE:
  406. return "ENGINE_TRANSPORT_MODE_BRIDGE";
  407. }
  408. carla_stderr("CarlaBackend::EngineTransportMode2Str(%i) - invalid mode", mode);
  409. return nullptr;
  410. }
  411. static inline
  412. const char* FileCallbackOpcode2Str(const FileCallbackOpcode opcode) noexcept
  413. {
  414. switch (opcode)
  415. {
  416. case FILE_CALLBACK_DEBUG:
  417. return "FILE_CALLBACK_DEBUG";
  418. case FILE_CALLBACK_OPEN:
  419. return "FILE_CALLBACK_OPEN";
  420. case FILE_CALLBACK_SAVE:
  421. return "FILE_CALLBACK_SAVE";
  422. }
  423. carla_stderr("CarlaBackend::FileCallbackOpcode2Str(%i) - invalid opcode", opcode);
  424. return nullptr;
  425. }
  426. static inline
  427. const char* PatchbayIcon2Str(const PatchbayIcon icon) noexcept
  428. {
  429. switch (icon)
  430. {
  431. case PATCHBAY_ICON_APPLICATION:
  432. return "PATCHBAY_ICON_APPLICATION";
  433. case PATCHBAY_ICON_PLUGIN:
  434. return "PATCHBAY_ICON_PLUGIN";
  435. case PATCHBAY_ICON_HARDWARE:
  436. return "PATCHBAY_ICON_HARDWARE";
  437. case PATCHBAY_ICON_CARLA:
  438. return "PATCHBAY_ICON_CARLA";
  439. case PATCHBAY_ICON_DISTRHO:
  440. return "PATCHBAY_ICON_DISTRHO";
  441. case PATCHBAY_ICON_FILE:
  442. return "PATCHBAY_ICON_FILE";
  443. }
  444. carla_stderr("CarlaBackend::PatchbayIcon2Str(%i) - invalid icon", icon);
  445. return nullptr;
  446. }
  447. // -----------------------------------------------------------------------
  448. static inline
  449. BinaryType getBinaryTypeFromString(const char* const ctype) noexcept
  450. {
  451. CARLA_SAFE_ASSERT_RETURN(ctype != nullptr && ctype[0] != '\0', BINARY_NONE);
  452. carla_debug("CarlaBackend::getBinaryTypeFromString(\"%s\")", ctype);
  453. CarlaString stype(ctype);
  454. if (stype.isEmpty())
  455. return BINARY_NONE;
  456. stype.toLower();
  457. if (stype == "none")
  458. return BINARY_NONE;
  459. if (stype == "native")
  460. return BINARY_NATIVE;
  461. if (stype == "posix32" || stype == "linux32" || stype == "mac32")
  462. return BINARY_POSIX32;
  463. if (stype == "posix64" || stype == "linux64" || stype == "mac64")
  464. return BINARY_POSIX64;
  465. if (stype == "win32")
  466. return BINARY_WIN32;
  467. if (stype == "win64")
  468. return BINARY_WIN64;
  469. carla_stderr("CarlaBackend::getBinaryTypeFromString(\"%s\") - invalid string type", ctype);
  470. return BINARY_NONE;
  471. }
  472. // -----------------------------------------------------------------------
  473. static inline
  474. const char* getPluginTypeAsString(const PluginType type) noexcept
  475. {
  476. carla_debug("CarlaBackend::getPluginTypeAsString(%i:%s)", type, PluginType2Str(type));
  477. switch (type)
  478. {
  479. case PLUGIN_NONE:
  480. return "NONE";
  481. case PLUGIN_INTERNAL:
  482. return "INTERNAL";
  483. case PLUGIN_LADSPA:
  484. return "LADSPA";
  485. case PLUGIN_DSSI:
  486. return "DSSI";
  487. case PLUGIN_LV2:
  488. return "LV2";
  489. case PLUGIN_VST2:
  490. return "VST2";
  491. case PLUGIN_VST3:
  492. return "VST3";
  493. case PLUGIN_AU:
  494. return "AU";
  495. case PLUGIN_DLS:
  496. return "DLS";
  497. case PLUGIN_GIG:
  498. return "GIG";
  499. case PLUGIN_SF2:
  500. return "SF2";
  501. case PLUGIN_SFZ:
  502. return "SFZ";
  503. case PLUGIN_JACK:
  504. return "JACK";
  505. }
  506. carla_stderr("CarlaBackend::getPluginTypeAsString(%i) - invalid type", type);
  507. return "NONE";
  508. }
  509. static inline
  510. PluginType getPluginTypeFromString(const char* const ctype) noexcept
  511. {
  512. CARLA_SAFE_ASSERT_RETURN(ctype != nullptr && ctype[0] != '\0', PLUGIN_NONE);
  513. carla_debug("CarlaBackend::getPluginTypeFromString(\"%s\")", ctype);
  514. CarlaString stype(ctype);
  515. if (stype.isEmpty())
  516. return PLUGIN_NONE;
  517. stype.toLower();
  518. if (stype == "none")
  519. return PLUGIN_NONE;
  520. if (stype == "internal" || stype == "native")
  521. return PLUGIN_INTERNAL;
  522. if (stype == "ladspa")
  523. return PLUGIN_LADSPA;
  524. if (stype == "dssi")
  525. return PLUGIN_DSSI;
  526. if (stype == "lv2")
  527. return PLUGIN_LV2;
  528. if (stype == "vst2" || stype == "vst")
  529. return PLUGIN_VST2;
  530. if (stype == "vst3")
  531. return PLUGIN_VST3;
  532. if (stype == "au" || stype == "audiounit")
  533. return PLUGIN_AU;
  534. if (stype == "dls")
  535. return PLUGIN_DLS;
  536. if (stype == "gig")
  537. return PLUGIN_GIG;
  538. if (stype == "sf2" || stype == "sf3")
  539. return PLUGIN_SF2;
  540. if (stype == "sfz")
  541. return PLUGIN_SFZ;
  542. if (stype == "jack")
  543. return PLUGIN_JACK;
  544. carla_stderr("CarlaBackend::getPluginTypeFromString(\"%s\") - invalid string type", ctype);
  545. return PLUGIN_NONE;
  546. }
  547. // -----------------------------------------------------------------------
  548. static inline
  549. PluginCategory getPluginCategoryFromName(const char* const name) noexcept
  550. {
  551. CARLA_SAFE_ASSERT_RETURN(name != nullptr && name[0] != '\0', PLUGIN_CATEGORY_NONE);
  552. carla_debug("CarlaBackend::getPluginCategoryFromName(\"%s\")", name);
  553. CarlaString sname(name);
  554. if (sname.isEmpty())
  555. return PLUGIN_CATEGORY_NONE;
  556. sname.toLower();
  557. // generic tags first
  558. if (sname.contains("delay"))
  559. return PLUGIN_CATEGORY_DELAY;
  560. if (sname.contains("reverb"))
  561. return PLUGIN_CATEGORY_DELAY;
  562. // filter
  563. if (sname.contains("filter"))
  564. return PLUGIN_CATEGORY_FILTER;
  565. // distortion
  566. if (sname.contains("distortion"))
  567. return PLUGIN_CATEGORY_DISTORTION;
  568. // dynamics
  569. if (sname.contains("dynamics"))
  570. return PLUGIN_CATEGORY_DYNAMICS;
  571. if (sname.contains("amplifier"))
  572. return PLUGIN_CATEGORY_DYNAMICS;
  573. if (sname.contains("compressor"))
  574. return PLUGIN_CATEGORY_DYNAMICS;
  575. if (sname.contains("enhancer"))
  576. return PLUGIN_CATEGORY_DYNAMICS;
  577. if (sname.contains("exciter"))
  578. return PLUGIN_CATEGORY_DYNAMICS;
  579. if (sname.contains("gate"))
  580. return PLUGIN_CATEGORY_DYNAMICS;
  581. if (sname.contains("limiter"))
  582. return PLUGIN_CATEGORY_DYNAMICS;
  583. // modulator
  584. if (sname.contains("modulator"))
  585. return PLUGIN_CATEGORY_MODULATOR;
  586. if (sname.contains("chorus"))
  587. return PLUGIN_CATEGORY_MODULATOR;
  588. if (sname.contains("flanger"))
  589. return PLUGIN_CATEGORY_MODULATOR;
  590. if (sname.contains("phaser"))
  591. return PLUGIN_CATEGORY_MODULATOR;
  592. if (sname.contains("saturator"))
  593. return PLUGIN_CATEGORY_MODULATOR;
  594. // utility
  595. if (sname.contains("utility"))
  596. return PLUGIN_CATEGORY_UTILITY;
  597. if (sname.contains("analyzer"))
  598. return PLUGIN_CATEGORY_UTILITY;
  599. if (sname.contains("converter"))
  600. return PLUGIN_CATEGORY_UTILITY;
  601. if (sname.contains("deesser"))
  602. return PLUGIN_CATEGORY_UTILITY;
  603. if (sname.contains("mixer"))
  604. return PLUGIN_CATEGORY_UTILITY;
  605. // common tags
  606. if (sname.contains("verb"))
  607. return PLUGIN_CATEGORY_DELAY;
  608. if (sname.contains("eq"))
  609. return PLUGIN_CATEGORY_EQ;
  610. if (sname.contains("tool"))
  611. return PLUGIN_CATEGORY_UTILITY;
  612. return PLUGIN_CATEGORY_NONE;
  613. }
  614. // -----------------------------------------------------------------------
  615. static inline
  616. bool isPluginOptionEnabled(const uint options, const uint option)
  617. {
  618. if (options == PLUGIN_OPTIONS_NULL)
  619. return true;
  620. if (options & option)
  621. return true;
  622. return false;
  623. }
  624. // -----------------------------------------------------------------------
  625. CARLA_BACKEND_END_NAMESPACE
  626. #endif // CARLA_BACKEND_UTILS_HPP_INCLUDED