Cleanup
[carla.git] / source / utils / CarlaBackendUtils.hpp
bloba5b9b5425195fffa23d9a8eecb10979790f95200
1 /*
2 * Carla Backend utils
3 * Copyright (C) 2011-2024 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 "CarlaNative.h"
23 #include "CarlaString.hpp"
25 CARLA_BACKEND_START_NAMESPACE
27 // -----------------------------------------------------------------------
29 static inline
30 const char* PluginOption2Str(const uint option) noexcept
32 switch (option)
34 case PLUGIN_OPTION_FIXED_BUFFERS:
35 return "PLUGIN_OPTION_FIXED_BUFFERS";
36 case PLUGIN_OPTION_FORCE_STEREO:
37 return "PLUGIN_OPTION_FORCE_STEREO";
38 case PLUGIN_OPTION_MAP_PROGRAM_CHANGES:
39 return "PLUGIN_OPTION_MAP_PROGRAM_CHANGES";
40 case PLUGIN_OPTION_USE_CHUNKS:
41 return "PLUGIN_OPTION_USE_CHUNKS";
42 case PLUGIN_OPTION_SEND_CONTROL_CHANGES:
43 return "PLUGIN_OPTION_SEND_CONTROL_CHANGES";
44 case PLUGIN_OPTION_SEND_CHANNEL_PRESSURE:
45 return "PLUGIN_OPTION_SEND_CHANNEL_PRESSURE";
46 case PLUGIN_OPTION_SEND_NOTE_AFTERTOUCH:
47 return "PLUGIN_OPTION_SEND_NOTE_AFTERTOUCH";
48 case PLUGIN_OPTION_SEND_PITCHBEND:
49 return "PLUGIN_OPTION_SEND_PITCHBEND";
50 case PLUGIN_OPTION_SEND_ALL_SOUND_OFF:
51 return "PLUGIN_OPTION_SEND_ALL_SOUND_OFF";
54 carla_stderr("CarlaBackend::PluginOption2Str(%i) - invalid option", option);
55 return "";
58 // -----------------------------------------------------------------------
60 static inline
61 const char* BinaryType2Str(const BinaryType type) noexcept
63 switch (type)
65 case BINARY_NONE:
66 return "BINARY_NONE";
67 case BINARY_POSIX32:
68 return "BINARY_POSIX32";
69 case BINARY_POSIX64:
70 return "BINARY_POSIX64";
71 case BINARY_WIN32:
72 return "BINARY_WIN32";
73 case BINARY_WIN64:
74 return "BINARY_WIN64";
75 case BINARY_OTHER:
76 return "BINARY_OTHER";
79 carla_stderr("CarlaBackend::BinaryType2Str(%i) - invalid type", type);
80 return "";
83 static inline
84 const char* FileType2Str(const FileType type) noexcept
86 switch (type)
88 case FILE_NONE:
89 return "FILE_NONE";
90 case FILE_AUDIO:
91 return "FILE_AUDIO";
92 case FILE_MIDI:
93 return "FILE_MIDI";
96 carla_stderr("CarlaBackend::FileType2Str(%i) - invalid type", type);
97 return "";
100 static inline
101 const char* PluginType2Str(const PluginType type) noexcept
103 switch (type)
105 case PLUGIN_NONE:
106 return "PLUGIN_NONE";
107 case PLUGIN_INTERNAL:
108 return "PLUGIN_INTERNAL";
109 case PLUGIN_LADSPA:
110 return "PLUGIN_LADSPA";
111 case PLUGIN_DSSI:
112 return "PLUGIN_DSSI";
113 case PLUGIN_LV2:
114 return "PLUGIN_LV2";
115 case PLUGIN_VST2:
116 return "PLUGIN_VST2";
117 case PLUGIN_VST3:
118 return "PLUGIN_VST3";
119 case PLUGIN_AU:
120 return "PLUGIN_AU";
121 case PLUGIN_DLS:
122 return "PLUGIN_DLS";
123 case PLUGIN_GIG:
124 return "PLUGIN_GIG";
125 case PLUGIN_SF2:
126 return "PLUGIN_SF2";
127 case PLUGIN_SFZ:
128 return "PLUGIN_SFZ";
129 case PLUGIN_JACK:
130 return "PLUGIN_JACK";
131 case PLUGIN_JSFX:
132 return "PLUGIN_JSFX";
133 case PLUGIN_CLAP:
134 return "PLUGIN_CLAP";
135 case PLUGIN_TYPE_COUNT:
136 break;
139 carla_stderr("CarlaBackend::PluginType2Str(%i) - invalid type", type);
140 return "";
143 static inline
144 const char* PluginCategory2Str(const PluginCategory category) noexcept
146 switch (category)
148 case PLUGIN_CATEGORY_NONE:
149 return "PLUGIN_CATEGORY_NONE";
150 case PLUGIN_CATEGORY_SYNTH:
151 return "PLUGIN_CATEGORY_SYNTH";
152 case PLUGIN_CATEGORY_DELAY:
153 return "PLUGIN_CATEGORY_DELAY";
154 case PLUGIN_CATEGORY_EQ:
155 return "PLUGIN_CATEGORY_EQ";
156 case PLUGIN_CATEGORY_FILTER:
157 return "PLUGIN_CATEGORY_FILTER";
158 case PLUGIN_CATEGORY_DISTORTION:
159 return "PLUGIN_CATEGORY_DISTORTION";
160 case PLUGIN_CATEGORY_DYNAMICS:
161 return "PLUGIN_CATEGORY_DYNAMICS";
162 case PLUGIN_CATEGORY_MODULATOR:
163 return "PLUGIN_CATEGORY_MODULATOR";
164 case PLUGIN_CATEGORY_UTILITY:
165 return "PLUGIN_CATEGORY_UTILITY";
166 case PLUGIN_CATEGORY_OTHER:
167 return "PLUGIN_CATEGORY_OTHER";
170 carla_stderr("CarlaBackend::PluginCategory2Str(%i) - invalid category", category);
171 return "";
174 static inline
175 const char* ParameterType2Str(const ParameterType type) noexcept
177 switch (type)
179 case PARAMETER_UNKNOWN:
180 return "PARAMETER_UNKNOWN";
181 case PARAMETER_INPUT:
182 return "PARAMETER_INPUT";
183 case PARAMETER_OUTPUT:
184 return "PARAMETER_OUTPUT";
187 carla_stderr("CarlaBackend::ParameterType2Str(%i) - invalid type", type);
188 return "";
191 static inline
192 const char* InternalParameterIndex2Str(const InternalParameterIndex index) noexcept
194 switch (index)
196 case PARAMETER_NULL:
197 return "PARAMETER_NULL";
198 #ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
199 case PARAMETER_ACTIVE:
200 return "PARAMETER_ACTIVE";
201 case PARAMETER_DRYWET:
202 return "PARAMETER_DRYWET";
203 case PARAMETER_VOLUME:
204 return "PARAMETER_VOLUME";
205 case PARAMETER_BALANCE_LEFT:
206 return "PARAMETER_BALANCE_LEFT";
207 case PARAMETER_BALANCE_RIGHT:
208 return "PARAMETER_BALANCE_RIGHT";
209 case PARAMETER_PANNING:
210 return "PARAMETER_PANNING";
211 case PARAMETER_CTRL_CHANNEL:
212 return "PARAMETER_CTRL_CHANNEL";
213 #endif
214 case PARAMETER_MAX:
215 return "PARAMETER_MAX";
218 carla_stderr("CarlaBackend::InternalParameterIndex2Str(%i) - invalid index", index);
219 return "";
222 static inline
223 const char* EngineCallbackOpcode2Str(const EngineCallbackOpcode opcode) noexcept
225 switch (opcode)
227 case ENGINE_CALLBACK_DEBUG:
228 return "ENGINE_CALLBACK_DEBUG";
229 case ENGINE_CALLBACK_PLUGIN_ADDED:
230 return "ENGINE_CALLBACK_PLUGIN_ADDED";
231 case ENGINE_CALLBACK_PLUGIN_REMOVED:
232 return "ENGINE_CALLBACK_PLUGIN_REMOVED";
233 case ENGINE_CALLBACK_PLUGIN_RENAMED:
234 return "ENGINE_CALLBACK_PLUGIN_RENAMED";
235 case ENGINE_CALLBACK_PLUGIN_UNAVAILABLE:
236 return "ENGINE_CALLBACK_PLUGIN_UNAVAILABLE";
237 case ENGINE_CALLBACK_PARAMETER_VALUE_CHANGED:
238 return "ENGINE_CALLBACK_PARAMETER_VALUE_CHANGED";
239 case ENGINE_CALLBACK_PARAMETER_DEFAULT_CHANGED:
240 return "ENGINE_CALLBACK_PARAMETER_DEFAULT_CHANGED";
241 #ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
242 case ENGINE_CALLBACK_PARAMETER_MAPPED_CONTROL_INDEX_CHANGED:
243 return "ENGINE_CALLBACK_PARAMETER_MAPPED_CONTROL_INDEX_CHANGED";
244 case ENGINE_CALLBACK_PARAMETER_MIDI_CHANNEL_CHANGED:
245 return "ENGINE_CALLBACK_PARAMETER_MIDI_CHANNEL_CHANGED";
246 case ENGINE_CALLBACK_OPTION_CHANGED:
247 return "ENGINE_CALLBACK_OPTION_CHANGED";
248 #endif
249 case ENGINE_CALLBACK_PROGRAM_CHANGED:
250 return "ENGINE_CALLBACK_PROGRAM_CHANGED";
251 case ENGINE_CALLBACK_MIDI_PROGRAM_CHANGED:
252 return "ENGINE_CALLBACK_MIDI_PROGRAM_CHANGED";
253 case ENGINE_CALLBACK_UI_STATE_CHANGED:
254 return "ENGINE_CALLBACK_UI_STATE_CHANGED";
255 case ENGINE_CALLBACK_NOTE_ON:
256 return "ENGINE_CALLBACK_NOTE_ON";
257 case ENGINE_CALLBACK_NOTE_OFF:
258 return "ENGINE_CALLBACK_NOTE_OFF";
259 case ENGINE_CALLBACK_UPDATE:
260 return "ENGINE_CALLBACK_UPDATE";
261 case ENGINE_CALLBACK_RELOAD_INFO:
262 return "ENGINE_CALLBACK_RELOAD_INFO";
263 case ENGINE_CALLBACK_RELOAD_PARAMETERS:
264 return "ENGINE_CALLBACK_RELOAD_PARAMETERS";
265 case ENGINE_CALLBACK_RELOAD_PROGRAMS:
266 return "ENGINE_CALLBACK_RELOAD_PROGRAMS";
267 case ENGINE_CALLBACK_RELOAD_ALL:
268 return "ENGINE_CALLBACK_RELOAD_ALL";
269 #ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
270 case ENGINE_CALLBACK_PATCHBAY_CLIENT_ADDED:
271 return "ENGINE_CALLBACK_PATCHBAY_CLIENT_ADDED";
272 case ENGINE_CALLBACK_PATCHBAY_CLIENT_REMOVED:
273 return "ENGINE_CALLBACK_PATCHBAY_CLIENT_REMOVED";
274 case ENGINE_CALLBACK_PATCHBAY_CLIENT_RENAMED:
275 return "ENGINE_CALLBACK_PATCHBAY_CLIENT_RENAMED";
276 case ENGINE_CALLBACK_PATCHBAY_CLIENT_DATA_CHANGED:
277 return "ENGINE_CALLBACK_PATCHBAY_CLIENT_DATA_CHANGED";
278 case ENGINE_CALLBACK_PATCHBAY_PORT_ADDED:
279 return "ENGINE_CALLBACK_PATCHBAY_PORT_ADDED";
280 case ENGINE_CALLBACK_PATCHBAY_PORT_REMOVED:
281 return "ENGINE_CALLBACK_PATCHBAY_PORT_REMOVED";
282 case ENGINE_CALLBACK_PATCHBAY_PORT_CHANGED:
283 return "ENGINE_CALLBACK_PATCHBAY_PORT_CHANGED";
284 case ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED:
285 return "ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED";
286 case ENGINE_CALLBACK_PATCHBAY_CONNECTION_REMOVED:
287 return "ENGINE_CALLBACK_PATCHBAY_CONNECTION_REMOVED";
288 #endif
289 case ENGINE_CALLBACK_ENGINE_STARTED:
290 return "ENGINE_CALLBACK_ENGINE_STARTED";
291 case ENGINE_CALLBACK_ENGINE_STOPPED:
292 return "ENGINE_CALLBACK_ENGINE_STOPPED";
293 case ENGINE_CALLBACK_PROCESS_MODE_CHANGED:
294 return "ENGINE_CALLBACK_PROCESS_MODE_CHANGED";
295 case ENGINE_CALLBACK_TRANSPORT_MODE_CHANGED:
296 return "ENGINE_CALLBACK_TRANSPORT_MODE_CHANGED";
297 case ENGINE_CALLBACK_BUFFER_SIZE_CHANGED:
298 return "ENGINE_CALLBACK_BUFFER_SIZE_CHANGED";
299 case ENGINE_CALLBACK_SAMPLE_RATE_CHANGED:
300 return "ENGINE_CALLBACK_SAMPLE_RATE_CHANGED";
301 case ENGINE_CALLBACK_CANCELABLE_ACTION:
302 return "ENGINE_CALLBACK_CANCELABLE_ACTION";
303 case ENGINE_CALLBACK_PROJECT_LOAD_FINISHED:
304 return "ENGINE_CALLBACK_PROJECT_LOAD_FINISHED";
305 case ENGINE_CALLBACK_NSM:
306 return "ENGINE_CALLBACK_NSM";
307 case ENGINE_CALLBACK_IDLE:
308 return "ENGINE_CALLBACK_IDLE";
309 case ENGINE_CALLBACK_INFO:
310 return "ENGINE_CALLBACK_INFO";
311 case ENGINE_CALLBACK_ERROR:
312 return "ENGINE_CALLBACK_ERROR";
313 case ENGINE_CALLBACK_QUIT:
314 return "ENGINE_CALLBACK_QUIT";
315 case ENGINE_CALLBACK_INLINE_DISPLAY_REDRAW:
316 return "ENGINE_CALLBACK_INLINE_DISPLAY_REDRAW";
317 case ENGINE_CALLBACK_PATCHBAY_PORT_GROUP_ADDED:
318 return "ENGINE_CALLBACK_PATCHBAY_PORT_GROUP_ADDED";
319 case ENGINE_CALLBACK_PATCHBAY_PORT_GROUP_REMOVED:
320 return "ENGINE_CALLBACK_PATCHBAY_PORT_GROUP_REMOVED";
321 case ENGINE_CALLBACK_PATCHBAY_PORT_GROUP_CHANGED:
322 return "ENGINE_CALLBACK_PATCHBAY_PORT_GROUP_CHANGED";
323 case ENGINE_CALLBACK_PARAMETER_MAPPED_RANGE_CHANGED:
324 return "ENGINE_CALLBACK_PARAMETER_MAPPED_RANGE_CHANGED";
325 case ENGINE_CALLBACK_PATCHBAY_CLIENT_POSITION_CHANGED:
326 return "ENGINE_CALLBACK_PATCHBAY_CLIENT_POSITION_CHANGED";
327 case ENGINE_CALLBACK_EMBED_UI_RESIZED:
328 return "ENGINE_CALLBACK_EMBED_UI_RESIZED";
331 carla_stderr("CarlaBackend::EngineCallbackOpcode2Str(%i) - invalid opcode", opcode);
332 return "";
335 static inline
336 const char* EngineOption2Str(const EngineOption option) noexcept
338 switch (option)
340 case ENGINE_OPTION_DEBUG:
341 return "ENGINE_OPTION_DEBUG";
342 case ENGINE_OPTION_PROCESS_MODE:
343 return "ENGINE_OPTION_PROCESS_MODE";
344 case ENGINE_OPTION_TRANSPORT_MODE:
345 return "ENGINE_OPTION_TRANSPORT_MODE";
346 case ENGINE_OPTION_FORCE_STEREO:
347 return "ENGINE_OPTION_FORCE_STEREO";
348 case ENGINE_OPTION_PREFER_PLUGIN_BRIDGES:
349 return "ENGINE_OPTION_PREFER_PLUGIN_BRIDGES";
350 case ENGINE_OPTION_PREFER_UI_BRIDGES:
351 return "ENGINE_OPTION_PREFER_UI_BRIDGES";
352 case ENGINE_OPTION_UIS_ALWAYS_ON_TOP:
353 return "ENGINE_OPTION_UIS_ALWAYS_ON_TOP";
354 case ENGINE_OPTION_MAX_PARAMETERS:
355 return "ENGINE_OPTION_MAX_PARAMETERS";
356 case ENGINE_OPTION_RESET_XRUNS:
357 return "ENGINE_OPTION_RESET_XRUNS";
358 case ENGINE_OPTION_UI_BRIDGES_TIMEOUT:
359 return "ENGINE_OPTION_UI_BRIDGES_TIMEOUT";
360 case ENGINE_OPTION_AUDIO_BUFFER_SIZE:
361 return "ENGINE_OPTION_AUDIO_BUFFER_SIZE";
362 case ENGINE_OPTION_AUDIO_SAMPLE_RATE:
363 return "ENGINE_OPTION_AUDIO_SAMPLE_RATE";
364 case ENGINE_OPTION_AUDIO_TRIPLE_BUFFER:
365 return "ENGINE_OPTION_AUDIO_TRIPLE_BUFFER";
366 case ENGINE_OPTION_AUDIO_DRIVER:
367 return "ENGINE_OPTION_AUDIO_DRIVER";
368 case ENGINE_OPTION_AUDIO_DEVICE:
369 return "ENGINE_OPTION_AUDIO_DEVICE";
370 #ifndef BUILD_BRIDGE
371 case ENGINE_OPTION_OSC_ENABLED:
372 return "ENGINE_OPTION_OSC_ENABLED";
373 case ENGINE_OPTION_OSC_PORT_UDP:
374 return "ENGINE_OPTION_OSC_PORT_UDP";
375 case ENGINE_OPTION_OSC_PORT_TCP:
376 return "ENGINE_OPTION_OSC_PORT_TCP";
377 #endif
378 case ENGINE_OPTION_FILE_PATH:
379 return "ENGINE_OPTION_FILE_PATH";
380 case ENGINE_OPTION_PLUGIN_PATH:
381 return "ENGINE_OPTION_PLUGIN_PATH";
382 case ENGINE_OPTION_PATH_BINARIES:
383 return "ENGINE_OPTION_PATH_BINARIES";
384 case ENGINE_OPTION_PATH_RESOURCES:
385 return "ENGINE_OPTION_PATH_RESOURCES";
386 case ENGINE_OPTION_PREVENT_BAD_BEHAVIOUR:
387 return "ENGINE_OPTION_PREVENT_BAD_BEHAVIOUR";
388 case ENGINE_OPTION_FRONTEND_BACKGROUND_COLOR:
389 return "ENGINE_OPTION_FRONTEND_BACKGROUND_COLOR";
390 case ENGINE_OPTION_FRONTEND_FOREGROUND_COLOR:
391 return "ENGINE_OPTION_FRONTEND_FOREGROUND_COLOR";
392 case ENGINE_OPTION_FRONTEND_UI_SCALE:
393 return "ENGINE_OPTION_FRONTEND_UI_SCALE";
394 case ENGINE_OPTION_FRONTEND_WIN_ID:
395 return "ENGINE_OPTION_FRONTEND_WIN_ID";
396 #if !defined(BUILD_BRIDGE_ALTERNATIVE_ARCH) && !defined(CARLA_OS_WIN)
397 case ENGINE_OPTION_WINE_EXECUTABLE:
398 return "ENGINE_OPTION_WINE_EXECUTABLE";
399 case ENGINE_OPTION_WINE_AUTO_PREFIX:
400 return "ENGINE_OPTION_WINE_AUTO_PREFIX";
401 case ENGINE_OPTION_WINE_FALLBACK_PREFIX:
402 return "ENGINE_OPTION_WINE_FALLBACK_PREFIX";
403 case ENGINE_OPTION_WINE_RT_PRIO_ENABLED:
404 return "ENGINE_OPTION_WINE_RT_PRIO_ENABLED";
405 case ENGINE_OPTION_WINE_BASE_RT_PRIO:
406 return "ENGINE_OPTION_WINE_BASE_RT_PRIO";
407 case ENGINE_OPTION_WINE_SERVER_RT_PRIO:
408 return "ENGINE_OPTION_WINE_SERVER_RT_PRIO";
409 #endif
410 #ifndef BUILD_BRIDGE
411 case ENGINE_OPTION_DEBUG_CONSOLE_OUTPUT:
412 return "ENGINE_OPTION_DEBUG_CONSOLE_OUTPUT";
413 #endif
414 case ENGINE_OPTION_CLIENT_NAME_PREFIX:
415 return "ENGINE_OPTION_CLIENT_NAME_PREFIX";
416 case ENGINE_OPTION_PLUGINS_ARE_STANDALONE:
417 return "ENGINE_OPTION_PLUGINS_ARE_STANDALONE";
420 carla_stderr("CarlaBackend::EngineOption2Str(%i) - invalid option", option);
421 return "";
424 static inline
425 const char* EngineProcessMode2Str(const EngineProcessMode mode) noexcept
427 switch (mode)
429 case ENGINE_PROCESS_MODE_SINGLE_CLIENT:
430 return "ENGINE_PROCESS_MODE_SINGLE_CLIENT";
431 case ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS:
432 return "ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS";
433 case ENGINE_PROCESS_MODE_CONTINUOUS_RACK:
434 return "ENGINE_PROCESS_MODE_CONTINUOUS_RACK";
435 case ENGINE_PROCESS_MODE_PATCHBAY:
436 return "ENGINE_PROCESS_MODE_PATCHBAY";
437 case ENGINE_PROCESS_MODE_BRIDGE:
438 return "ENGINE_PROCESS_MODE_BRIDGE";
441 carla_stderr("CarlaBackend::EngineProcessMode2Str(%i) - invalid mode", mode);
442 return "";
445 static inline
446 const char* EngineTransportMode2Str(const EngineTransportMode mode) noexcept
448 switch (mode)
450 case ENGINE_TRANSPORT_MODE_DISABLED:
451 return "ENGINE_TRANSPORT_MODE_DISABLED";
452 case ENGINE_TRANSPORT_MODE_INTERNAL:
453 return "ENGINE_TRANSPORT_MODE_INTERNAL";
454 case ENGINE_TRANSPORT_MODE_JACK:
455 return "ENGINE_TRANSPORT_MODE_JACK";
456 case ENGINE_TRANSPORT_MODE_PLUGIN:
457 return "ENGINE_TRANSPORT_MODE_PLUGIN";
458 case ENGINE_TRANSPORT_MODE_BRIDGE:
459 return "ENGINE_TRANSPORT_MODE_BRIDGE";
462 carla_stderr("CarlaBackend::EngineTransportMode2Str(%i) - invalid mode", mode);
463 return "";
466 static inline
467 const char* FileCallbackOpcode2Str(const FileCallbackOpcode opcode) noexcept
469 switch (opcode)
471 case FILE_CALLBACK_DEBUG:
472 return "FILE_CALLBACK_DEBUG";
473 case FILE_CALLBACK_OPEN:
474 return "FILE_CALLBACK_OPEN";
475 case FILE_CALLBACK_SAVE:
476 return "FILE_CALLBACK_SAVE";
479 carla_stderr("CarlaBackend::FileCallbackOpcode2Str(%i) - invalid opcode", opcode);
480 return "";
483 static inline
484 const char* PatchbayIcon2Str(const PatchbayIcon icon) noexcept
486 switch (icon)
488 case PATCHBAY_ICON_APPLICATION:
489 return "PATCHBAY_ICON_APPLICATION";
490 case PATCHBAY_ICON_PLUGIN:
491 return "PATCHBAY_ICON_PLUGIN";
492 case PATCHBAY_ICON_HARDWARE:
493 return "PATCHBAY_ICON_HARDWARE";
494 case PATCHBAY_ICON_CARLA:
495 return "PATCHBAY_ICON_CARLA";
496 case PATCHBAY_ICON_DISTRHO:
497 return "PATCHBAY_ICON_DISTRHO";
498 case PATCHBAY_ICON_FILE:
499 return "PATCHBAY_ICON_FILE";
502 carla_stderr("CarlaBackend::PatchbayIcon2Str(%i) - invalid icon", icon);
503 return "";
506 // -----------------------------------------------------------------------
508 static inline
509 const char* NativePluginDispatcherOpcode2Str(const NativePluginDispatcherOpcode opcode) noexcept
511 switch (opcode)
513 case NATIVE_PLUGIN_OPCODE_NULL:
514 return "NATIVE_PLUGIN_OPCODE_NULL";
515 case NATIVE_PLUGIN_OPCODE_BUFFER_SIZE_CHANGED:
516 return "NATIVE_PLUGIN_OPCODE_BUFFER_SIZE_CHANGED";
517 case NATIVE_PLUGIN_OPCODE_SAMPLE_RATE_CHANGED:
518 return "NATIVE_PLUGIN_OPCODE_SAMPLE_RATE_CHANGED";
519 case NATIVE_PLUGIN_OPCODE_OFFLINE_CHANGED:
520 return "NATIVE_PLUGIN_OPCODE_OFFLINE_CHANGED";
521 case NATIVE_PLUGIN_OPCODE_UI_NAME_CHANGED:
522 return "NATIVE_PLUGIN_OPCODE_UI_NAME_CHANGED";
523 case NATIVE_PLUGIN_OPCODE_GET_INTERNAL_HANDLE:
524 return "NATIVE_PLUGIN_OPCODE_GET_INTERNAL_HANDLE";
525 case NATIVE_PLUGIN_OPCODE_IDLE:
526 return "NATIVE_PLUGIN_OPCODE_IDLE";
527 case NATIVE_PLUGIN_OPCODE_UI_MIDI_EVENT:
528 return "NATIVE_PLUGIN_OPCODE_UI_MIDI_EVENT";
529 case NATIVE_PLUGIN_OPCODE_HOST_USES_EMBED:
530 return "NATIVE_PLUGIN_OPCODE_HOST_USES_EMBED";
531 case NATIVE_PLUGIN_OPCODE_HOST_OPTION:
532 return "NATIVE_PLUGIN_OPCODE_HOST_OPTION";
535 carla_stderr("CarlaBackend::NativePluginDispatcherOpcode2Str(%i) - invalid icon", opcode);
536 return "";
539 static inline
540 const char* NativeHostDispatcherOpcode2Str(const NativeHostDispatcherOpcode opcode) noexcept
542 switch (opcode)
544 case NATIVE_HOST_OPCODE_NULL:
545 return "NATIVE_HOST_OPCODE_NULL";
546 case NATIVE_HOST_OPCODE_UPDATE_PARAMETER:
547 return "NATIVE_HOST_OPCODE_UPDATE_PARAMETER";
548 case NATIVE_HOST_OPCODE_UPDATE_MIDI_PROGRAM:
549 return "NATIVE_HOST_OPCODE_UPDATE_MIDI_PROGRAM";
550 case NATIVE_HOST_OPCODE_RELOAD_PARAMETERS:
551 return "NATIVE_HOST_OPCODE_RELOAD_PARAMETERS";
552 case NATIVE_HOST_OPCODE_RELOAD_MIDI_PROGRAMS:
553 return "NATIVE_HOST_OPCODE_RELOAD_MIDI_PROGRAMS";
554 case NATIVE_HOST_OPCODE_RELOAD_ALL:
555 return "NATIVE_HOST_OPCODE_RELOAD_ALL";
556 case NATIVE_HOST_OPCODE_UI_UNAVAILABLE:
557 return "NATIVE_HOST_OPCODE_UI_UNAVAILABLE";
558 case NATIVE_HOST_OPCODE_HOST_IDLE:
559 return "NATIVE_HOST_OPCODE_HOST_IDLE";
560 case NATIVE_HOST_OPCODE_INTERNAL_PLUGIN:
561 return "NATIVE_HOST_OPCODE_INTERNAL_PLUGIN";
562 case NATIVE_HOST_OPCODE_QUEUE_INLINE_DISPLAY:
563 return "NATIVE_HOST_OPCODE_QUEUE_INLINE_DISPLAY";
564 case NATIVE_HOST_OPCODE_UI_TOUCH_PARAMETER:
565 return "NATIVE_HOST_OPCODE_UI_TOUCH_PARAMETER";
566 case NATIVE_HOST_OPCODE_REQUEST_IDLE:
567 return "NATIVE_HOST_OPCODE_REQUEST_IDLE";
568 case NATIVE_HOST_OPCODE_GET_FILE_PATH:
569 return "NATIVE_HOST_OPCODE_GET_FILE_PATH";
570 case NATIVE_HOST_OPCODE_UI_RESIZE:
571 return "NATIVE_HOST_OPCODE_UI_RESIZE";
572 case NATIVE_HOST_OPCODE_PREVIEW_BUFFER_DATA:
573 return "NATIVE_HOST_OPCODE_PREVIEW_BUFFER_DATA";
576 carla_stderr("CarlaBackend::NativeHostDispatcherOpcode2Str(%i) - invalid icon", opcode);
577 return "";
580 // -----------------------------------------------------------------------
582 static inline
583 const char* getBinaryTypeAsString(const BinaryType type) noexcept
585 carla_debug("CarlaBackend::getBinaryTypeAsString(%i:%s)", type, BinaryType2Str(type));
587 if (type == BINARY_NATIVE)
588 return "native";
590 switch (type)
592 case BINARY_NONE:
593 return "none";
594 case BINARY_POSIX32:
595 return "posix32";
596 case BINARY_POSIX64:
597 return "posix64";
598 case BINARY_WIN32:
599 return "win32";
600 case BINARY_WIN64:
601 return "win64";
602 case BINARY_OTHER:
603 return "other";
606 carla_stderr("CarlaBackend::getBinaryTypeAsString(%i) - invalid type", type);
607 return "NONE";
610 static inline
611 BinaryType getBinaryTypeFromString(const char* const ctype) noexcept
613 CARLA_SAFE_ASSERT_RETURN(ctype != nullptr && ctype[0] != '\0', BINARY_NONE);
614 carla_debug("CarlaBackend::getBinaryTypeFromString(\"%s\")", ctype);
616 CarlaString stype(ctype);
618 if (stype.isEmpty())
619 return BINARY_NONE;
621 stype.toLower();
623 if (stype == "none")
624 return BINARY_NONE;
625 if (stype == "native")
626 return BINARY_NATIVE;
627 if (stype == "posix32" || stype == "linux32" || stype == "mac32")
628 return BINARY_POSIX32;
629 if (stype == "posix64" || stype == "linux64" || stype == "mac64")
630 return BINARY_POSIX64;
631 if (stype == "win32")
632 return BINARY_WIN32;
633 if (stype == "win64")
634 return BINARY_WIN64;
635 if (stype == "other")
636 return BINARY_OTHER;
638 carla_stderr("CarlaBackend::getBinaryTypeFromString(\"%s\") - invalid string type", ctype);
639 return BINARY_NONE;
642 // -----------------------------------------------------------------------
644 static inline
645 const char* getPluginCategoryAsString(const PluginCategory category) noexcept
647 carla_debug("CarlaBackend::getPluginCategoryAsString(%i:%s)", category, PluginCategory2Str(category));
649 switch (category)
651 case PLUGIN_CATEGORY_NONE:
652 return "none";
653 case PLUGIN_CATEGORY_SYNTH:
654 return "synth";
655 case PLUGIN_CATEGORY_DELAY:
656 return "delay";
657 case PLUGIN_CATEGORY_EQ:
658 return "eq";
659 case PLUGIN_CATEGORY_FILTER:
660 return "filter";
661 case PLUGIN_CATEGORY_DISTORTION:
662 return "distortion";
663 case PLUGIN_CATEGORY_DYNAMICS:
664 return "dynamics";
665 case PLUGIN_CATEGORY_MODULATOR:
666 return "modulator";
667 case PLUGIN_CATEGORY_UTILITY:
668 return "utility";
669 case PLUGIN_CATEGORY_OTHER:
670 return "other";
673 carla_stderr("CarlaBackend::getPluginCategoryAsString(%i) - invalid category", category);
674 return "NONE";
677 static inline
678 PluginCategory getPluginCategoryFromString(const char* const category) noexcept
680 CARLA_SAFE_ASSERT_RETURN(category != nullptr && category[0] != '\0', PLUGIN_CATEGORY_NONE);
681 carla_debug("CarlaBackend::getPluginCategoryFromString(\"%s\")", category);
683 if (std::strcmp(category, "none") == 0)
684 return PLUGIN_CATEGORY_NONE;
685 if (std::strcmp(category, "synth") == 0)
686 return PLUGIN_CATEGORY_SYNTH;
687 if (std::strcmp(category, "delay") == 0)
688 return PLUGIN_CATEGORY_DELAY;
689 if (std::strcmp(category, "eq") == 0)
690 return PLUGIN_CATEGORY_EQ;
691 if (std::strcmp(category, "filter") == 0)
692 return PLUGIN_CATEGORY_FILTER;
693 if (std::strcmp(category, "distortion") == 0)
694 return PLUGIN_CATEGORY_DISTORTION;
695 if (std::strcmp(category, "dynamics") == 0)
696 return PLUGIN_CATEGORY_DYNAMICS;
697 if (std::strcmp(category, "modulator") == 0)
698 return PLUGIN_CATEGORY_MODULATOR;
699 if (std::strcmp(category, "utility") == 0)
700 return PLUGIN_CATEGORY_UTILITY;
701 if (std::strcmp(category, "other") == 0)
702 return PLUGIN_CATEGORY_OTHER;
704 carla_stderr("CarlaBackend::getPluginCategoryFromString(\"%s\") - invalid category", category);
705 return PLUGIN_CATEGORY_NONE;
708 // -----------------------------------------------------------------------
710 static inline
711 const char* getPluginTypeAsString(const PluginType type) noexcept
713 carla_debug("CarlaBackend::getPluginTypeAsString(%i:%s)", type, PluginType2Str(type));
715 switch (type)
717 case PLUGIN_NONE:
718 return "NONE";
719 case PLUGIN_INTERNAL:
720 return "INTERNAL";
721 case PLUGIN_LADSPA:
722 return "LADSPA";
723 case PLUGIN_DSSI:
724 return "DSSI";
725 case PLUGIN_LV2:
726 return "LV2";
727 case PLUGIN_VST2:
728 return "VST2";
729 case PLUGIN_VST3:
730 return "VST3";
731 case PLUGIN_AU:
732 return "AU";
733 case PLUGIN_DLS:
734 return "DLS";
735 case PLUGIN_GIG:
736 return "GIG";
737 case PLUGIN_SF2:
738 return "SF2";
739 case PLUGIN_SFZ:
740 return "SFZ";
741 case PLUGIN_JACK:
742 return "JACK";
743 case PLUGIN_JSFX:
744 return "JSFX";
745 case PLUGIN_CLAP:
746 return "CLAP";
747 case PLUGIN_TYPE_COUNT:
748 break;
751 carla_stderr("CarlaBackend::getPluginTypeAsString(%i) - invalid type", type);
752 return "NONE";
755 static inline
756 PluginType getPluginTypeFromString(const char* const ctype) noexcept
758 CARLA_SAFE_ASSERT_RETURN(ctype != nullptr && ctype[0] != '\0', PLUGIN_NONE);
759 carla_debug("CarlaBackend::getPluginTypeFromString(\"%s\")", ctype);
761 CarlaString stype(ctype);
763 if (stype.isEmpty())
764 return PLUGIN_NONE;
766 stype.toLower();
768 if (stype == "none")
769 return PLUGIN_NONE;
770 if (stype == "internal" || stype == "native")
771 return PLUGIN_INTERNAL;
772 if (stype == "ladspa")
773 return PLUGIN_LADSPA;
774 if (stype == "dssi")
775 return PLUGIN_DSSI;
776 if (stype == "lv2")
777 return PLUGIN_LV2;
778 if (stype == "vst2" || stype == "vst")
779 return PLUGIN_VST2;
780 if (stype == "vst3")
781 return PLUGIN_VST3;
782 if (stype == "au" || stype == "audiounit")
783 return PLUGIN_AU;
784 if (stype == "dls")
785 return PLUGIN_DLS;
786 if (stype == "gig")
787 return PLUGIN_GIG;
788 if (stype == "sf2" || stype == "sf3")
789 return PLUGIN_SF2;
790 if (stype == "sfz")
791 return PLUGIN_SFZ;
792 if (stype == "jack")
793 return PLUGIN_JACK;
794 if (stype == "jsfx")
795 return PLUGIN_JSFX;
796 if (stype == "clap")
797 return PLUGIN_CLAP;
799 carla_stderr("CarlaBackend::getPluginTypeFromString(\"%s\") - invalid string type", ctype);
800 return PLUGIN_NONE;
803 // -----------------------------------------------------------------------
805 static inline
806 PluginCategory getPluginCategoryFromName(const char* const name) noexcept
808 CARLA_SAFE_ASSERT_RETURN(name != nullptr && name[0] != '\0', PLUGIN_CATEGORY_NONE);
809 carla_debug("CarlaBackend::getPluginCategoryFromName(\"%s\")", name);
811 CarlaString sname(name);
813 if (sname.isEmpty())
814 return PLUGIN_CATEGORY_NONE;
816 sname.toLower();
818 // generic tags first
819 if (sname.contains("delay"))
820 return PLUGIN_CATEGORY_DELAY;
821 if (sname.contains("reverb"))
822 return PLUGIN_CATEGORY_DELAY;
824 // filter
825 if (sname.contains("filter"))
826 return PLUGIN_CATEGORY_FILTER;
828 // distortion
829 if (sname.contains("distortion"))
830 return PLUGIN_CATEGORY_DISTORTION;
832 // dynamics
833 if (sname.contains("dynamics"))
834 return PLUGIN_CATEGORY_DYNAMICS;
835 if (sname.contains("amplifier"))
836 return PLUGIN_CATEGORY_DYNAMICS;
837 if (sname.contains("compressor"))
838 return PLUGIN_CATEGORY_DYNAMICS;
839 if (sname.contains("enhancer"))
840 return PLUGIN_CATEGORY_DYNAMICS;
841 if (sname.contains("exciter"))
842 return PLUGIN_CATEGORY_DYNAMICS;
843 if (sname.contains("gate"))
844 return PLUGIN_CATEGORY_DYNAMICS;
845 if (sname.contains("limiter"))
846 return PLUGIN_CATEGORY_DYNAMICS;
848 // modulator
849 if (sname.contains("modulator"))
850 return PLUGIN_CATEGORY_MODULATOR;
851 if (sname.contains("chorus"))
852 return PLUGIN_CATEGORY_MODULATOR;
853 if (sname.contains("flanger"))
854 return PLUGIN_CATEGORY_MODULATOR;
855 if (sname.contains("phaser"))
856 return PLUGIN_CATEGORY_MODULATOR;
857 if (sname.contains("saturator"))
858 return PLUGIN_CATEGORY_MODULATOR;
860 // utility
861 if (sname.contains("utility"))
862 return PLUGIN_CATEGORY_UTILITY;
863 if (sname.contains("analyzer"))
864 return PLUGIN_CATEGORY_UTILITY;
865 if (sname.contains("converter"))
866 return PLUGIN_CATEGORY_UTILITY;
867 if (sname.contains("deesser"))
868 return PLUGIN_CATEGORY_UTILITY;
869 if (sname.contains("mixer"))
870 return PLUGIN_CATEGORY_UTILITY;
872 // common tags
873 if (sname.contains("verb"))
874 return PLUGIN_CATEGORY_DELAY;
876 if (sname.contains("eq"))
877 return PLUGIN_CATEGORY_EQ;
879 if (sname.contains("tool"))
880 return PLUGIN_CATEGORY_UTILITY;
882 // synth
883 if (sname.contains("synth"))
884 return PLUGIN_CATEGORY_SYNTH;
886 // other
887 if (sname.contains("misc"))
888 return PLUGIN_CATEGORY_OTHER;
889 if (sname.contains("other"))
890 return PLUGIN_CATEGORY_OTHER;
892 return PLUGIN_CATEGORY_NONE;
895 // -----------------------------------------------------------------------
897 static inline
898 bool isPluginOptionEnabled(const uint options, const uint option)
900 if (options == PLUGIN_OPTIONS_NULL)
901 return true;
902 if (options & option)
903 return true;
904 return false;
907 static inline
908 bool isPluginOptionInverseEnabled(const uint options, const uint option)
910 if (options == PLUGIN_OPTIONS_NULL)
911 return false;
912 if (options & option)
913 return true;
914 return false;
917 // -----------------------------------------------------------------------
919 CARLA_BACKEND_END_NAMESPACE
921 #endif // CARLA_BACKEND_UTILS_HPP_INCLUDED