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.

703 lines
22KB

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