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.

748 lines
23KB

  1. /*
  2. * Carla Backend utils
  3. * Copyright (C) 2011-2019 Filipe Coelho <falktx@falktx.com>
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License as
  7. * published by the Free Software Foundation; either version 2 of
  8. * the License, or any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * For a full copy of the GNU General Public License see the doc/GPL.txt file.
  16. */
  17. #ifndef CARLA_BACKEND_UTILS_HPP_INCLUDED
  18. #define CARLA_BACKEND_UTILS_HPP_INCLUDED
  19. #include "CarlaBackend.h"
  20. #include "CarlaString.hpp"
  21. CARLA_BACKEND_START_NAMESPACE
  22. // -----------------------------------------------------------------------
  23. static inline
  24. const char* PluginOption2Str(const uint option) noexcept
  25. {
  26. switch (option)
  27. {
  28. case PLUGIN_OPTION_FIXED_BUFFERS:
  29. return "PLUGIN_OPTION_FIXED_BUFFERS";
  30. case PLUGIN_OPTION_FORCE_STEREO:
  31. return "PLUGIN_OPTION_FORCE_STEREO";
  32. case PLUGIN_OPTION_MAP_PROGRAM_CHANGES:
  33. return "PLUGIN_OPTION_MAP_PROGRAM_CHANGES";
  34. case PLUGIN_OPTION_USE_CHUNKS:
  35. return "PLUGIN_OPTION_USE_CHUNKS";
  36. case PLUGIN_OPTION_SEND_CONTROL_CHANGES:
  37. return "PLUGIN_OPTION_SEND_CONTROL_CHANGES";
  38. case PLUGIN_OPTION_SEND_CHANNEL_PRESSURE:
  39. return "PLUGIN_OPTION_SEND_CHANNEL_PRESSURE";
  40. case PLUGIN_OPTION_SEND_NOTE_AFTERTOUCH:
  41. return "PLUGIN_OPTION_SEND_NOTE_AFTERTOUCH";
  42. case PLUGIN_OPTION_SEND_PITCHBEND:
  43. return "PLUGIN_OPTION_SEND_PITCHBEND";
  44. case PLUGIN_OPTION_SEND_ALL_SOUND_OFF:
  45. return "PLUGIN_OPTION_SEND_ALL_SOUND_OFF";
  46. }
  47. carla_stderr("CarlaBackend::PluginOption2Str(%i) - invalid option", option);
  48. return nullptr;
  49. }
  50. // -----------------------------------------------------------------------
  51. static inline
  52. const char* BinaryType2Str(const BinaryType type) noexcept
  53. {
  54. switch (type)
  55. {
  56. case BINARY_NONE:
  57. return "BINARY_NONE";
  58. case BINARY_POSIX32:
  59. return "BINARY_POSIX32";
  60. case BINARY_POSIX64:
  61. return "BINARY_POSIX64";
  62. case BINARY_WIN32:
  63. return "BINARY_WIN32";
  64. case BINARY_WIN64:
  65. return "BINARY_WIN64";
  66. case BINARY_OTHER:
  67. return "BINARY_OTHER";
  68. }
  69. carla_stderr("CarlaBackend::BinaryType2Str(%i) - invalid type", type);
  70. return nullptr;
  71. }
  72. static inline
  73. const char* FileType2Str(const FileType type) noexcept
  74. {
  75. switch (type)
  76. {
  77. case FILE_NONE:
  78. return "FILE_NONE";
  79. case FILE_AUDIO:
  80. return "FILE_AUDIO";
  81. case FILE_MIDI:
  82. return "FILE_MIDI";
  83. }
  84. carla_stderr("CarlaBackend::FileType2Str(%i) - invalid type", type);
  85. return nullptr;
  86. }
  87. static inline
  88. const char* PluginType2Str(const PluginType type) noexcept
  89. {
  90. switch (type)
  91. {
  92. case PLUGIN_NONE:
  93. return "PLUGIN_NONE";
  94. case PLUGIN_INTERNAL:
  95. return "PLUGIN_INTERNAL";
  96. case PLUGIN_LADSPA:
  97. return "PLUGIN_LADSPA";
  98. case PLUGIN_DSSI:
  99. return "PLUGIN_DSSI";
  100. case PLUGIN_LV2:
  101. return "PLUGIN_LV2";
  102. case PLUGIN_VST2:
  103. return "PLUGIN_VST2";
  104. case PLUGIN_VST3:
  105. return "PLUGIN_VST3";
  106. case PLUGIN_AU:
  107. return "PLUGIN_AU";
  108. case PLUGIN_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. }
  119. carla_stderr("CarlaBackend::PluginType2Str(%i) - invalid type", type);
  120. return nullptr;
  121. }
  122. static inline
  123. const char* PluginCategory2Str(const PluginCategory category) noexcept
  124. {
  125. switch (category)
  126. {
  127. case PLUGIN_CATEGORY_NONE:
  128. return "PLUGIN_CATEGORY_NONE";
  129. case PLUGIN_CATEGORY_SYNTH:
  130. return "PLUGIN_CATEGORY_SYNTH";
  131. case PLUGIN_CATEGORY_DELAY:
  132. return "PLUGIN_CATEGORY_DELAY";
  133. case PLUGIN_CATEGORY_EQ:
  134. return "PLUGIN_CATEGORY_EQ";
  135. case PLUGIN_CATEGORY_FILTER:
  136. return "PLUGIN_CATEGORY_FILTER";
  137. case PLUGIN_CATEGORY_DISTORTION:
  138. return "PLUGIN_CATEGORY_DISTORTION";
  139. case PLUGIN_CATEGORY_DYNAMICS:
  140. return "PLUGIN_CATEGORY_DYNAMICS";
  141. case PLUGIN_CATEGORY_MODULATOR:
  142. return "PLUGIN_CATEGORY_MODULATOR";
  143. case PLUGIN_CATEGORY_UTILITY:
  144. return "PLUGIN_CATEGORY_UTILITY";
  145. case PLUGIN_CATEGORY_OTHER:
  146. return "PLUGIN_CATEGORY_OTHER";
  147. }
  148. carla_stderr("CarlaBackend::PluginCategory2Str(%i) - invalid category", category);
  149. return nullptr;
  150. }
  151. static inline
  152. const char* ParameterType2Str(const ParameterType type) noexcept
  153. {
  154. switch (type)
  155. {
  156. case PARAMETER_UNKNOWN:
  157. return "PARAMETER_UNKNOWN";
  158. case PARAMETER_INPUT:
  159. return "PARAMETER_INPUT";
  160. case PARAMETER_OUTPUT:
  161. return "PARAMETER_OUTPUT";
  162. }
  163. carla_stderr("CarlaBackend::ParameterType2Str(%i) - invalid type", type);
  164. return nullptr;
  165. }
  166. static inline
  167. const char* InternalParameterIndex2Str(const InternalParameterIndex index) noexcept
  168. {
  169. switch (index)
  170. {
  171. case PARAMETER_NULL:
  172. return "PARAMETER_NULL";
  173. #ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
  174. case PARAMETER_ACTIVE:
  175. return "PARAMETER_ACTIVE";
  176. case PARAMETER_DRYWET:
  177. return "PARAMETER_DRYWET";
  178. case PARAMETER_VOLUME:
  179. return "PARAMETER_VOLUME";
  180. case PARAMETER_BALANCE_LEFT:
  181. return "PARAMETER_BALANCE_LEFT";
  182. case PARAMETER_BALANCE_RIGHT:
  183. return "PARAMETER_BALANCE_RIGHT";
  184. case PARAMETER_PANNING:
  185. return "PARAMETER_PANNING";
  186. case PARAMETER_CTRL_CHANNEL:
  187. return "PARAMETER_CTRL_CHANNEL";
  188. #endif
  189. case PARAMETER_MAX:
  190. return "PARAMETER_MAX";
  191. }
  192. carla_stderr("CarlaBackend::InternalParameterIndex2Str(%i) - invalid index", index);
  193. return nullptr;
  194. }
  195. static inline
  196. const char* EngineCallbackOpcode2Str(const EngineCallbackOpcode opcode) noexcept
  197. {
  198. switch (opcode)
  199. {
  200. case ENGINE_CALLBACK_DEBUG:
  201. return "ENGINE_CALLBACK_DEBUG";
  202. case ENGINE_CALLBACK_PLUGIN_ADDED:
  203. return "ENGINE_CALLBACK_PLUGIN_ADDED";
  204. case ENGINE_CALLBACK_PLUGIN_REMOVED:
  205. return "ENGINE_CALLBACK_PLUGIN_REMOVED";
  206. case ENGINE_CALLBACK_PLUGIN_RENAMED:
  207. return "ENGINE_CALLBACK_PLUGIN_RENAMED";
  208. case ENGINE_CALLBACK_PLUGIN_UNAVAILABLE:
  209. return "ENGINE_CALLBACK_PLUGIN_UNAVAILABLE";
  210. case ENGINE_CALLBACK_PARAMETER_VALUE_CHANGED:
  211. return "ENGINE_CALLBACK_PARAMETER_VALUE_CHANGED";
  212. case ENGINE_CALLBACK_PARAMETER_DEFAULT_CHANGED:
  213. return "ENGINE_CALLBACK_PARAMETER_DEFAULT_CHANGED";
  214. #ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
  215. case ENGINE_CALLBACK_PARAMETER_MAPPED_CONTROL_INDEX_CHANGED:
  216. return "ENGINE_CALLBACK_PARAMETER_MAPPED_CONTROL_INDEX_CHANGED";
  217. case ENGINE_CALLBACK_PARAMETER_MIDI_CHANNEL_CHANGED:
  218. return "ENGINE_CALLBACK_PARAMETER_MIDI_CHANNEL_CHANGED";
  219. case ENGINE_CALLBACK_OPTION_CHANGED:
  220. return "ENGINE_CALLBACK_OPTION_CHANGED";
  221. #endif
  222. case ENGINE_CALLBACK_PROGRAM_CHANGED:
  223. return "ENGINE_CALLBACK_PROGRAM_CHANGED";
  224. case ENGINE_CALLBACK_MIDI_PROGRAM_CHANGED:
  225. return "ENGINE_CALLBACK_MIDI_PROGRAM_CHANGED";
  226. case ENGINE_CALLBACK_UI_STATE_CHANGED:
  227. return "ENGINE_CALLBACK_UI_STATE_CHANGED";
  228. case ENGINE_CALLBACK_NOTE_ON:
  229. return "ENGINE_CALLBACK_NOTE_ON";
  230. case ENGINE_CALLBACK_NOTE_OFF:
  231. return "ENGINE_CALLBACK_NOTE_OFF";
  232. case ENGINE_CALLBACK_UPDATE:
  233. return "ENGINE_CALLBACK_UPDATE";
  234. case ENGINE_CALLBACK_RELOAD_INFO:
  235. return "ENGINE_CALLBACK_RELOAD_INFO";
  236. case ENGINE_CALLBACK_RELOAD_PARAMETERS:
  237. return "ENGINE_CALLBACK_RELOAD_PARAMETERS";
  238. case ENGINE_CALLBACK_RELOAD_PROGRAMS:
  239. return "ENGINE_CALLBACK_RELOAD_PROGRAMS";
  240. case ENGINE_CALLBACK_RELOAD_ALL:
  241. return "ENGINE_CALLBACK_RELOAD_ALL";
  242. #ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
  243. case ENGINE_CALLBACK_PATCHBAY_CLIENT_ADDED:
  244. return "ENGINE_CALLBACK_PATCHBAY_CLIENT_ADDED";
  245. case ENGINE_CALLBACK_PATCHBAY_CLIENT_REMOVED:
  246. return "ENGINE_CALLBACK_PATCHBAY_CLIENT_REMOVED";
  247. case ENGINE_CALLBACK_PATCHBAY_CLIENT_RENAMED:
  248. return "ENGINE_CALLBACK_PATCHBAY_CLIENT_RENAMED";
  249. case ENGINE_CALLBACK_PATCHBAY_CLIENT_DATA_CHANGED:
  250. return "ENGINE_CALLBACK_PATCHBAY_CLIENT_DATA_CHANGED";
  251. case ENGINE_CALLBACK_PATCHBAY_PORT_ADDED:
  252. return "ENGINE_CALLBACK_PATCHBAY_PORT_ADDED";
  253. case ENGINE_CALLBACK_PATCHBAY_PORT_REMOVED:
  254. return "ENGINE_CALLBACK_PATCHBAY_PORT_REMOVED";
  255. case ENGINE_CALLBACK_PATCHBAY_PORT_CHANGED:
  256. return "ENGINE_CALLBACK_PATCHBAY_PORT_CHANGED";
  257. case ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED:
  258. return "ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED";
  259. case ENGINE_CALLBACK_PATCHBAY_CONNECTION_REMOVED:
  260. return "ENGINE_CALLBACK_PATCHBAY_CONNECTION_REMOVED";
  261. #endif
  262. case ENGINE_CALLBACK_ENGINE_STARTED:
  263. return "ENGINE_CALLBACK_ENGINE_STARTED";
  264. case ENGINE_CALLBACK_ENGINE_STOPPED:
  265. return "ENGINE_CALLBACK_ENGINE_STOPPED";
  266. case ENGINE_CALLBACK_PROCESS_MODE_CHANGED:
  267. return "ENGINE_CALLBACK_PROCESS_MODE_CHANGED";
  268. case ENGINE_CALLBACK_TRANSPORT_MODE_CHANGED:
  269. return "ENGINE_CALLBACK_TRANSPORT_MODE_CHANGED";
  270. case ENGINE_CALLBACK_BUFFER_SIZE_CHANGED:
  271. return "ENGINE_CALLBACK_BUFFER_SIZE_CHANGED";
  272. case ENGINE_CALLBACK_SAMPLE_RATE_CHANGED:
  273. return "ENGINE_CALLBACK_SAMPLE_RATE_CHANGED";
  274. case ENGINE_CALLBACK_CANCELABLE_ACTION:
  275. return "ENGINE_CALLBACK_CANCELABLE_ACTION";
  276. case ENGINE_CALLBACK_PROJECT_LOAD_FINISHED:
  277. return "ENGINE_CALLBACK_PROJECT_LOAD_FINISHED";
  278. case ENGINE_CALLBACK_NSM:
  279. return "ENGINE_CALLBACK_NSM";
  280. case ENGINE_CALLBACK_IDLE:
  281. return "ENGINE_CALLBACK_IDLE";
  282. case ENGINE_CALLBACK_INFO:
  283. return "ENGINE_CALLBACK_INFO";
  284. case ENGINE_CALLBACK_ERROR:
  285. return "ENGINE_CALLBACK_ERROR";
  286. case ENGINE_CALLBACK_QUIT:
  287. return "ENGINE_CALLBACK_QUIT";
  288. case ENGINE_CALLBACK_INLINE_DISPLAY_REDRAW:
  289. return "ENGINE_CALLBACK_INLINE_DISPLAY_REDRAW";
  290. case ENGINE_CALLBACK_PATCHBAY_PORT_GROUP_ADDED:
  291. return "ENGINE_CALLBACK_PATCHBAY_PORT_GROUP_ADDED";
  292. case ENGINE_CALLBACK_PATCHBAY_PORT_GROUP_REMOVED:
  293. return "ENGINE_CALLBACK_PATCHBAY_PORT_GROUP_REMOVED";
  294. case ENGINE_CALLBACK_PATCHBAY_PORT_GROUP_CHANGED:
  295. return "ENGINE_CALLBACK_PATCHBAY_PORT_GROUP_CHANGED";
  296. case ENGINE_CALLBACK_PARAMETER_MAPPED_RANGE_CHANGED:
  297. return "ENGINE_CALLBACK_PARAMETER_MAPPED_RANGE_CHANGED";
  298. case ENGINE_CALLBACK_PATCHBAY_CLIENT_POSITION_CHANGED:
  299. return "ENGINE_CALLBACK_PATCHBAY_CLIENT_POSITION_CHANGED";
  300. }
  301. carla_stderr("CarlaBackend::EngineCallbackOpcode2Str(%i) - invalid opcode", opcode);
  302. return nullptr;
  303. }
  304. static inline
  305. const char* EngineOption2Str(const EngineOption option) noexcept
  306. {
  307. switch (option)
  308. {
  309. case ENGINE_OPTION_DEBUG:
  310. return "ENGINE_OPTION_DEBUG";
  311. case ENGINE_OPTION_PROCESS_MODE:
  312. return "ENGINE_OPTION_PROCESS_MODE";
  313. case ENGINE_OPTION_TRANSPORT_MODE:
  314. return "ENGINE_OPTION_TRANSPORT_MODE";
  315. case ENGINE_OPTION_FORCE_STEREO:
  316. return "ENGINE_OPTION_FORCE_STEREO";
  317. case ENGINE_OPTION_PREFER_PLUGIN_BRIDGES:
  318. return "ENGINE_OPTION_PREFER_PLUGIN_BRIDGES";
  319. case ENGINE_OPTION_PREFER_UI_BRIDGES:
  320. return "ENGINE_OPTION_PREFER_UI_BRIDGES";
  321. case ENGINE_OPTION_UIS_ALWAYS_ON_TOP:
  322. return "ENGINE_OPTION_UIS_ALWAYS_ON_TOP";
  323. case ENGINE_OPTION_MAX_PARAMETERS:
  324. return "ENGINE_OPTION_MAX_PARAMETERS";
  325. case ENGINE_OPTION_RESET_XRUNS:
  326. return "ENGINE_OPTION_RESET_XRUNS";
  327. case ENGINE_OPTION_UI_BRIDGES_TIMEOUT:
  328. return "ENGINE_OPTION_UI_BRIDGES_TIMEOUT";
  329. case ENGINE_OPTION_AUDIO_BUFFER_SIZE:
  330. return "ENGINE_OPTION_AUDIO_BUFFER_SIZE";
  331. case ENGINE_OPTION_AUDIO_SAMPLE_RATE:
  332. return "ENGINE_OPTION_AUDIO_SAMPLE_RATE";
  333. case ENGINE_OPTION_AUDIO_TRIPLE_BUFFER:
  334. return "ENGINE_OPTION_AUDIO_TRIPLE_BUFFER";
  335. case ENGINE_OPTION_AUDIO_DRIVER:
  336. return "ENGINE_OPTION_AUDIO_DRIVER";
  337. case ENGINE_OPTION_AUDIO_DEVICE:
  338. return "ENGINE_OPTION_AUDIO_DEVICE";
  339. case ENGINE_OPTION_OSC_ENABLED:
  340. return "ENGINE_OPTION_OSC_ENABLED";
  341. case ENGINE_OPTION_OSC_PORT_UDP:
  342. return "ENGINE_OPTION_OSC_PORT_UDP";
  343. case ENGINE_OPTION_OSC_PORT_TCP:
  344. return "ENGINE_OPTION_OSC_PORT_TCP";
  345. case ENGINE_OPTION_FILE_PATH:
  346. return "ENGINE_OPTION_FILE_PATH";
  347. case ENGINE_OPTION_PLUGIN_PATH:
  348. return "ENGINE_OPTION_PLUGIN_PATH";
  349. case ENGINE_OPTION_PATH_BINARIES:
  350. return "ENGINE_OPTION_PATH_BINARIES";
  351. case ENGINE_OPTION_PATH_RESOURCES:
  352. return "ENGINE_OPTION_PATH_RESOURCES";
  353. case ENGINE_OPTION_PREVENT_BAD_BEHAVIOUR:
  354. return "ENGINE_OPTION_PREVENT_BAD_BEHAVIOUR";
  355. case ENGINE_OPTION_FRONTEND_BACKGROUND_COLOR:
  356. return "ENGINE_OPTION_FRONTEND_BACKGROUND_COLOR";
  357. case ENGINE_OPTION_FRONTEND_FOREGROUND_COLOR:
  358. return "ENGINE_OPTION_FRONTEND_FOREGROUND_COLOR";
  359. case ENGINE_OPTION_FRONTEND_UI_SCALE:
  360. return "ENGINE_OPTION_FRONTEND_UI_SCALE";
  361. case ENGINE_OPTION_FRONTEND_WIN_ID:
  362. return "ENGINE_OPTION_FRONTEND_WIN_ID";
  363. #if !defined(BUILD_BRIDGE_ALTERNATIVE_ARCH) && !defined(CARLA_OS_WIN)
  364. case ENGINE_OPTION_WINE_EXECUTABLE:
  365. return "ENGINE_OPTION_WINE_EXECUTABLE";
  366. case ENGINE_OPTION_WINE_AUTO_PREFIX:
  367. return "ENGINE_OPTION_WINE_AUTO_PREFIX";
  368. case ENGINE_OPTION_WINE_FALLBACK_PREFIX:
  369. return "ENGINE_OPTION_WINE_FALLBACK_PREFIX";
  370. case ENGINE_OPTION_WINE_RT_PRIO_ENABLED:
  371. return "ENGINE_OPTION_WINE_RT_PRIO_ENABLED";
  372. case ENGINE_OPTION_WINE_BASE_RT_PRIO:
  373. return "ENGINE_OPTION_WINE_BASE_RT_PRIO";
  374. case ENGINE_OPTION_WINE_SERVER_RT_PRIO:
  375. return "ENGINE_OPTION_WINE_SERVER_RT_PRIO";
  376. #endif
  377. case ENGINE_OPTION_DEBUG_CONSOLE_OUTPUT:
  378. return "ENGINE_OPTION_DEBUG_CONSOLE_OUTPUT";
  379. }
  380. carla_stderr("CarlaBackend::EngineOption2Str(%i) - invalid option", option);
  381. return nullptr;
  382. }
  383. static inline
  384. const char* EngineProcessMode2Str(const EngineProcessMode mode) noexcept
  385. {
  386. switch (mode)
  387. {
  388. case ENGINE_PROCESS_MODE_SINGLE_CLIENT:
  389. return "ENGINE_PROCESS_MODE_SINGLE_CLIENT";
  390. case ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS:
  391. return "ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS";
  392. case ENGINE_PROCESS_MODE_CONTINUOUS_RACK:
  393. return "ENGINE_PROCESS_MODE_CONTINUOUS_RACK";
  394. case ENGINE_PROCESS_MODE_PATCHBAY:
  395. return "ENGINE_PROCESS_MODE_PATCHBAY";
  396. case ENGINE_PROCESS_MODE_BRIDGE:
  397. return "ENGINE_PROCESS_MODE_BRIDGE";
  398. }
  399. carla_stderr("CarlaBackend::EngineProcessMode2Str(%i) - invalid mode", mode);
  400. return nullptr;
  401. }
  402. static inline
  403. const char* EngineTransportMode2Str(const EngineTransportMode mode) noexcept
  404. {
  405. switch (mode)
  406. {
  407. case ENGINE_TRANSPORT_MODE_DISABLED:
  408. return "ENGINE_TRANSPORT_MODE_DISABLED";
  409. case ENGINE_TRANSPORT_MODE_INTERNAL:
  410. return "ENGINE_TRANSPORT_MODE_INTERNAL";
  411. case ENGINE_TRANSPORT_MODE_JACK:
  412. return "ENGINE_TRANSPORT_MODE_JACK";
  413. case ENGINE_TRANSPORT_MODE_PLUGIN:
  414. return "ENGINE_TRANSPORT_MODE_PLUGIN";
  415. case ENGINE_TRANSPORT_MODE_BRIDGE:
  416. return "ENGINE_TRANSPORT_MODE_BRIDGE";
  417. }
  418. carla_stderr("CarlaBackend::EngineTransportMode2Str(%i) - invalid mode", mode);
  419. return nullptr;
  420. }
  421. static inline
  422. const char* FileCallbackOpcode2Str(const FileCallbackOpcode opcode) noexcept
  423. {
  424. switch (opcode)
  425. {
  426. case FILE_CALLBACK_DEBUG:
  427. return "FILE_CALLBACK_DEBUG";
  428. case FILE_CALLBACK_OPEN:
  429. return "FILE_CALLBACK_OPEN";
  430. case FILE_CALLBACK_SAVE:
  431. return "FILE_CALLBACK_SAVE";
  432. }
  433. carla_stderr("CarlaBackend::FileCallbackOpcode2Str(%i) - invalid opcode", opcode);
  434. return nullptr;
  435. }
  436. static inline
  437. const char* PatchbayIcon2Str(const PatchbayIcon icon) noexcept
  438. {
  439. switch (icon)
  440. {
  441. case PATCHBAY_ICON_APPLICATION:
  442. return "PATCHBAY_ICON_APPLICATION";
  443. case PATCHBAY_ICON_PLUGIN:
  444. return "PATCHBAY_ICON_PLUGIN";
  445. case PATCHBAY_ICON_HARDWARE:
  446. return "PATCHBAY_ICON_HARDWARE";
  447. case PATCHBAY_ICON_CARLA:
  448. return "PATCHBAY_ICON_CARLA";
  449. case PATCHBAY_ICON_DISTRHO:
  450. return "PATCHBAY_ICON_DISTRHO";
  451. case PATCHBAY_ICON_FILE:
  452. return "PATCHBAY_ICON_FILE";
  453. }
  454. carla_stderr("CarlaBackend::PatchbayIcon2Str(%i) - invalid icon", icon);
  455. return nullptr;
  456. }
  457. // -----------------------------------------------------------------------
  458. static inline
  459. BinaryType getBinaryTypeFromString(const char* const ctype) noexcept
  460. {
  461. CARLA_SAFE_ASSERT_RETURN(ctype != nullptr && ctype[0] != '\0', BINARY_NONE);
  462. carla_debug("CarlaBackend::getBinaryTypeFromString(\"%s\")", ctype);
  463. CarlaString stype(ctype);
  464. if (stype.isEmpty())
  465. return BINARY_NONE;
  466. stype.toLower();
  467. if (stype == "none")
  468. return BINARY_NONE;
  469. if (stype == "native")
  470. return BINARY_NATIVE;
  471. if (stype == "posix32" || stype == "linux32" || stype == "mac32")
  472. return BINARY_POSIX32;
  473. if (stype == "posix64" || stype == "linux64" || stype == "mac64")
  474. return BINARY_POSIX64;
  475. if (stype == "win32")
  476. return BINARY_WIN32;
  477. if (stype == "win64")
  478. return BINARY_WIN64;
  479. carla_stderr("CarlaBackend::getBinaryTypeFromString(\"%s\") - invalid string type", ctype);
  480. return BINARY_NONE;
  481. }
  482. // -----------------------------------------------------------------------
  483. static inline
  484. const char* getPluginCategoryAsString(const PluginCategory category) noexcept
  485. {
  486. carla_debug("CarlaBackend::getPluginCategoryAsString(%i:%s)", category, PluginCategory2Str(category));
  487. switch (category)
  488. {
  489. case PLUGIN_CATEGORY_NONE:
  490. return "none";
  491. case PLUGIN_CATEGORY_SYNTH:
  492. return "synth";
  493. case PLUGIN_CATEGORY_DELAY:
  494. return "delay";
  495. case PLUGIN_CATEGORY_EQ:
  496. return "eq";
  497. case PLUGIN_CATEGORY_FILTER:
  498. return "filter";
  499. case PLUGIN_CATEGORY_DISTORTION:
  500. return "distortion";
  501. case PLUGIN_CATEGORY_DYNAMICS:
  502. return "dynamics";
  503. case PLUGIN_CATEGORY_MODULATOR:
  504. return "modulator";
  505. case PLUGIN_CATEGORY_UTILITY:
  506. return "utility";
  507. case PLUGIN_CATEGORY_OTHER:
  508. return "other";
  509. }
  510. carla_stderr("CarlaBackend::getPluginCategoryAsString(%i) - invalid category", category);
  511. return "NONE";
  512. }
  513. static inline
  514. const char* getPluginTypeAsString(const PluginType type) noexcept
  515. {
  516. carla_debug("CarlaBackend::getPluginTypeAsString(%i:%s)", type, PluginType2Str(type));
  517. switch (type)
  518. {
  519. case PLUGIN_NONE:
  520. return "NONE";
  521. case PLUGIN_INTERNAL:
  522. return "INTERNAL";
  523. case PLUGIN_LADSPA:
  524. return "LADSPA";
  525. case PLUGIN_DSSI:
  526. return "DSSI";
  527. case PLUGIN_LV2:
  528. return "LV2";
  529. case PLUGIN_VST2:
  530. return "VST2";
  531. case PLUGIN_VST3:
  532. return "VST3";
  533. case PLUGIN_AU:
  534. return "AU";
  535. case PLUGIN_DLS:
  536. return "DLS";
  537. case PLUGIN_GIG:
  538. return "GIG";
  539. case PLUGIN_SF2:
  540. return "SF2";
  541. case PLUGIN_SFZ:
  542. return "SFZ";
  543. case PLUGIN_JACK:
  544. return "JACK";
  545. }
  546. carla_stderr("CarlaBackend::getPluginTypeAsString(%i) - invalid type", type);
  547. return "NONE";
  548. }
  549. static inline
  550. PluginType getPluginTypeFromString(const char* const ctype) noexcept
  551. {
  552. CARLA_SAFE_ASSERT_RETURN(ctype != nullptr && ctype[0] != '\0', PLUGIN_NONE);
  553. carla_debug("CarlaBackend::getPluginTypeFromString(\"%s\")", ctype);
  554. CarlaString stype(ctype);
  555. if (stype.isEmpty())
  556. return PLUGIN_NONE;
  557. stype.toLower();
  558. if (stype == "none")
  559. return PLUGIN_NONE;
  560. if (stype == "internal" || stype == "native")
  561. return PLUGIN_INTERNAL;
  562. if (stype == "ladspa")
  563. return PLUGIN_LADSPA;
  564. if (stype == "dssi")
  565. return PLUGIN_DSSI;
  566. if (stype == "lv2")
  567. return PLUGIN_LV2;
  568. if (stype == "vst2" || stype == "vst")
  569. return PLUGIN_VST2;
  570. if (stype == "vst3")
  571. return PLUGIN_VST3;
  572. if (stype == "au" || stype == "audiounit")
  573. return PLUGIN_AU;
  574. if (stype == "dls")
  575. return PLUGIN_DLS;
  576. if (stype == "gig")
  577. return PLUGIN_GIG;
  578. if (stype == "sf2" || stype == "sf3")
  579. return PLUGIN_SF2;
  580. if (stype == "sfz")
  581. return PLUGIN_SFZ;
  582. if (stype == "jack")
  583. return PLUGIN_JACK;
  584. carla_stderr("CarlaBackend::getPluginTypeFromString(\"%s\") - invalid string type", ctype);
  585. return PLUGIN_NONE;
  586. }
  587. // -----------------------------------------------------------------------
  588. static inline
  589. PluginCategory getPluginCategoryFromName(const char* const name) noexcept
  590. {
  591. CARLA_SAFE_ASSERT_RETURN(name != nullptr && name[0] != '\0', PLUGIN_CATEGORY_NONE);
  592. carla_debug("CarlaBackend::getPluginCategoryFromName(\"%s\")", name);
  593. CarlaString sname(name);
  594. if (sname.isEmpty())
  595. return PLUGIN_CATEGORY_NONE;
  596. sname.toLower();
  597. // generic tags first
  598. if (sname.contains("delay"))
  599. return PLUGIN_CATEGORY_DELAY;
  600. if (sname.contains("reverb"))
  601. return PLUGIN_CATEGORY_DELAY;
  602. // filter
  603. if (sname.contains("filter"))
  604. return PLUGIN_CATEGORY_FILTER;
  605. // distortion
  606. if (sname.contains("distortion"))
  607. return PLUGIN_CATEGORY_DISTORTION;
  608. // dynamics
  609. if (sname.contains("dynamics"))
  610. return PLUGIN_CATEGORY_DYNAMICS;
  611. if (sname.contains("amplifier"))
  612. return PLUGIN_CATEGORY_DYNAMICS;
  613. if (sname.contains("compressor"))
  614. return PLUGIN_CATEGORY_DYNAMICS;
  615. if (sname.contains("enhancer"))
  616. return PLUGIN_CATEGORY_DYNAMICS;
  617. if (sname.contains("exciter"))
  618. return PLUGIN_CATEGORY_DYNAMICS;
  619. if (sname.contains("gate"))
  620. return PLUGIN_CATEGORY_DYNAMICS;
  621. if (sname.contains("limiter"))
  622. return PLUGIN_CATEGORY_DYNAMICS;
  623. // modulator
  624. if (sname.contains("modulator"))
  625. return PLUGIN_CATEGORY_MODULATOR;
  626. if (sname.contains("chorus"))
  627. return PLUGIN_CATEGORY_MODULATOR;
  628. if (sname.contains("flanger"))
  629. return PLUGIN_CATEGORY_MODULATOR;
  630. if (sname.contains("phaser"))
  631. return PLUGIN_CATEGORY_MODULATOR;
  632. if (sname.contains("saturator"))
  633. return PLUGIN_CATEGORY_MODULATOR;
  634. // utility
  635. if (sname.contains("utility"))
  636. return PLUGIN_CATEGORY_UTILITY;
  637. if (sname.contains("analyzer"))
  638. return PLUGIN_CATEGORY_UTILITY;
  639. if (sname.contains("converter"))
  640. return PLUGIN_CATEGORY_UTILITY;
  641. if (sname.contains("deesser"))
  642. return PLUGIN_CATEGORY_UTILITY;
  643. if (sname.contains("mixer"))
  644. return PLUGIN_CATEGORY_UTILITY;
  645. // common tags
  646. if (sname.contains("verb"))
  647. return PLUGIN_CATEGORY_DELAY;
  648. if (sname.contains("eq"))
  649. return PLUGIN_CATEGORY_EQ;
  650. if (sname.contains("tool"))
  651. return PLUGIN_CATEGORY_UTILITY;
  652. // synth
  653. if (sname.contains("synth"))
  654. return PLUGIN_CATEGORY_SYNTH;
  655. // other
  656. if (sname.contains("misc"))
  657. return PLUGIN_CATEGORY_OTHER;
  658. if (sname.contains("other"))
  659. return PLUGIN_CATEGORY_OTHER;
  660. return PLUGIN_CATEGORY_NONE;
  661. }
  662. // -----------------------------------------------------------------------
  663. static inline
  664. bool isPluginOptionEnabled(const uint options, const uint option)
  665. {
  666. if (options == PLUGIN_OPTIONS_NULL)
  667. return true;
  668. if (options & option)
  669. return true;
  670. return false;
  671. }
  672. // -----------------------------------------------------------------------
  673. CARLA_BACKEND_END_NAMESPACE
  674. #endif // CARLA_BACKEND_UTILS_HPP_INCLUDED