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.

784 lines
24KB

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