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.

837 lines
26KB

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