Fix last commit
[carla.git] / source / utils / CarlaBackendUtils.hpp
blob690761cc09ff6a696dd058d89df34eb0f56c755a
1 /*
2 * Carla Backend utils
3 * Copyright (C) 2011-2023 Filipe Coelho <falktx@falktx.com>
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.
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.
15 * For a full copy of the GNU General Public License see the doc/GPL.txt file.
18 #ifndef CARLA_BACKEND_UTILS_HPP_INCLUDED
19 #define CARLA_BACKEND_UTILS_HPP_INCLUDED
21 #include "CarlaBackend.h"
22 #include "CarlaString.hpp"
24 CARLA_BACKEND_START_NAMESPACE
26 // -----------------------------------------------------------------------
28 static inline
29 const char* PluginOption2Str(const uint option) noexcept
31 switch (option)
33 case PLUGIN_OPTION_FIXED_BUFFERS:
34 return "PLUGIN_OPTION_FIXED_BUFFERS";
35 case PLUGIN_OPTION_FORCE_STEREO:
36 return "PLUGIN_OPTION_FORCE_STEREO";
37 case PLUGIN_OPTION_MAP_PROGRAM_CHANGES:
38 return "PLUGIN_OPTION_MAP_PROGRAM_CHANGES";
39 case PLUGIN_OPTION_USE_CHUNKS:
40 return "PLUGIN_OPTION_USE_CHUNKS";
41 case PLUGIN_OPTION_SEND_CONTROL_CHANGES:
42 return "PLUGIN_OPTION_SEND_CONTROL_CHANGES";
43 case PLUGIN_OPTION_SEND_CHANNEL_PRESSURE:
44 return "PLUGIN_OPTION_SEND_CHANNEL_PRESSURE";
45 case PLUGIN_OPTION_SEND_NOTE_AFTERTOUCH:
46 return "PLUGIN_OPTION_SEND_NOTE_AFTERTOUCH";
47 case PLUGIN_OPTION_SEND_PITCHBEND:
48 return "PLUGIN_OPTION_SEND_PITCHBEND";
49 case PLUGIN_OPTION_SEND_ALL_SOUND_OFF:
50 return "PLUGIN_OPTION_SEND_ALL_SOUND_OFF";
53 carla_stderr("CarlaBackend::PluginOption2Str(%i) - invalid option", option);
54 return "";
57 // -----------------------------------------------------------------------
59 static inline
60 const char* BinaryType2Str(const BinaryType type) noexcept
62 switch (type)
64 case BINARY_NONE:
65 return "BINARY_NONE";
66 case BINARY_POSIX32:
67 return "BINARY_POSIX32";
68 case BINARY_POSIX64:
69 return "BINARY_POSIX64";
70 case BINARY_WIN32:
71 return "BINARY_WIN32";
72 case BINARY_WIN64:
73 return "BINARY_WIN64";
74 case BINARY_OTHER:
75 return "BINARY_OTHER";
78 carla_stderr("CarlaBackend::BinaryType2Str(%i) - invalid type", type);
79 return "";
82 static inline
83 const char* FileType2Str(const FileType type) noexcept
85 switch (type)
87 case FILE_NONE:
88 return "FILE_NONE";
89 case FILE_AUDIO:
90 return "FILE_AUDIO";
91 case FILE_MIDI:
92 return "FILE_MIDI";
95 carla_stderr("CarlaBackend::FileType2Str(%i) - invalid type", type);
96 return "";
99 static inline
100 const char* PluginType2Str(const PluginType type) noexcept
102 switch (type)
104 case PLUGIN_NONE:
105 return "PLUGIN_NONE";
106 case PLUGIN_INTERNAL:
107 return "PLUGIN_INTERNAL";
108 case PLUGIN_LADSPA:
109 return "PLUGIN_LADSPA";
110 case PLUGIN_DSSI:
111 return "PLUGIN_DSSI";
112 case PLUGIN_LV2:
113 return "PLUGIN_LV2";
114 case PLUGIN_VST2:
115 return "PLUGIN_VST2";
116 case PLUGIN_VST3:
117 return "PLUGIN_VST3";
118 case PLUGIN_AU:
119 return "PLUGIN_AU";
120 case PLUGIN_DLS:
121 return "PLUGIN_DLS";
122 case PLUGIN_GIG:
123 return "PLUGIN_GIG";
124 case PLUGIN_SF2:
125 return "PLUGIN_SF2";
126 case PLUGIN_SFZ:
127 return "PLUGIN_SFZ";
128 case PLUGIN_JACK:
129 return "PLUGIN_JACK";
130 case PLUGIN_JSFX:
131 return "PLUGIN_JSFX";
132 case PLUGIN_CLAP:
133 return "PLUGIN_CLAP";
134 case PLUGIN_TYPE_COUNT:
135 break;
138 carla_stderr("CarlaBackend::PluginType2Str(%i) - invalid type", type);
139 return "";
142 static inline
143 const char* PluginCategory2Str(const PluginCategory category) noexcept
145 switch (category)
147 case PLUGIN_CATEGORY_NONE:
148 return "PLUGIN_CATEGORY_NONE";
149 case PLUGIN_CATEGORY_SYNTH:
150 return "PLUGIN_CATEGORY_SYNTH";
151 case PLUGIN_CATEGORY_DELAY:
152 return "PLUGIN_CATEGORY_DELAY";
153 case PLUGIN_CATEGORY_EQ:
154 return "PLUGIN_CATEGORY_EQ";
155 case PLUGIN_CATEGORY_FILTER:
156 return "PLUGIN_CATEGORY_FILTER";
157 case PLUGIN_CATEGORY_DISTORTION:
158 return "PLUGIN_CATEGORY_DISTORTION";
159 case PLUGIN_CATEGORY_DYNAMICS:
160 return "PLUGIN_CATEGORY_DYNAMICS";
161 case PLUGIN_CATEGORY_MODULATOR:
162 return "PLUGIN_CATEGORY_MODULATOR";
163 case PLUGIN_CATEGORY_UTILITY:
164 return "PLUGIN_CATEGORY_UTILITY";
165 case PLUGIN_CATEGORY_OTHER:
166 return "PLUGIN_CATEGORY_OTHER";
169 carla_stderr("CarlaBackend::PluginCategory2Str(%i) - invalid category", category);
170 return "";
173 static inline
174 const char* ParameterType2Str(const ParameterType type) noexcept
176 switch (type)
178 case PARAMETER_UNKNOWN:
179 return "PARAMETER_UNKNOWN";
180 case PARAMETER_INPUT:
181 return "PARAMETER_INPUT";
182 case PARAMETER_OUTPUT:
183 return "PARAMETER_OUTPUT";
186 carla_stderr("CarlaBackend::ParameterType2Str(%i) - invalid type", type);
187 return "";
190 static inline
191 const char* InternalParameterIndex2Str(const InternalParameterIndex index) noexcept
193 switch (index)
195 case PARAMETER_NULL:
196 return "PARAMETER_NULL";
197 #ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
198 case PARAMETER_ACTIVE:
199 return "PARAMETER_ACTIVE";
200 case PARAMETER_DRYWET:
201 return "PARAMETER_DRYWET";
202 case PARAMETER_VOLUME:
203 return "PARAMETER_VOLUME";
204 case PARAMETER_BALANCE_LEFT:
205 return "PARAMETER_BALANCE_LEFT";
206 case PARAMETER_BALANCE_RIGHT:
207 return "PARAMETER_BALANCE_RIGHT";
208 case PARAMETER_PANNING:
209 return "PARAMETER_PANNING";
210 case PARAMETER_CTRL_CHANNEL:
211 return "PARAMETER_CTRL_CHANNEL";
212 #endif
213 case PARAMETER_MAX:
214 return "PARAMETER_MAX";
217 carla_stderr("CarlaBackend::InternalParameterIndex2Str(%i) - invalid index", index);
218 return "";
221 static inline
222 const char* EngineCallbackOpcode2Str(const EngineCallbackOpcode opcode) noexcept
224 switch (opcode)
226 case ENGINE_CALLBACK_DEBUG:
227 return "ENGINE_CALLBACK_DEBUG";
228 case ENGINE_CALLBACK_PLUGIN_ADDED:
229 return "ENGINE_CALLBACK_PLUGIN_ADDED";
230 case ENGINE_CALLBACK_PLUGIN_REMOVED:
231 return "ENGINE_CALLBACK_PLUGIN_REMOVED";
232 case ENGINE_CALLBACK_PLUGIN_RENAMED:
233 return "ENGINE_CALLBACK_PLUGIN_RENAMED";
234 case ENGINE_CALLBACK_PLUGIN_UNAVAILABLE:
235 return "ENGINE_CALLBACK_PLUGIN_UNAVAILABLE";
236 case ENGINE_CALLBACK_PARAMETER_VALUE_CHANGED:
237 return "ENGINE_CALLBACK_PARAMETER_VALUE_CHANGED";
238 case ENGINE_CALLBACK_PARAMETER_DEFAULT_CHANGED:
239 return "ENGINE_CALLBACK_PARAMETER_DEFAULT_CHANGED";
240 #ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
241 case ENGINE_CALLBACK_PARAMETER_MAPPED_CONTROL_INDEX_CHANGED:
242 return "ENGINE_CALLBACK_PARAMETER_MAPPED_CONTROL_INDEX_CHANGED";
243 case ENGINE_CALLBACK_PARAMETER_MIDI_CHANNEL_CHANGED:
244 return "ENGINE_CALLBACK_PARAMETER_MIDI_CHANNEL_CHANGED";
245 case ENGINE_CALLBACK_OPTION_CHANGED:
246 return "ENGINE_CALLBACK_OPTION_CHANGED";
247 #endif
248 case ENGINE_CALLBACK_PROGRAM_CHANGED:
249 return "ENGINE_CALLBACK_PROGRAM_CHANGED";
250 case ENGINE_CALLBACK_MIDI_PROGRAM_CHANGED:
251 return "ENGINE_CALLBACK_MIDI_PROGRAM_CHANGED";
252 case ENGINE_CALLBACK_UI_STATE_CHANGED:
253 return "ENGINE_CALLBACK_UI_STATE_CHANGED";
254 case ENGINE_CALLBACK_NOTE_ON:
255 return "ENGINE_CALLBACK_NOTE_ON";
256 case ENGINE_CALLBACK_NOTE_OFF:
257 return "ENGINE_CALLBACK_NOTE_OFF";
258 case ENGINE_CALLBACK_UPDATE:
259 return "ENGINE_CALLBACK_UPDATE";
260 case ENGINE_CALLBACK_RELOAD_INFO:
261 return "ENGINE_CALLBACK_RELOAD_INFO";
262 case ENGINE_CALLBACK_RELOAD_PARAMETERS:
263 return "ENGINE_CALLBACK_RELOAD_PARAMETERS";
264 case ENGINE_CALLBACK_RELOAD_PROGRAMS:
265 return "ENGINE_CALLBACK_RELOAD_PROGRAMS";
266 case ENGINE_CALLBACK_RELOAD_ALL:
267 return "ENGINE_CALLBACK_RELOAD_ALL";
268 #ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
269 case ENGINE_CALLBACK_PATCHBAY_CLIENT_ADDED:
270 return "ENGINE_CALLBACK_PATCHBAY_CLIENT_ADDED";
271 case ENGINE_CALLBACK_PATCHBAY_CLIENT_REMOVED:
272 return "ENGINE_CALLBACK_PATCHBAY_CLIENT_REMOVED";
273 case ENGINE_CALLBACK_PATCHBAY_CLIENT_RENAMED:
274 return "ENGINE_CALLBACK_PATCHBAY_CLIENT_RENAMED";
275 case ENGINE_CALLBACK_PATCHBAY_CLIENT_DATA_CHANGED:
276 return "ENGINE_CALLBACK_PATCHBAY_CLIENT_DATA_CHANGED";
277 case ENGINE_CALLBACK_PATCHBAY_PORT_ADDED:
278 return "ENGINE_CALLBACK_PATCHBAY_PORT_ADDED";
279 case ENGINE_CALLBACK_PATCHBAY_PORT_REMOVED:
280 return "ENGINE_CALLBACK_PATCHBAY_PORT_REMOVED";
281 case ENGINE_CALLBACK_PATCHBAY_PORT_CHANGED:
282 return "ENGINE_CALLBACK_PATCHBAY_PORT_CHANGED";
283 case ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED:
284 return "ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED";
285 case ENGINE_CALLBACK_PATCHBAY_CONNECTION_REMOVED:
286 return "ENGINE_CALLBACK_PATCHBAY_CONNECTION_REMOVED";
287 #endif
288 case ENGINE_CALLBACK_ENGINE_STARTED:
289 return "ENGINE_CALLBACK_ENGINE_STARTED";
290 case ENGINE_CALLBACK_ENGINE_STOPPED:
291 return "ENGINE_CALLBACK_ENGINE_STOPPED";
292 case ENGINE_CALLBACK_PROCESS_MODE_CHANGED:
293 return "ENGINE_CALLBACK_PROCESS_MODE_CHANGED";
294 case ENGINE_CALLBACK_TRANSPORT_MODE_CHANGED:
295 return "ENGINE_CALLBACK_TRANSPORT_MODE_CHANGED";
296 case ENGINE_CALLBACK_BUFFER_SIZE_CHANGED:
297 return "ENGINE_CALLBACK_BUFFER_SIZE_CHANGED";
298 case ENGINE_CALLBACK_SAMPLE_RATE_CHANGED:
299 return "ENGINE_CALLBACK_SAMPLE_RATE_CHANGED";
300 case ENGINE_CALLBACK_CANCELABLE_ACTION:
301 return "ENGINE_CALLBACK_CANCELABLE_ACTION";
302 case ENGINE_CALLBACK_PROJECT_LOAD_FINISHED:
303 return "ENGINE_CALLBACK_PROJECT_LOAD_FINISHED";
304 case ENGINE_CALLBACK_NSM:
305 return "ENGINE_CALLBACK_NSM";
306 case ENGINE_CALLBACK_IDLE:
307 return "ENGINE_CALLBACK_IDLE";
308 case ENGINE_CALLBACK_INFO:
309 return "ENGINE_CALLBACK_INFO";
310 case ENGINE_CALLBACK_ERROR:
311 return "ENGINE_CALLBACK_ERROR";
312 case ENGINE_CALLBACK_QUIT:
313 return "ENGINE_CALLBACK_QUIT";
314 case ENGINE_CALLBACK_INLINE_DISPLAY_REDRAW:
315 return "ENGINE_CALLBACK_INLINE_DISPLAY_REDRAW";
316 case ENGINE_CALLBACK_PATCHBAY_PORT_GROUP_ADDED:
317 return "ENGINE_CALLBACK_PATCHBAY_PORT_GROUP_ADDED";
318 case ENGINE_CALLBACK_PATCHBAY_PORT_GROUP_REMOVED:
319 return "ENGINE_CALLBACK_PATCHBAY_PORT_GROUP_REMOVED";
320 case ENGINE_CALLBACK_PATCHBAY_PORT_GROUP_CHANGED:
321 return "ENGINE_CALLBACK_PATCHBAY_PORT_GROUP_CHANGED";
322 case ENGINE_CALLBACK_PARAMETER_MAPPED_RANGE_CHANGED:
323 return "ENGINE_CALLBACK_PARAMETER_MAPPED_RANGE_CHANGED";
324 case ENGINE_CALLBACK_PATCHBAY_CLIENT_POSITION_CHANGED:
325 return "ENGINE_CALLBACK_PATCHBAY_CLIENT_POSITION_CHANGED";
326 case ENGINE_CALLBACK_EMBED_UI_RESIZED:
327 return "ENGINE_CALLBACK_EMBED_UI_RESIZED";
330 carla_stderr("CarlaBackend::EngineCallbackOpcode2Str(%i) - invalid opcode", opcode);
331 return "";
334 static inline
335 const char* EngineOption2Str(const EngineOption option) noexcept
337 switch (option)
339 case ENGINE_OPTION_DEBUG:
340 return "ENGINE_OPTION_DEBUG";
341 case ENGINE_OPTION_PROCESS_MODE:
342 return "ENGINE_OPTION_PROCESS_MODE";
343 case ENGINE_OPTION_TRANSPORT_MODE:
344 return "ENGINE_OPTION_TRANSPORT_MODE";
345 case ENGINE_OPTION_FORCE_STEREO:
346 return "ENGINE_OPTION_FORCE_STEREO";
347 case ENGINE_OPTION_PREFER_PLUGIN_BRIDGES:
348 return "ENGINE_OPTION_PREFER_PLUGIN_BRIDGES";
349 case ENGINE_OPTION_PREFER_UI_BRIDGES:
350 return "ENGINE_OPTION_PREFER_UI_BRIDGES";
351 case ENGINE_OPTION_UIS_ALWAYS_ON_TOP:
352 return "ENGINE_OPTION_UIS_ALWAYS_ON_TOP";
353 case ENGINE_OPTION_MAX_PARAMETERS:
354 return "ENGINE_OPTION_MAX_PARAMETERS";
355 case ENGINE_OPTION_RESET_XRUNS:
356 return "ENGINE_OPTION_RESET_XRUNS";
357 case ENGINE_OPTION_UI_BRIDGES_TIMEOUT:
358 return "ENGINE_OPTION_UI_BRIDGES_TIMEOUT";
359 case ENGINE_OPTION_AUDIO_BUFFER_SIZE:
360 return "ENGINE_OPTION_AUDIO_BUFFER_SIZE";
361 case ENGINE_OPTION_AUDIO_SAMPLE_RATE:
362 return "ENGINE_OPTION_AUDIO_SAMPLE_RATE";
363 case ENGINE_OPTION_AUDIO_TRIPLE_BUFFER:
364 return "ENGINE_OPTION_AUDIO_TRIPLE_BUFFER";
365 case ENGINE_OPTION_AUDIO_DRIVER:
366 return "ENGINE_OPTION_AUDIO_DRIVER";
367 case ENGINE_OPTION_AUDIO_DEVICE:
368 return "ENGINE_OPTION_AUDIO_DEVICE";
369 #ifndef BUILD_BRIDGE
370 case ENGINE_OPTION_OSC_ENABLED:
371 return "ENGINE_OPTION_OSC_ENABLED";
372 case ENGINE_OPTION_OSC_PORT_UDP:
373 return "ENGINE_OPTION_OSC_PORT_UDP";
374 case ENGINE_OPTION_OSC_PORT_TCP:
375 return "ENGINE_OPTION_OSC_PORT_TCP";
376 #endif
377 case ENGINE_OPTION_FILE_PATH:
378 return "ENGINE_OPTION_FILE_PATH";
379 case ENGINE_OPTION_PLUGIN_PATH:
380 return "ENGINE_OPTION_PLUGIN_PATH";
381 case ENGINE_OPTION_PATH_BINARIES:
382 return "ENGINE_OPTION_PATH_BINARIES";
383 case ENGINE_OPTION_PATH_RESOURCES:
384 return "ENGINE_OPTION_PATH_RESOURCES";
385 case ENGINE_OPTION_PREVENT_BAD_BEHAVIOUR:
386 return "ENGINE_OPTION_PREVENT_BAD_BEHAVIOUR";
387 case ENGINE_OPTION_FRONTEND_BACKGROUND_COLOR:
388 return "ENGINE_OPTION_FRONTEND_BACKGROUND_COLOR";
389 case ENGINE_OPTION_FRONTEND_FOREGROUND_COLOR:
390 return "ENGINE_OPTION_FRONTEND_FOREGROUND_COLOR";
391 case ENGINE_OPTION_FRONTEND_UI_SCALE:
392 return "ENGINE_OPTION_FRONTEND_UI_SCALE";
393 case ENGINE_OPTION_FRONTEND_WIN_ID:
394 return "ENGINE_OPTION_FRONTEND_WIN_ID";
395 #if !defined(BUILD_BRIDGE_ALTERNATIVE_ARCH) && !defined(CARLA_OS_WIN)
396 case ENGINE_OPTION_WINE_EXECUTABLE:
397 return "ENGINE_OPTION_WINE_EXECUTABLE";
398 case ENGINE_OPTION_WINE_AUTO_PREFIX:
399 return "ENGINE_OPTION_WINE_AUTO_PREFIX";
400 case ENGINE_OPTION_WINE_FALLBACK_PREFIX:
401 return "ENGINE_OPTION_WINE_FALLBACK_PREFIX";
402 case ENGINE_OPTION_WINE_RT_PRIO_ENABLED:
403 return "ENGINE_OPTION_WINE_RT_PRIO_ENABLED";
404 case ENGINE_OPTION_WINE_BASE_RT_PRIO:
405 return "ENGINE_OPTION_WINE_BASE_RT_PRIO";
406 case ENGINE_OPTION_WINE_SERVER_RT_PRIO:
407 return "ENGINE_OPTION_WINE_SERVER_RT_PRIO";
408 #endif
409 #ifndef BUILD_BRIDGE
410 case ENGINE_OPTION_DEBUG_CONSOLE_OUTPUT:
411 return "ENGINE_OPTION_DEBUG_CONSOLE_OUTPUT";
412 #endif
413 case ENGINE_OPTION_CLIENT_NAME_PREFIX:
414 return "ENGINE_OPTION_CLIENT_NAME_PREFIX";
415 case ENGINE_OPTION_PLUGINS_ARE_STANDALONE:
416 return "ENGINE_OPTION_PLUGINS_ARE_STANDALONE";
419 carla_stderr("CarlaBackend::EngineOption2Str(%i) - invalid option", option);
420 return "";
423 static inline
424 const char* EngineProcessMode2Str(const EngineProcessMode mode) noexcept
426 switch (mode)
428 case ENGINE_PROCESS_MODE_SINGLE_CLIENT:
429 return "ENGINE_PROCESS_MODE_SINGLE_CLIENT";
430 case ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS:
431 return "ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS";
432 case ENGINE_PROCESS_MODE_CONTINUOUS_RACK:
433 return "ENGINE_PROCESS_MODE_CONTINUOUS_RACK";
434 case ENGINE_PROCESS_MODE_PATCHBAY:
435 return "ENGINE_PROCESS_MODE_PATCHBAY";
436 case ENGINE_PROCESS_MODE_BRIDGE:
437 return "ENGINE_PROCESS_MODE_BRIDGE";
440 carla_stderr("CarlaBackend::EngineProcessMode2Str(%i) - invalid mode", mode);
441 return "";
444 static inline
445 const char* EngineTransportMode2Str(const EngineTransportMode mode) noexcept
447 switch (mode)
449 case ENGINE_TRANSPORT_MODE_DISABLED:
450 return "ENGINE_TRANSPORT_MODE_DISABLED";
451 case ENGINE_TRANSPORT_MODE_INTERNAL:
452 return "ENGINE_TRANSPORT_MODE_INTERNAL";
453 case ENGINE_TRANSPORT_MODE_JACK:
454 return "ENGINE_TRANSPORT_MODE_JACK";
455 case ENGINE_TRANSPORT_MODE_PLUGIN:
456 return "ENGINE_TRANSPORT_MODE_PLUGIN";
457 case ENGINE_TRANSPORT_MODE_BRIDGE:
458 return "ENGINE_TRANSPORT_MODE_BRIDGE";
461 carla_stderr("CarlaBackend::EngineTransportMode2Str(%i) - invalid mode", mode);
462 return "";
465 static inline
466 const char* FileCallbackOpcode2Str(const FileCallbackOpcode opcode) noexcept
468 switch (opcode)
470 case FILE_CALLBACK_DEBUG:
471 return "FILE_CALLBACK_DEBUG";
472 case FILE_CALLBACK_OPEN:
473 return "FILE_CALLBACK_OPEN";
474 case FILE_CALLBACK_SAVE:
475 return "FILE_CALLBACK_SAVE";
478 carla_stderr("CarlaBackend::FileCallbackOpcode2Str(%i) - invalid opcode", opcode);
479 return "";
482 static inline
483 const char* PatchbayIcon2Str(const PatchbayIcon icon) noexcept
485 switch (icon)
487 case PATCHBAY_ICON_APPLICATION:
488 return "PATCHBAY_ICON_APPLICATION";
489 case PATCHBAY_ICON_PLUGIN:
490 return "PATCHBAY_ICON_PLUGIN";
491 case PATCHBAY_ICON_HARDWARE:
492 return "PATCHBAY_ICON_HARDWARE";
493 case PATCHBAY_ICON_CARLA:
494 return "PATCHBAY_ICON_CARLA";
495 case PATCHBAY_ICON_DISTRHO:
496 return "PATCHBAY_ICON_DISTRHO";
497 case PATCHBAY_ICON_FILE:
498 return "PATCHBAY_ICON_FILE";
501 carla_stderr("CarlaBackend::PatchbayIcon2Str(%i) - invalid icon", icon);
502 return "";
505 // -----------------------------------------------------------------------
507 static inline
508 const char* getBinaryTypeAsString(const BinaryType type) noexcept
510 carla_debug("CarlaBackend::getBinaryTypeAsString(%i:%s)", type, BinaryType2Str(type));
512 if (type == BINARY_NATIVE)
513 return "native";
515 switch (type)
517 case BINARY_NONE:
518 return "none";
519 case BINARY_POSIX32:
520 return "posix32";
521 case BINARY_POSIX64:
522 return "posix64";
523 case BINARY_WIN32:
524 return "win32";
525 case BINARY_WIN64:
526 return "win64";
527 case BINARY_OTHER:
528 return "other";
531 carla_stderr("CarlaBackend::getBinaryTypeAsString(%i) - invalid type", type);
532 return "NONE";
535 static inline
536 BinaryType getBinaryTypeFromString(const char* const ctype) noexcept
538 CARLA_SAFE_ASSERT_RETURN(ctype != nullptr && ctype[0] != '\0', BINARY_NONE);
539 carla_debug("CarlaBackend::getBinaryTypeFromString(\"%s\")", ctype);
541 CarlaString stype(ctype);
543 if (stype.isEmpty())
544 return BINARY_NONE;
546 stype.toLower();
548 if (stype == "none")
549 return BINARY_NONE;
550 if (stype == "native")
551 return BINARY_NATIVE;
552 if (stype == "posix32" || stype == "linux32" || stype == "mac32")
553 return BINARY_POSIX32;
554 if (stype == "posix64" || stype == "linux64" || stype == "mac64")
555 return BINARY_POSIX64;
556 if (stype == "win32")
557 return BINARY_WIN32;
558 if (stype == "win64")
559 return BINARY_WIN64;
560 if (stype == "other")
561 return BINARY_OTHER;
563 carla_stderr("CarlaBackend::getBinaryTypeFromString(\"%s\") - invalid string type", ctype);
564 return BINARY_NONE;
567 // -----------------------------------------------------------------------
569 static inline
570 const char* getPluginCategoryAsString(const PluginCategory category) noexcept
572 carla_debug("CarlaBackend::getPluginCategoryAsString(%i:%s)", category, PluginCategory2Str(category));
574 switch (category)
576 case PLUGIN_CATEGORY_NONE:
577 return "none";
578 case PLUGIN_CATEGORY_SYNTH:
579 return "synth";
580 case PLUGIN_CATEGORY_DELAY:
581 return "delay";
582 case PLUGIN_CATEGORY_EQ:
583 return "eq";
584 case PLUGIN_CATEGORY_FILTER:
585 return "filter";
586 case PLUGIN_CATEGORY_DISTORTION:
587 return "distortion";
588 case PLUGIN_CATEGORY_DYNAMICS:
589 return "dynamics";
590 case PLUGIN_CATEGORY_MODULATOR:
591 return "modulator";
592 case PLUGIN_CATEGORY_UTILITY:
593 return "utility";
594 case PLUGIN_CATEGORY_OTHER:
595 return "other";
598 carla_stderr("CarlaBackend::getPluginCategoryAsString(%i) - invalid category", category);
599 return "NONE";
602 static inline
603 PluginCategory getPluginCategoryFromString(const char* const category) noexcept
605 CARLA_SAFE_ASSERT_RETURN(category != nullptr && category[0] != '\0', PLUGIN_CATEGORY_NONE);
606 carla_debug("CarlaBackend::getPluginCategoryFromString(\"%s\")", category);
608 if (std::strcmp(category, "none") == 0)
609 return PLUGIN_CATEGORY_NONE;
610 if (std::strcmp(category, "synth") == 0)
611 return PLUGIN_CATEGORY_SYNTH;
612 if (std::strcmp(category, "delay") == 0)
613 return PLUGIN_CATEGORY_DELAY;
614 if (std::strcmp(category, "eq") == 0)
615 return PLUGIN_CATEGORY_EQ;
616 if (std::strcmp(category, "filter") == 0)
617 return PLUGIN_CATEGORY_FILTER;
618 if (std::strcmp(category, "distortion") == 0)
619 return PLUGIN_CATEGORY_DISTORTION;
620 if (std::strcmp(category, "dynamics") == 0)
621 return PLUGIN_CATEGORY_DYNAMICS;
622 if (std::strcmp(category, "modulator") == 0)
623 return PLUGIN_CATEGORY_MODULATOR;
624 if (std::strcmp(category, "utility") == 0)
625 return PLUGIN_CATEGORY_UTILITY;
626 if (std::strcmp(category, "other") == 0)
627 return PLUGIN_CATEGORY_OTHER;
629 carla_stderr("CarlaBackend::getPluginCategoryFromString(\"%s\") - invalid category", category);
630 return PLUGIN_CATEGORY_NONE;
633 // -----------------------------------------------------------------------
635 static inline
636 const char* getPluginTypeAsString(const PluginType type) noexcept
638 carla_debug("CarlaBackend::getPluginTypeAsString(%i:%s)", type, PluginType2Str(type));
640 switch (type)
642 case PLUGIN_NONE:
643 return "NONE";
644 case PLUGIN_INTERNAL:
645 return "INTERNAL";
646 case PLUGIN_LADSPA:
647 return "LADSPA";
648 case PLUGIN_DSSI:
649 return "DSSI";
650 case PLUGIN_LV2:
651 return "LV2";
652 case PLUGIN_VST2:
653 return "VST2";
654 case PLUGIN_VST3:
655 return "VST3";
656 case PLUGIN_AU:
657 return "AU";
658 case PLUGIN_DLS:
659 return "DLS";
660 case PLUGIN_GIG:
661 return "GIG";
662 case PLUGIN_SF2:
663 return "SF2";
664 case PLUGIN_SFZ:
665 return "SFZ";
666 case PLUGIN_JACK:
667 return "JACK";
668 case PLUGIN_JSFX:
669 return "JSFX";
670 case PLUGIN_CLAP:
671 return "CLAP";
672 case PLUGIN_TYPE_COUNT:
673 break;
676 carla_stderr("CarlaBackend::getPluginTypeAsString(%i) - invalid type", type);
677 return "NONE";
680 static inline
681 PluginType getPluginTypeFromString(const char* const ctype) noexcept
683 CARLA_SAFE_ASSERT_RETURN(ctype != nullptr && ctype[0] != '\0', PLUGIN_NONE);
684 carla_debug("CarlaBackend::getPluginTypeFromString(\"%s\")", ctype);
686 CarlaString stype(ctype);
688 if (stype.isEmpty())
689 return PLUGIN_NONE;
691 stype.toLower();
693 if (stype == "none")
694 return PLUGIN_NONE;
695 if (stype == "internal" || stype == "native")
696 return PLUGIN_INTERNAL;
697 if (stype == "ladspa")
698 return PLUGIN_LADSPA;
699 if (stype == "dssi")
700 return PLUGIN_DSSI;
701 if (stype == "lv2")
702 return PLUGIN_LV2;
703 if (stype == "vst2" || stype == "vst")
704 return PLUGIN_VST2;
705 if (stype == "vst3")
706 return PLUGIN_VST3;
707 if (stype == "au" || stype == "audiounit")
708 return PLUGIN_AU;
709 if (stype == "dls")
710 return PLUGIN_DLS;
711 if (stype == "gig")
712 return PLUGIN_GIG;
713 if (stype == "sf2" || stype == "sf3")
714 return PLUGIN_SF2;
715 if (stype == "sfz")
716 return PLUGIN_SFZ;
717 if (stype == "jack")
718 return PLUGIN_JACK;
719 if (stype == "jsfx")
720 return PLUGIN_JSFX;
721 if (stype == "clap")
722 return PLUGIN_CLAP;
724 carla_stderr("CarlaBackend::getPluginTypeFromString(\"%s\") - invalid string type", ctype);
725 return PLUGIN_NONE;
728 // -----------------------------------------------------------------------
730 static inline
731 PluginCategory getPluginCategoryFromName(const char* const name) noexcept
733 CARLA_SAFE_ASSERT_RETURN(name != nullptr && name[0] != '\0', PLUGIN_CATEGORY_NONE);
734 carla_debug("CarlaBackend::getPluginCategoryFromName(\"%s\")", name);
736 CarlaString sname(name);
738 if (sname.isEmpty())
739 return PLUGIN_CATEGORY_NONE;
741 sname.toLower();
743 // generic tags first
744 if (sname.contains("delay"))
745 return PLUGIN_CATEGORY_DELAY;
746 if (sname.contains("reverb"))
747 return PLUGIN_CATEGORY_DELAY;
749 // filter
750 if (sname.contains("filter"))
751 return PLUGIN_CATEGORY_FILTER;
753 // distortion
754 if (sname.contains("distortion"))
755 return PLUGIN_CATEGORY_DISTORTION;
757 // dynamics
758 if (sname.contains("dynamics"))
759 return PLUGIN_CATEGORY_DYNAMICS;
760 if (sname.contains("amplifier"))
761 return PLUGIN_CATEGORY_DYNAMICS;
762 if (sname.contains("compressor"))
763 return PLUGIN_CATEGORY_DYNAMICS;
764 if (sname.contains("enhancer"))
765 return PLUGIN_CATEGORY_DYNAMICS;
766 if (sname.contains("exciter"))
767 return PLUGIN_CATEGORY_DYNAMICS;
768 if (sname.contains("gate"))
769 return PLUGIN_CATEGORY_DYNAMICS;
770 if (sname.contains("limiter"))
771 return PLUGIN_CATEGORY_DYNAMICS;
773 // modulator
774 if (sname.contains("modulator"))
775 return PLUGIN_CATEGORY_MODULATOR;
776 if (sname.contains("chorus"))
777 return PLUGIN_CATEGORY_MODULATOR;
778 if (sname.contains("flanger"))
779 return PLUGIN_CATEGORY_MODULATOR;
780 if (sname.contains("phaser"))
781 return PLUGIN_CATEGORY_MODULATOR;
782 if (sname.contains("saturator"))
783 return PLUGIN_CATEGORY_MODULATOR;
785 // utility
786 if (sname.contains("utility"))
787 return PLUGIN_CATEGORY_UTILITY;
788 if (sname.contains("analyzer"))
789 return PLUGIN_CATEGORY_UTILITY;
790 if (sname.contains("converter"))
791 return PLUGIN_CATEGORY_UTILITY;
792 if (sname.contains("deesser"))
793 return PLUGIN_CATEGORY_UTILITY;
794 if (sname.contains("mixer"))
795 return PLUGIN_CATEGORY_UTILITY;
797 // common tags
798 if (sname.contains("verb"))
799 return PLUGIN_CATEGORY_DELAY;
801 if (sname.contains("eq"))
802 return PLUGIN_CATEGORY_EQ;
804 if (sname.contains("tool"))
805 return PLUGIN_CATEGORY_UTILITY;
807 // synth
808 if (sname.contains("synth"))
809 return PLUGIN_CATEGORY_SYNTH;
811 // other
812 if (sname.contains("misc"))
813 return PLUGIN_CATEGORY_OTHER;
814 if (sname.contains("other"))
815 return PLUGIN_CATEGORY_OTHER;
817 return PLUGIN_CATEGORY_NONE;
820 // -----------------------------------------------------------------------
822 static inline
823 bool isPluginOptionEnabled(const uint options, const uint option)
825 if (options == PLUGIN_OPTIONS_NULL)
826 return true;
827 if (options & option)
828 return true;
829 return false;
832 static inline
833 bool isPluginOptionInverseEnabled(const uint options, const uint option)
835 if (options == PLUGIN_OPTIONS_NULL)
836 return false;
837 if (options & option)
838 return true;
839 return false;
842 // -----------------------------------------------------------------------
844 CARLA_BACKEND_END_NAMESPACE
846 #endif // CARLA_BACKEND_UTILS_HPP_INCLUDED