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.

652 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* 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_CHANGED:
  237. return "ENGINE_CALLBACK_PATCHBAY_PORT_CHANGED";
  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. case ENGINE_CALLBACK_INLINE_DISPLAY_REDRAW:
  270. return "ENGINE_CALLBACK_INLINE_DISPLAY_REDRAW";
  271. case ENGINE_CALLBACK_PATCHBAY_PORT_GROUP_ADDED:
  272. return "ENGINE_CALLBACK_PATCHBAY_PORT_GROUP_ADDED";
  273. case ENGINE_CALLBACK_PATCHBAY_PORT_GROUP_REMOVED:
  274. return "ENGINE_CALLBACK_PATCHBAY_PORT_GROUP_REMOVED";
  275. case ENGINE_CALLBACK_PATCHBAY_PORT_GROUP_CHANGED:
  276. return "ENGINE_CALLBACK_PATCHBAY_PORT_GROUP_CHANGED";
  277. }
  278. carla_stderr("CarlaBackend::EngineCallbackOpcode2Str(%i) - invalid opcode", opcode);
  279. return nullptr;
  280. }
  281. static inline
  282. const char* EngineOption2Str(const EngineOption option) noexcept
  283. {
  284. switch (option)
  285. {
  286. case ENGINE_OPTION_DEBUG:
  287. return "ENGINE_OPTION_DEBUG";
  288. case ENGINE_OPTION_PROCESS_MODE:
  289. return "ENGINE_OPTION_PROCESS_MODE";
  290. case ENGINE_OPTION_TRANSPORT_MODE:
  291. return "ENGINE_OPTION_TRANSPORT_MODE";
  292. case ENGINE_OPTION_FORCE_STEREO:
  293. return "ENGINE_OPTION_FORCE_STEREO";
  294. case ENGINE_OPTION_PREFER_PLUGIN_BRIDGES:
  295. return "ENGINE_OPTION_PREFER_PLUGIN_BRIDGES";
  296. case ENGINE_OPTION_PREFER_UI_BRIDGES:
  297. return "ENGINE_OPTION_PREFER_UI_BRIDGES";
  298. case ENGINE_OPTION_UIS_ALWAYS_ON_TOP:
  299. return "ENGINE_OPTION_UIS_ALWAYS_ON_TOP";
  300. case ENGINE_OPTION_MAX_PARAMETERS:
  301. return "ENGINE_OPTION_MAX_PARAMETERS";
  302. case ENGINE_OPTION_UI_BRIDGES_TIMEOUT:
  303. return "ENGINE_OPTION_UI_BRIDGES_TIMEOUT";
  304. case ENGINE_OPTION_AUDIO_BUFFER_SIZE:
  305. return "ENGINE_OPTION_AUDIO_BUFFER_SIZE";
  306. case ENGINE_OPTION_AUDIO_SAMPLE_RATE:
  307. return "ENGINE_OPTION_AUDIO_SAMPLE_RATE";
  308. case ENGINE_OPTION_AUDIO_TRIPLE_BUFFER:
  309. return "ENGINE_OPTION_AUDIO_TRIPLE_BUFFER";
  310. case ENGINE_OPTION_AUDIO_DRIVER:
  311. return "ENGINE_OPTION_AUDIO_DRIVER";
  312. case ENGINE_OPTION_AUDIO_DEVICE:
  313. return "ENGINE_OPTION_AUDIO_DEVICE";
  314. case ENGINE_OPTION_OSC_ENABLED:
  315. return "ENGINE_OPTION_OSC_ENABLED";
  316. case ENGINE_OPTION_OSC_PORT_UDP:
  317. return "ENGINE_OPTION_OSC_PORT_UDP";
  318. case ENGINE_OPTION_OSC_PORT_TCP:
  319. return "ENGINE_OPTION_OSC_PORT_TCP";
  320. case ENGINE_OPTION_PLUGIN_PATH:
  321. return "ENGINE_OPTION_PLUGIN_PATH";
  322. case ENGINE_OPTION_PATH_BINARIES:
  323. return "ENGINE_OPTION_PATH_BINARIES";
  324. case ENGINE_OPTION_PATH_RESOURCES:
  325. return "ENGINE_OPTION_PATH_RESOURCES";
  326. case ENGINE_OPTION_PREVENT_BAD_BEHAVIOUR:
  327. return "ENGINE_OPTION_PREVENT_BAD_BEHAVIOUR";
  328. case ENGINE_OPTION_FRONTEND_UI_SCALE:
  329. return "ENGINE_OPTION_FRONTEND_UI_SCALE";
  330. case ENGINE_OPTION_FRONTEND_WIN_ID:
  331. return "ENGINE_OPTION_FRONTEND_WIN_ID";
  332. #if !defined(BUILD_BRIDGE_ALTERNATIVE_ARCH) && !defined(CARLA_OS_WIN)
  333. case ENGINE_OPTION_WINE_EXECUTABLE:
  334. return "ENGINE_OPTION_WINE_EXECUTABLE";
  335. case ENGINE_OPTION_WINE_AUTO_PREFIX:
  336. return "ENGINE_OPTION_WINE_AUTO_PREFIX";
  337. case ENGINE_OPTION_WINE_FALLBACK_PREFIX:
  338. return "ENGINE_OPTION_WINE_FALLBACK_PREFIX";
  339. case ENGINE_OPTION_WINE_RT_PRIO_ENABLED:
  340. return "ENGINE_OPTION_WINE_RT_PRIO_ENABLED";
  341. case ENGINE_OPTION_WINE_BASE_RT_PRIO:
  342. return "ENGINE_OPTION_WINE_BASE_RT_PRIO";
  343. case ENGINE_OPTION_WINE_SERVER_RT_PRIO:
  344. return "ENGINE_OPTION_WINE_SERVER_RT_PRIO";
  345. #endif
  346. case ENGINE_OPTION_DEBUG_CONSOLE_OUTPUT:
  347. return "ENGINE_OPTION_DEBUG_CONSOLE_OUTPUT";
  348. }
  349. carla_stderr("CarlaBackend::EngineOption2Str(%i) - invalid option", option);
  350. return nullptr;
  351. }
  352. static inline
  353. const char* EngineProcessMode2Str(const EngineProcessMode mode) noexcept
  354. {
  355. switch (mode)
  356. {
  357. case ENGINE_PROCESS_MODE_SINGLE_CLIENT:
  358. return "ENGINE_PROCESS_MODE_SINGLE_CLIENT";
  359. case ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS:
  360. return "ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS";
  361. case ENGINE_PROCESS_MODE_CONTINUOUS_RACK:
  362. return "ENGINE_PROCESS_MODE_CONTINUOUS_RACK";
  363. case ENGINE_PROCESS_MODE_PATCHBAY:
  364. return "ENGINE_PROCESS_MODE_PATCHBAY";
  365. case ENGINE_PROCESS_MODE_BRIDGE:
  366. return "ENGINE_PROCESS_MODE_BRIDGE";
  367. }
  368. carla_stderr("CarlaBackend::EngineProcessMode2Str(%i) - invalid mode", mode);
  369. return nullptr;
  370. }
  371. static inline
  372. const char* EngineTransportMode2Str(const EngineTransportMode mode) noexcept
  373. {
  374. switch (mode)
  375. {
  376. case ENGINE_TRANSPORT_MODE_DISABLED:
  377. return "ENGINE_TRANSPORT_MODE_DISABLED";
  378. case ENGINE_TRANSPORT_MODE_INTERNAL:
  379. return "ENGINE_TRANSPORT_MODE_INTERNAL";
  380. case ENGINE_TRANSPORT_MODE_JACK:
  381. return "ENGINE_TRANSPORT_MODE_JACK";
  382. case ENGINE_TRANSPORT_MODE_PLUGIN:
  383. return "ENGINE_TRANSPORT_MODE_PLUGIN";
  384. case ENGINE_TRANSPORT_MODE_BRIDGE:
  385. return "ENGINE_TRANSPORT_MODE_BRIDGE";
  386. }
  387. carla_stderr("CarlaBackend::EngineTransportMode2Str(%i) - invalid mode", mode);
  388. return nullptr;
  389. }
  390. static inline
  391. const char* FileCallbackOpcode2Str(const FileCallbackOpcode opcode) noexcept
  392. {
  393. switch (opcode)
  394. {
  395. case FILE_CALLBACK_DEBUG:
  396. return "FILE_CALLBACK_DEBUG";
  397. case FILE_CALLBACK_OPEN:
  398. return "FILE_CALLBACK_OPEN";
  399. case FILE_CALLBACK_SAVE:
  400. return "FILE_CALLBACK_SAVE";
  401. }
  402. carla_stderr("CarlaBackend::FileCallbackOpcode2Str(%i) - invalid opcode", opcode);
  403. return nullptr;
  404. }
  405. static inline
  406. const char* PatchbayIcon2Str(const PatchbayIcon icon) noexcept
  407. {
  408. switch (icon)
  409. {
  410. case PATCHBAY_ICON_APPLICATION:
  411. return "PATCHBAY_ICON_APPLICATION";
  412. case PATCHBAY_ICON_PLUGIN:
  413. return "PATCHBAY_ICON_PLUGIN";
  414. case PATCHBAY_ICON_HARDWARE:
  415. return "PATCHBAY_ICON_HARDWARE";
  416. case PATCHBAY_ICON_CARLA:
  417. return "PATCHBAY_ICON_CARLA";
  418. case PATCHBAY_ICON_DISTRHO:
  419. return "PATCHBAY_ICON_DISTRHO";
  420. case PATCHBAY_ICON_FILE:
  421. return "PATCHBAY_ICON_FILE";
  422. }
  423. carla_stderr("CarlaBackend::PatchbayIcon2Str(%i) - invalid icon", icon);
  424. return nullptr;
  425. }
  426. // -----------------------------------------------------------------------
  427. static inline
  428. BinaryType getBinaryTypeFromString(const char* const ctype) noexcept
  429. {
  430. CARLA_SAFE_ASSERT_RETURN(ctype != nullptr && ctype[0] != '\0', BINARY_NONE);
  431. carla_debug("CarlaBackend::getBinaryTypeFromString(\"%s\")", ctype);
  432. CarlaString stype(ctype);
  433. if (stype.isEmpty())
  434. return BINARY_NONE;
  435. stype.toLower();
  436. if (stype == "none")
  437. return BINARY_NONE;
  438. if (stype == "native")
  439. return BINARY_NATIVE;
  440. if (stype == "posix32" || stype == "linux32" || stype == "mac32")
  441. return BINARY_POSIX32;
  442. if (stype == "posix64" || stype == "linux64" || stype == "mac64")
  443. return BINARY_POSIX64;
  444. if (stype == "win32")
  445. return BINARY_WIN32;
  446. if (stype == "win64")
  447. return BINARY_WIN64;
  448. carla_stderr("CarlaBackend::getBinaryTypeFromString(\"%s\") - invalid string type", ctype);
  449. return BINARY_NONE;
  450. }
  451. // -----------------------------------------------------------------------
  452. static inline
  453. const char* getPluginTypeAsString(const PluginType type) noexcept
  454. {
  455. carla_debug("CarlaBackend::getPluginTypeAsString(%i:%s)", type, PluginType2Str(type));
  456. switch (type)
  457. {
  458. case PLUGIN_NONE:
  459. return "NONE";
  460. case PLUGIN_INTERNAL:
  461. return "INTERNAL";
  462. case PLUGIN_LADSPA:
  463. return "LADSPA";
  464. case PLUGIN_DSSI:
  465. return "DSSI";
  466. case PLUGIN_LV2:
  467. return "LV2";
  468. case PLUGIN_VST2:
  469. return "VST2";
  470. case PLUGIN_VST3:
  471. return "VST3";
  472. case PLUGIN_AU:
  473. return "AU";;
  474. case PLUGIN_SF2:
  475. return "SF2";
  476. case PLUGIN_SFZ:
  477. return "SFZ";
  478. case PLUGIN_JACK:
  479. return "JACK";
  480. }
  481. carla_stderr("CarlaBackend::getPluginTypeAsString(%i) - invalid type", type);
  482. return "NONE";
  483. }
  484. static inline
  485. PluginType getPluginTypeFromString(const char* const ctype) noexcept
  486. {
  487. CARLA_SAFE_ASSERT_RETURN(ctype != nullptr && ctype[0] != '\0', PLUGIN_NONE);
  488. carla_debug("CarlaBackend::getPluginTypeFromString(\"%s\")", ctype);
  489. CarlaString stype(ctype);
  490. if (stype.isEmpty())
  491. return PLUGIN_NONE;
  492. stype.toLower();
  493. if (stype == "none")
  494. return PLUGIN_NONE;
  495. if (stype == "internal" || stype == "native")
  496. return PLUGIN_INTERNAL;
  497. if (stype == "ladspa")
  498. return PLUGIN_LADSPA;
  499. if (stype == "dssi")
  500. return PLUGIN_DSSI;
  501. if (stype == "lv2")
  502. return PLUGIN_LV2;
  503. if (stype == "vst2" || stype == "vst")
  504. return PLUGIN_VST2;
  505. if (stype == "vst3")
  506. return PLUGIN_VST3;
  507. if (stype == "au" || stype == "audiounit")
  508. return PLUGIN_AU;
  509. if (stype == "sf2")
  510. return PLUGIN_SF2;
  511. if (stype == "sfz")
  512. return PLUGIN_SFZ;
  513. if (stype == "jack")
  514. return PLUGIN_JACK;
  515. carla_stderr("CarlaBackend::getPluginTypeFromString(\"%s\") - invalid string type", ctype);
  516. return PLUGIN_NONE;
  517. }
  518. // -----------------------------------------------------------------------
  519. static inline
  520. PluginCategory getPluginCategoryFromName(const char* const name) noexcept
  521. {
  522. CARLA_SAFE_ASSERT_RETURN(name != nullptr && name[0] != '\0', PLUGIN_CATEGORY_NONE);
  523. carla_debug("CarlaBackend::getPluginCategoryFromName(\"%s\")", name);
  524. CarlaString sname(name);
  525. if (sname.isEmpty())
  526. return PLUGIN_CATEGORY_NONE;
  527. sname.toLower();
  528. // generic tags first
  529. if (sname.contains("delay"))
  530. return PLUGIN_CATEGORY_DELAY;
  531. if (sname.contains("reverb"))
  532. return PLUGIN_CATEGORY_DELAY;
  533. // filter
  534. if (sname.contains("filter"))
  535. return PLUGIN_CATEGORY_FILTER;
  536. // distortion
  537. if (sname.contains("distortion"))
  538. return PLUGIN_CATEGORY_DISTORTION;
  539. // dynamics
  540. if (sname.contains("dynamics"))
  541. return PLUGIN_CATEGORY_DYNAMICS;
  542. if (sname.contains("amplifier"))
  543. return PLUGIN_CATEGORY_DYNAMICS;
  544. if (sname.contains("compressor"))
  545. return PLUGIN_CATEGORY_DYNAMICS;
  546. if (sname.contains("enhancer"))
  547. return PLUGIN_CATEGORY_DYNAMICS;
  548. if (sname.contains("exciter"))
  549. return PLUGIN_CATEGORY_DYNAMICS;
  550. if (sname.contains("gate"))
  551. return PLUGIN_CATEGORY_DYNAMICS;
  552. if (sname.contains("limiter"))
  553. return PLUGIN_CATEGORY_DYNAMICS;
  554. // modulator
  555. if (sname.contains("modulator"))
  556. return PLUGIN_CATEGORY_MODULATOR;
  557. if (sname.contains("chorus"))
  558. return PLUGIN_CATEGORY_MODULATOR;
  559. if (sname.contains("flanger"))
  560. return PLUGIN_CATEGORY_MODULATOR;
  561. if (sname.contains("phaser"))
  562. return PLUGIN_CATEGORY_MODULATOR;
  563. if (sname.contains("saturator"))
  564. return PLUGIN_CATEGORY_MODULATOR;
  565. // utility
  566. if (sname.contains("utility"))
  567. return PLUGIN_CATEGORY_UTILITY;
  568. if (sname.contains("analyzer"))
  569. return PLUGIN_CATEGORY_UTILITY;
  570. if (sname.contains("converter"))
  571. return PLUGIN_CATEGORY_UTILITY;
  572. if (sname.contains("deesser"))
  573. return PLUGIN_CATEGORY_UTILITY;
  574. if (sname.contains("mixer"))
  575. return PLUGIN_CATEGORY_UTILITY;
  576. // common tags
  577. if (sname.contains("verb"))
  578. return PLUGIN_CATEGORY_DELAY;
  579. if (sname.contains("eq"))
  580. return PLUGIN_CATEGORY_EQ;
  581. if (sname.contains("tool"))
  582. return PLUGIN_CATEGORY_UTILITY;
  583. return PLUGIN_CATEGORY_NONE;
  584. }
  585. // -----------------------------------------------------------------------
  586. CARLA_BACKEND_END_NAMESPACE
  587. #endif // CARLA_BACKEND_UTILS_HPP_INCLUDED