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 // -----------------------------------------------------------------------
29 const char* PluginOption2Str(const uint option
) noexcept
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
);
57 // -----------------------------------------------------------------------
60 const char* BinaryType2Str(const BinaryType type
) noexcept
67 return "BINARY_POSIX32";
69 return "BINARY_POSIX64";
71 return "BINARY_WIN32";
73 return "BINARY_WIN64";
75 return "BINARY_OTHER";
78 carla_stderr("CarlaBackend::BinaryType2Str(%i) - invalid type", type
);
83 const char* FileType2Str(const FileType type
) noexcept
95 carla_stderr("CarlaBackend::FileType2Str(%i) - invalid type", type
);
100 const char* PluginType2Str(const PluginType type
) noexcept
105 return "PLUGIN_NONE";
106 case PLUGIN_INTERNAL
:
107 return "PLUGIN_INTERNAL";
109 return "PLUGIN_LADSPA";
111 return "PLUGIN_DSSI";
115 return "PLUGIN_VST2";
117 return "PLUGIN_VST3";
129 return "PLUGIN_JACK";
131 return "PLUGIN_JSFX";
133 return "PLUGIN_CLAP";
134 case PLUGIN_TYPE_COUNT
:
138 carla_stderr("CarlaBackend::PluginType2Str(%i) - invalid type", type
);
143 const char* PluginCategory2Str(const PluginCategory category
) noexcept
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
);
174 const char* ParameterType2Str(const ParameterType type
) noexcept
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
);
191 const char* InternalParameterIndex2Str(const InternalParameterIndex index
) noexcept
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";
214 return "PARAMETER_MAX";
217 carla_stderr("CarlaBackend::InternalParameterIndex2Str(%i) - invalid index", index
);
222 const char* EngineCallbackOpcode2Str(const EngineCallbackOpcode opcode
) noexcept
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";
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";
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
);
335 const char* EngineOption2Str(const EngineOption option
) noexcept
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";
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";
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";
410 case ENGINE_OPTION_DEBUG_CONSOLE_OUTPUT
:
411 return "ENGINE_OPTION_DEBUG_CONSOLE_OUTPUT";
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
);
424 const char* EngineProcessMode2Str(const EngineProcessMode mode
) noexcept
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
);
445 const char* EngineTransportMode2Str(const EngineTransportMode mode
) noexcept
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
);
466 const char* FileCallbackOpcode2Str(const FileCallbackOpcode opcode
) noexcept
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
);
483 const char* PatchbayIcon2Str(const PatchbayIcon icon
) noexcept
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
);
505 // -----------------------------------------------------------------------
508 const char* getBinaryTypeAsString(const BinaryType type
) noexcept
510 carla_debug("CarlaBackend::getBinaryTypeAsString(%i:%s)", type
, BinaryType2Str(type
));
512 if (type
== BINARY_NATIVE
)
531 carla_stderr("CarlaBackend::getBinaryTypeAsString(%i) - invalid type", type
);
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
);
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")
558 if (stype
== "win64")
560 if (stype
== "other")
563 carla_stderr("CarlaBackend::getBinaryTypeFromString(\"%s\") - invalid string type", ctype
);
567 // -----------------------------------------------------------------------
570 const char* getPluginCategoryAsString(const PluginCategory category
) noexcept
572 carla_debug("CarlaBackend::getPluginCategoryAsString(%i:%s)", category
, PluginCategory2Str(category
));
576 case PLUGIN_CATEGORY_NONE
:
578 case PLUGIN_CATEGORY_SYNTH
:
580 case PLUGIN_CATEGORY_DELAY
:
582 case PLUGIN_CATEGORY_EQ
:
584 case PLUGIN_CATEGORY_FILTER
:
586 case PLUGIN_CATEGORY_DISTORTION
:
588 case PLUGIN_CATEGORY_DYNAMICS
:
590 case PLUGIN_CATEGORY_MODULATOR
:
592 case PLUGIN_CATEGORY_UTILITY
:
594 case PLUGIN_CATEGORY_OTHER
:
598 carla_stderr("CarlaBackend::getPluginCategoryAsString(%i) - invalid category", category
);
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 // -----------------------------------------------------------------------
636 const char* getPluginTypeAsString(const PluginType type
) noexcept
638 carla_debug("CarlaBackend::getPluginTypeAsString(%i:%s)", type
, PluginType2Str(type
));
644 case PLUGIN_INTERNAL
:
672 case PLUGIN_TYPE_COUNT
:
676 carla_stderr("CarlaBackend::getPluginTypeAsString(%i) - invalid type", type
);
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
);
695 if (stype
== "internal" || stype
== "native")
696 return PLUGIN_INTERNAL
;
697 if (stype
== "ladspa")
698 return PLUGIN_LADSPA
;
703 if (stype
== "vst2" || stype
== "vst")
707 if (stype
== "au" || stype
== "audiounit")
713 if (stype
== "sf2" || stype
== "sf3")
724 carla_stderr("CarlaBackend::getPluginTypeFromString(\"%s\") - invalid string type", ctype
);
728 // -----------------------------------------------------------------------
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
);
739 return PLUGIN_CATEGORY_NONE
;
743 // generic tags first
744 if (sname
.contains("delay"))
745 return PLUGIN_CATEGORY_DELAY
;
746 if (sname
.contains("reverb"))
747 return PLUGIN_CATEGORY_DELAY
;
750 if (sname
.contains("filter"))
751 return PLUGIN_CATEGORY_FILTER
;
754 if (sname
.contains("distortion"))
755 return PLUGIN_CATEGORY_DISTORTION
;
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
;
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
;
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
;
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
;
808 if (sname
.contains("synth"))
809 return PLUGIN_CATEGORY_SYNTH
;
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 // -----------------------------------------------------------------------
823 bool isPluginOptionEnabled(const uint options
, const uint option
)
825 if (options
== PLUGIN_OPTIONS_NULL
)
827 if (options
& option
)
833 bool isPluginOptionInverseEnabled(const uint options
, const uint option
)
835 if (options
== PLUGIN_OPTIONS_NULL
)
837 if (options
& option
)
842 // -----------------------------------------------------------------------
844 CARLA_BACKEND_END_NAMESPACE
846 #endif // CARLA_BACKEND_UTILS_HPP_INCLUDED