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.

671 lines
21KB

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