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.

774 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. }
  121. carla_stderr("CarlaBackend::PluginType2Str(%i) - invalid type", type);
  122. return nullptr;
  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 nullptr;
  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 nullptr;
  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 nullptr;
  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 nullptr;
  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 nullptr;
  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 nullptr;
  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 nullptr;
  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 nullptr;
  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 nullptr;
  468. }
  469. // -----------------------------------------------------------------------
  470. static inline
  471. BinaryType getBinaryTypeFromString(const char* const ctype) noexcept
  472. {
  473. CARLA_SAFE_ASSERT_RETURN(ctype != nullptr && ctype[0] != '\0', BINARY_NONE);
  474. carla_debug("CarlaBackend::getBinaryTypeFromString(\"%s\")", ctype);
  475. CarlaString stype(ctype);
  476. if (stype.isEmpty())
  477. return BINARY_NONE;
  478. stype.toLower();
  479. if (stype == "none")
  480. return BINARY_NONE;
  481. if (stype == "native")
  482. return BINARY_NATIVE;
  483. if (stype == "posix32" || stype == "linux32" || stype == "mac32")
  484. return BINARY_POSIX32;
  485. if (stype == "posix64" || stype == "linux64" || stype == "mac64")
  486. return BINARY_POSIX64;
  487. if (stype == "win32")
  488. return BINARY_WIN32;
  489. if (stype == "win64")
  490. return BINARY_WIN64;
  491. carla_stderr("CarlaBackend::getBinaryTypeFromString(\"%s\") - invalid string type", ctype);
  492. return BINARY_NONE;
  493. }
  494. // -----------------------------------------------------------------------
  495. static inline
  496. const char* getPluginCategoryAsString(const PluginCategory category) noexcept
  497. {
  498. carla_debug("CarlaBackend::getPluginCategoryAsString(%i:%s)", category, PluginCategory2Str(category));
  499. switch (category)
  500. {
  501. case PLUGIN_CATEGORY_NONE:
  502. return "none";
  503. case PLUGIN_CATEGORY_SYNTH:
  504. return "synth";
  505. case PLUGIN_CATEGORY_DELAY:
  506. return "delay";
  507. case PLUGIN_CATEGORY_EQ:
  508. return "eq";
  509. case PLUGIN_CATEGORY_FILTER:
  510. return "filter";
  511. case PLUGIN_CATEGORY_DISTORTION:
  512. return "distortion";
  513. case PLUGIN_CATEGORY_DYNAMICS:
  514. return "dynamics";
  515. case PLUGIN_CATEGORY_MODULATOR:
  516. return "modulator";
  517. case PLUGIN_CATEGORY_UTILITY:
  518. return "utility";
  519. case PLUGIN_CATEGORY_OTHER:
  520. return "other";
  521. }
  522. carla_stderr("CarlaBackend::getPluginCategoryAsString(%i) - invalid category", category);
  523. return "NONE";
  524. }
  525. static inline
  526. const char* getPluginTypeAsString(const PluginType type) noexcept
  527. {
  528. carla_debug("CarlaBackend::getPluginTypeAsString(%i:%s)", type, PluginType2Str(type));
  529. switch (type)
  530. {
  531. case PLUGIN_NONE:
  532. return "NONE";
  533. case PLUGIN_INTERNAL:
  534. return "INTERNAL";
  535. case PLUGIN_LADSPA:
  536. return "LADSPA";
  537. case PLUGIN_DSSI:
  538. return "DSSI";
  539. case PLUGIN_LV2:
  540. return "LV2";
  541. case PLUGIN_VST2:
  542. return "VST2";
  543. case PLUGIN_VST3:
  544. return "VST3";
  545. case PLUGIN_AU:
  546. return "AU";
  547. case PLUGIN_DLS:
  548. return "DLS";
  549. case PLUGIN_GIG:
  550. return "GIG";
  551. case PLUGIN_SF2:
  552. return "SF2";
  553. case PLUGIN_SFZ:
  554. return "SFZ";
  555. case PLUGIN_JACK:
  556. return "JACK";
  557. case PLUGIN_JSFX:
  558. return "JSFX";
  559. }
  560. carla_stderr("CarlaBackend::getPluginTypeAsString(%i) - invalid type", type);
  561. return "NONE";
  562. }
  563. static inline
  564. PluginType getPluginTypeFromString(const char* const ctype) noexcept
  565. {
  566. CARLA_SAFE_ASSERT_RETURN(ctype != nullptr && ctype[0] != '\0', PLUGIN_NONE);
  567. carla_debug("CarlaBackend::getPluginTypeFromString(\"%s\")", ctype);
  568. CarlaString stype(ctype);
  569. if (stype.isEmpty())
  570. return PLUGIN_NONE;
  571. stype.toLower();
  572. if (stype == "none")
  573. return PLUGIN_NONE;
  574. if (stype == "internal" || stype == "native")
  575. return PLUGIN_INTERNAL;
  576. if (stype == "ladspa")
  577. return PLUGIN_LADSPA;
  578. if (stype == "dssi")
  579. return PLUGIN_DSSI;
  580. if (stype == "lv2")
  581. return PLUGIN_LV2;
  582. if (stype == "vst2" || stype == "vst")
  583. return PLUGIN_VST2;
  584. if (stype == "vst3")
  585. return PLUGIN_VST3;
  586. if (stype == "au" || stype == "audiounit")
  587. return PLUGIN_AU;
  588. if (stype == "dls")
  589. return PLUGIN_DLS;
  590. if (stype == "gig")
  591. return PLUGIN_GIG;
  592. if (stype == "sf2" || stype == "sf3")
  593. return PLUGIN_SF2;
  594. if (stype == "sfz")
  595. return PLUGIN_SFZ;
  596. if (stype == "jack")
  597. return PLUGIN_JACK;
  598. if (stype == "jsfx")
  599. return PLUGIN_JSFX;
  600. carla_stderr("CarlaBackend::getPluginTypeFromString(\"%s\") - invalid string type", ctype);
  601. return PLUGIN_NONE;
  602. }
  603. // -----------------------------------------------------------------------
  604. static inline
  605. PluginCategory getPluginCategoryFromName(const char* const name) noexcept
  606. {
  607. CARLA_SAFE_ASSERT_RETURN(name != nullptr && name[0] != '\0', PLUGIN_CATEGORY_NONE);
  608. carla_debug("CarlaBackend::getPluginCategoryFromName(\"%s\")", name);
  609. CarlaString sname(name);
  610. if (sname.isEmpty())
  611. return PLUGIN_CATEGORY_NONE;
  612. sname.toLower();
  613. // generic tags first
  614. if (sname.contains("delay"))
  615. return PLUGIN_CATEGORY_DELAY;
  616. if (sname.contains("reverb"))
  617. return PLUGIN_CATEGORY_DELAY;
  618. // filter
  619. if (sname.contains("filter"))
  620. return PLUGIN_CATEGORY_FILTER;
  621. // distortion
  622. if (sname.contains("distortion"))
  623. return PLUGIN_CATEGORY_DISTORTION;
  624. // dynamics
  625. if (sname.contains("dynamics"))
  626. return PLUGIN_CATEGORY_DYNAMICS;
  627. if (sname.contains("amplifier"))
  628. return PLUGIN_CATEGORY_DYNAMICS;
  629. if (sname.contains("compressor"))
  630. return PLUGIN_CATEGORY_DYNAMICS;
  631. if (sname.contains("enhancer"))
  632. return PLUGIN_CATEGORY_DYNAMICS;
  633. if (sname.contains("exciter"))
  634. return PLUGIN_CATEGORY_DYNAMICS;
  635. if (sname.contains("gate"))
  636. return PLUGIN_CATEGORY_DYNAMICS;
  637. if (sname.contains("limiter"))
  638. return PLUGIN_CATEGORY_DYNAMICS;
  639. // modulator
  640. if (sname.contains("modulator"))
  641. return PLUGIN_CATEGORY_MODULATOR;
  642. if (sname.contains("chorus"))
  643. return PLUGIN_CATEGORY_MODULATOR;
  644. if (sname.contains("flanger"))
  645. return PLUGIN_CATEGORY_MODULATOR;
  646. if (sname.contains("phaser"))
  647. return PLUGIN_CATEGORY_MODULATOR;
  648. if (sname.contains("saturator"))
  649. return PLUGIN_CATEGORY_MODULATOR;
  650. // utility
  651. if (sname.contains("utility"))
  652. return PLUGIN_CATEGORY_UTILITY;
  653. if (sname.contains("analyzer"))
  654. return PLUGIN_CATEGORY_UTILITY;
  655. if (sname.contains("converter"))
  656. return PLUGIN_CATEGORY_UTILITY;
  657. if (sname.contains("deesser"))
  658. return PLUGIN_CATEGORY_UTILITY;
  659. if (sname.contains("mixer"))
  660. return PLUGIN_CATEGORY_UTILITY;
  661. // common tags
  662. if (sname.contains("verb"))
  663. return PLUGIN_CATEGORY_DELAY;
  664. if (sname.contains("eq"))
  665. return PLUGIN_CATEGORY_EQ;
  666. if (sname.contains("tool"))
  667. return PLUGIN_CATEGORY_UTILITY;
  668. // synth
  669. if (sname.contains("synth"))
  670. return PLUGIN_CATEGORY_SYNTH;
  671. // other
  672. if (sname.contains("misc"))
  673. return PLUGIN_CATEGORY_OTHER;
  674. if (sname.contains("other"))
  675. return PLUGIN_CATEGORY_OTHER;
  676. return PLUGIN_CATEGORY_NONE;
  677. }
  678. // -----------------------------------------------------------------------
  679. static inline
  680. bool isPluginOptionEnabled(const uint options, const uint option)
  681. {
  682. if (options == PLUGIN_OPTIONS_NULL)
  683. return true;
  684. if (options & option)
  685. return true;
  686. return false;
  687. }
  688. static inline
  689. bool isPluginOptionInverseEnabled(const uint options, const uint option)
  690. {
  691. if (options == PLUGIN_OPTIONS_NULL)
  692. return false;
  693. if (options & option)
  694. return true;
  695. return false;
  696. }
  697. // -----------------------------------------------------------------------
  698. CARLA_BACKEND_END_NAMESPACE
  699. #endif // CARLA_BACKEND_UTILS_HPP_INCLUDED