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.

CarlaBackendUtils.hpp 26KB

11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846
  1. /*
  2. * Carla Backend utils
  3. * Copyright (C) 2011-2023 Filipe Coelho <falktx@falktx.com>
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License as
  7. * published by the Free Software Foundation; either version 2 of
  8. * the License, or any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * For a full copy of the GNU General Public License see the doc/GPL.txt file.
  16. */
  17. #ifndef CARLA_BACKEND_UTILS_HPP_INCLUDED
  18. #define CARLA_BACKEND_UTILS_HPP_INCLUDED
  19. #include "CarlaBackend.h"
  20. #include "CarlaString.hpp"
  21. CARLA_BACKEND_START_NAMESPACE
  22. // -----------------------------------------------------------------------
  23. static inline
  24. const char* PluginOption2Str(const uint option) noexcept
  25. {
  26. switch (option)
  27. {
  28. case PLUGIN_OPTION_FIXED_BUFFERS:
  29. return "PLUGIN_OPTION_FIXED_BUFFERS";
  30. case PLUGIN_OPTION_FORCE_STEREO:
  31. return "PLUGIN_OPTION_FORCE_STEREO";
  32. case PLUGIN_OPTION_MAP_PROGRAM_CHANGES:
  33. return "PLUGIN_OPTION_MAP_PROGRAM_CHANGES";
  34. case PLUGIN_OPTION_USE_CHUNKS:
  35. return "PLUGIN_OPTION_USE_CHUNKS";
  36. case PLUGIN_OPTION_SEND_CONTROL_CHANGES:
  37. return "PLUGIN_OPTION_SEND_CONTROL_CHANGES";
  38. case PLUGIN_OPTION_SEND_CHANNEL_PRESSURE:
  39. return "PLUGIN_OPTION_SEND_CHANNEL_PRESSURE";
  40. case PLUGIN_OPTION_SEND_NOTE_AFTERTOUCH:
  41. return "PLUGIN_OPTION_SEND_NOTE_AFTERTOUCH";
  42. case PLUGIN_OPTION_SEND_PITCHBEND:
  43. return "PLUGIN_OPTION_SEND_PITCHBEND";
  44. case PLUGIN_OPTION_SEND_ALL_SOUND_OFF:
  45. return "PLUGIN_OPTION_SEND_ALL_SOUND_OFF";
  46. }
  47. carla_stderr("CarlaBackend::PluginOption2Str(%i) - invalid option", option);
  48. return 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. const char* getBinaryTypeAsString(const BinaryType type) noexcept
  476. {
  477. carla_debug("CarlaBackend::getBinaryTypeAsString(%i:%s)", type, BinaryType2Str(type));
  478. if (type == BINARY_NATIVE)
  479. return "native";
  480. switch (type)
  481. {
  482. case BINARY_NONE:
  483. return "none";
  484. case BINARY_POSIX32:
  485. return "posix32";
  486. case BINARY_POSIX64:
  487. return "posix64";
  488. case BINARY_WIN32:
  489. return "win32";
  490. case BINARY_WIN64:
  491. return "win64";
  492. case BINARY_OTHER:
  493. return "other";
  494. }
  495. carla_stderr("CarlaBackend::getBinaryTypeAsString(%i) - invalid type", type);
  496. return "NONE";
  497. }
  498. static inline
  499. BinaryType getBinaryTypeFromString(const char* const ctype) noexcept
  500. {
  501. CARLA_SAFE_ASSERT_RETURN(ctype != nullptr && ctype[0] != '\0', BINARY_NONE);
  502. carla_debug("CarlaBackend::getBinaryTypeFromString(\"%s\")", ctype);
  503. CarlaString stype(ctype);
  504. if (stype.isEmpty())
  505. return BINARY_NONE;
  506. stype.toLower();
  507. if (stype == "none")
  508. return BINARY_NONE;
  509. if (stype == "native")
  510. return BINARY_NATIVE;
  511. if (stype == "posix32" || stype == "linux32" || stype == "mac32")
  512. return BINARY_POSIX32;
  513. if (stype == "posix64" || stype == "linux64" || stype == "mac64")
  514. return BINARY_POSIX64;
  515. if (stype == "win32")
  516. return BINARY_WIN32;
  517. if (stype == "win64")
  518. return BINARY_WIN64;
  519. if (stype == "other")
  520. return BINARY_OTHER;
  521. carla_stderr("CarlaBackend::getBinaryTypeFromString(\"%s\") - invalid string type", ctype);
  522. return BINARY_NONE;
  523. }
  524. // -----------------------------------------------------------------------
  525. static inline
  526. const char* getPluginCategoryAsString(const PluginCategory category) noexcept
  527. {
  528. carla_debug("CarlaBackend::getPluginCategoryAsString(%i:%s)", category, PluginCategory2Str(category));
  529. switch (category)
  530. {
  531. case PLUGIN_CATEGORY_NONE:
  532. return "none";
  533. case PLUGIN_CATEGORY_SYNTH:
  534. return "synth";
  535. case PLUGIN_CATEGORY_DELAY:
  536. return "delay";
  537. case PLUGIN_CATEGORY_EQ:
  538. return "eq";
  539. case PLUGIN_CATEGORY_FILTER:
  540. return "filter";
  541. case PLUGIN_CATEGORY_DISTORTION:
  542. return "distortion";
  543. case PLUGIN_CATEGORY_DYNAMICS:
  544. return "dynamics";
  545. case PLUGIN_CATEGORY_MODULATOR:
  546. return "modulator";
  547. case PLUGIN_CATEGORY_UTILITY:
  548. return "utility";
  549. case PLUGIN_CATEGORY_OTHER:
  550. return "other";
  551. }
  552. carla_stderr("CarlaBackend::getPluginCategoryAsString(%i) - invalid category", category);
  553. return "NONE";
  554. }
  555. static inline
  556. PluginCategory getPluginCategoryFromString(const char* const category) noexcept
  557. {
  558. CARLA_SAFE_ASSERT_RETURN(category != nullptr && category[0] != '\0', PLUGIN_CATEGORY_NONE);
  559. carla_debug("CarlaBackend::getPluginCategoryFromString(\"%s\")", category);
  560. if (std::strcmp(category, "none") == 0)
  561. return PLUGIN_CATEGORY_NONE;
  562. if (std::strcmp(category, "synth") == 0)
  563. return PLUGIN_CATEGORY_SYNTH;
  564. if (std::strcmp(category, "delay") == 0)
  565. return PLUGIN_CATEGORY_DELAY;
  566. if (std::strcmp(category, "eq") == 0)
  567. return PLUGIN_CATEGORY_EQ;
  568. if (std::strcmp(category, "filter") == 0)
  569. return PLUGIN_CATEGORY_FILTER;
  570. if (std::strcmp(category, "distortion") == 0)
  571. return PLUGIN_CATEGORY_DISTORTION;
  572. if (std::strcmp(category, "dynamics") == 0)
  573. return PLUGIN_CATEGORY_DYNAMICS;
  574. if (std::strcmp(category, "modulator") == 0)
  575. return PLUGIN_CATEGORY_MODULATOR;
  576. if (std::strcmp(category, "utility") == 0)
  577. return PLUGIN_CATEGORY_UTILITY;
  578. if (std::strcmp(category, "other") == 0)
  579. return PLUGIN_CATEGORY_OTHER;
  580. carla_stderr("CarlaBackend::getPluginCategoryFromString(\"%s\") - invalid category", category);
  581. return PLUGIN_CATEGORY_NONE;
  582. }
  583. // -----------------------------------------------------------------------
  584. static inline
  585. const char* getPluginTypeAsString(const PluginType type) noexcept
  586. {
  587. carla_debug("CarlaBackend::getPluginTypeAsString(%i:%s)", type, PluginType2Str(type));
  588. switch (type)
  589. {
  590. case PLUGIN_NONE:
  591. return "NONE";
  592. case PLUGIN_INTERNAL:
  593. return "INTERNAL";
  594. case PLUGIN_LADSPA:
  595. return "LADSPA";
  596. case PLUGIN_DSSI:
  597. return "DSSI";
  598. case PLUGIN_LV2:
  599. return "LV2";
  600. case PLUGIN_VST2:
  601. return "VST2";
  602. case PLUGIN_VST3:
  603. return "VST3";
  604. case PLUGIN_AU:
  605. return "AU";
  606. case PLUGIN_DLS:
  607. return "DLS";
  608. case PLUGIN_GIG:
  609. return "GIG";
  610. case PLUGIN_SF2:
  611. return "SF2";
  612. case PLUGIN_SFZ:
  613. return "SFZ";
  614. case PLUGIN_JACK:
  615. return "JACK";
  616. case PLUGIN_JSFX:
  617. return "JSFX";
  618. case PLUGIN_CLAP:
  619. return "CLAP";
  620. case PLUGIN_TYPE_COUNT:
  621. break;
  622. }
  623. carla_stderr("CarlaBackend::getPluginTypeAsString(%i) - invalid type", type);
  624. return "NONE";
  625. }
  626. static inline
  627. PluginType getPluginTypeFromString(const char* const ctype) noexcept
  628. {
  629. CARLA_SAFE_ASSERT_RETURN(ctype != nullptr && ctype[0] != '\0', PLUGIN_NONE);
  630. carla_debug("CarlaBackend::getPluginTypeFromString(\"%s\")", ctype);
  631. CarlaString stype(ctype);
  632. if (stype.isEmpty())
  633. return PLUGIN_NONE;
  634. stype.toLower();
  635. if (stype == "none")
  636. return PLUGIN_NONE;
  637. if (stype == "internal" || stype == "native")
  638. return PLUGIN_INTERNAL;
  639. if (stype == "ladspa")
  640. return PLUGIN_LADSPA;
  641. if (stype == "dssi")
  642. return PLUGIN_DSSI;
  643. if (stype == "lv2")
  644. return PLUGIN_LV2;
  645. if (stype == "vst2" || stype == "vst")
  646. return PLUGIN_VST2;
  647. if (stype == "vst3")
  648. return PLUGIN_VST3;
  649. if (stype == "au" || stype == "audiounit")
  650. return PLUGIN_AU;
  651. if (stype == "dls")
  652. return PLUGIN_DLS;
  653. if (stype == "gig")
  654. return PLUGIN_GIG;
  655. if (stype == "sf2" || stype == "sf3")
  656. return PLUGIN_SF2;
  657. if (stype == "sfz")
  658. return PLUGIN_SFZ;
  659. if (stype == "jack")
  660. return PLUGIN_JACK;
  661. if (stype == "jsfx")
  662. return PLUGIN_JSFX;
  663. if (stype == "clap")
  664. return PLUGIN_CLAP;
  665. carla_stderr("CarlaBackend::getPluginTypeFromString(\"%s\") - invalid string type", ctype);
  666. return PLUGIN_NONE;
  667. }
  668. // -----------------------------------------------------------------------
  669. static inline
  670. PluginCategory getPluginCategoryFromName(const char* const name) noexcept
  671. {
  672. CARLA_SAFE_ASSERT_RETURN(name != nullptr && name[0] != '\0', PLUGIN_CATEGORY_NONE);
  673. carla_debug("CarlaBackend::getPluginCategoryFromName(\"%s\")", name);
  674. CarlaString sname(name);
  675. if (sname.isEmpty())
  676. return PLUGIN_CATEGORY_NONE;
  677. sname.toLower();
  678. // generic tags first
  679. if (sname.contains("delay"))
  680. return PLUGIN_CATEGORY_DELAY;
  681. if (sname.contains("reverb"))
  682. return PLUGIN_CATEGORY_DELAY;
  683. // filter
  684. if (sname.contains("filter"))
  685. return PLUGIN_CATEGORY_FILTER;
  686. // distortion
  687. if (sname.contains("distortion"))
  688. return PLUGIN_CATEGORY_DISTORTION;
  689. // dynamics
  690. if (sname.contains("dynamics"))
  691. return PLUGIN_CATEGORY_DYNAMICS;
  692. if (sname.contains("amplifier"))
  693. return PLUGIN_CATEGORY_DYNAMICS;
  694. if (sname.contains("compressor"))
  695. return PLUGIN_CATEGORY_DYNAMICS;
  696. if (sname.contains("enhancer"))
  697. return PLUGIN_CATEGORY_DYNAMICS;
  698. if (sname.contains("exciter"))
  699. return PLUGIN_CATEGORY_DYNAMICS;
  700. if (sname.contains("gate"))
  701. return PLUGIN_CATEGORY_DYNAMICS;
  702. if (sname.contains("limiter"))
  703. return PLUGIN_CATEGORY_DYNAMICS;
  704. // modulator
  705. if (sname.contains("modulator"))
  706. return PLUGIN_CATEGORY_MODULATOR;
  707. if (sname.contains("chorus"))
  708. return PLUGIN_CATEGORY_MODULATOR;
  709. if (sname.contains("flanger"))
  710. return PLUGIN_CATEGORY_MODULATOR;
  711. if (sname.contains("phaser"))
  712. return PLUGIN_CATEGORY_MODULATOR;
  713. if (sname.contains("saturator"))
  714. return PLUGIN_CATEGORY_MODULATOR;
  715. // utility
  716. if (sname.contains("utility"))
  717. return PLUGIN_CATEGORY_UTILITY;
  718. if (sname.contains("analyzer"))
  719. return PLUGIN_CATEGORY_UTILITY;
  720. if (sname.contains("converter"))
  721. return PLUGIN_CATEGORY_UTILITY;
  722. if (sname.contains("deesser"))
  723. return PLUGIN_CATEGORY_UTILITY;
  724. if (sname.contains("mixer"))
  725. return PLUGIN_CATEGORY_UTILITY;
  726. // common tags
  727. if (sname.contains("verb"))
  728. return PLUGIN_CATEGORY_DELAY;
  729. if (sname.contains("eq"))
  730. return PLUGIN_CATEGORY_EQ;
  731. if (sname.contains("tool"))
  732. return PLUGIN_CATEGORY_UTILITY;
  733. // synth
  734. if (sname.contains("synth"))
  735. return PLUGIN_CATEGORY_SYNTH;
  736. // other
  737. if (sname.contains("misc"))
  738. return PLUGIN_CATEGORY_OTHER;
  739. if (sname.contains("other"))
  740. return PLUGIN_CATEGORY_OTHER;
  741. return PLUGIN_CATEGORY_NONE;
  742. }
  743. // -----------------------------------------------------------------------
  744. static inline
  745. bool isPluginOptionEnabled(const uint options, const uint option)
  746. {
  747. if (options == PLUGIN_OPTIONS_NULL)
  748. return true;
  749. if (options & option)
  750. return true;
  751. return false;
  752. }
  753. static inline
  754. bool isPluginOptionInverseEnabled(const uint options, const uint option)
  755. {
  756. if (options == PLUGIN_OPTIONS_NULL)
  757. return false;
  758. if (options & option)
  759. return true;
  760. return false;
  761. }
  762. // -----------------------------------------------------------------------
  763. CARLA_BACKEND_END_NAMESPACE
  764. #endif // CARLA_BACKEND_UTILS_HPP_INCLUDED