1 /*
2  * Carla Plugin Host
3  * Copyright (C) 2011-2021 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 
18 #ifndef CARLA_BACKEND_H_INCLUDED
19 #define CARLA_BACKEND_H_INCLUDED
20 
21 #include "CarlaDefines.h"
22 
23 #ifdef CARLA_PROPER_CPP11_SUPPORT
24 # include <cstdint>
25 #else
26 # include <stdint.h>
27 #endif
28 
29 #define STR_MAX 0xFF
30 
31 #ifdef __cplusplus
32 # define CARLA_BACKEND_START_NAMESPACE namespace CarlaBackend {
33 # define CARLA_BACKEND_END_NAMESPACE }
34 # define CARLA_BACKEND_USE_NAMESPACE using namespace CarlaBackend;
35 # include <algorithm>
36 # include <cmath>
37 # include <limits>
38 /* Start namespace */
39 CARLA_BACKEND_START_NAMESPACE
40 #endif
41 
42 /*!
43  * @defgroup CarlaBackendAPI Carla Backend API
44  *
45  * The Carla Backend API.
46  *
47  * These are the base definitions for everything in the Carla backend code.
48  * @{
49  */
50 
51 /* ------------------------------------------------------------------------------------------------------------
52  * Carla Backend API (base definitions) */
53 
54 /*!
55  * Maximum default number of loadable plugins.
56  */
57 static const uint MAX_DEFAULT_PLUGINS = 512;
58 
59 /*!
60  * Maximum number of loadable plugins in rack mode.
61  */
62 static const uint MAX_RACK_PLUGINS = 64;
63 
64 /*!
65  * Maximum number of loadable plugins in patchbay mode.
66  */
67 static const uint MAX_PATCHBAY_PLUGINS = 255;
68 
69 /*!
70  * Maximum default number of parameters allowed.
71  * @see ENGINE_OPTION_MAX_PARAMETERS
72  */
73 static const uint MAX_DEFAULT_PARAMETERS = 200;
74 
75 /*!
76  * The "plugin Id" for the global Carla instance.
77  * Currently only used for audio peaks.
78  */
79 static const uint MAIN_CARLA_PLUGIN_ID = 0xFFFF;
80 
81 /* ------------------------------------------------------------------------------------------------------------
82  * Engine Driver Device Hints */
83 
84 /*!
85  * @defgroup EngineDriverHints Engine Driver Device Hints
86  *
87  * Various engine driver device hints.
88  * @see CarlaEngine::getHints(), CarlaEngine::getDriverDeviceInfo() and carla_get_engine_driver_device_info()
89  * @{
90  */
91 
92 /*!
93  * Engine driver device has custom control-panel.
94  */
95 static const uint ENGINE_DRIVER_DEVICE_HAS_CONTROL_PANEL = 0x1;
96 
97 /*!
98  * Engine driver device can use a triple-buffer (3 number of periods instead of the usual 2).
99  * @see ENGINE_OPTION_AUDIO_NUM_PERIODS
100  */
101 static const uint ENGINE_DRIVER_DEVICE_CAN_TRIPLE_BUFFER = 0x2;
102 
103 /*!
104  * Engine driver device can change buffer-size on the fly.
105  * @see ENGINE_OPTION_AUDIO_BUFFER_SIZE
106  */
107 static const uint ENGINE_DRIVER_DEVICE_VARIABLE_BUFFER_SIZE = 0x4;
108 
109 /*!
110  * Engine driver device can change sample-rate on the fly.
111  * @see ENGINE_OPTION_AUDIO_SAMPLE_RATE
112  */
113 static const uint ENGINE_DRIVER_DEVICE_VARIABLE_SAMPLE_RATE = 0x8;
114 
115 /** @} */
116 
117 /* ------------------------------------------------------------------------------------------------------------
118  * Plugin Hints */
119 
120 /*!
121  * @defgroup PluginHints Plugin Hints
122  *
123  * Various plugin hints.
124  * @see CarlaPlugin::getHints() and carla_get_plugin_info()
125  * @{
126  */
127 
128 /*!
129  * Plugin is a bridge.
130  * This hint is required because "bridge" itself is not a plugin type.
131  */
132 static const uint PLUGIN_IS_BRIDGE = 0x001;
133 
134 /*!
135  * Plugin is hard real-time safe.
136  */
137 static const uint PLUGIN_IS_RTSAFE = 0x002;
138 
139 /*!
140  * Plugin is a synth (produces sound).
141  */
142 static const uint PLUGIN_IS_SYNTH = 0x004;
143 
144 /*!
145  * Plugin has its own custom UI.
146  * @see CarlaPlugin::showCustomUI() and carla_show_custom_ui()
147  */
148 static const uint PLUGIN_HAS_CUSTOM_UI = 0x008;
149 
150 /*!
151  * Plugin can use internal Dry/Wet control.
152  */
153 static const uint PLUGIN_CAN_DRYWET = 0x010;
154 
155 /*!
156  * Plugin can use internal Volume control.
157  */
158 static const uint PLUGIN_CAN_VOLUME = 0x020;
159 
160 /*!
161  * Plugin can use internal (Stereo) Balance controls.
162  */
163 static const uint PLUGIN_CAN_BALANCE = 0x040;
164 
165 /*!
166  * Plugin can use internal (Mono) Panning control.
167  */
168 static const uint PLUGIN_CAN_PANNING = 0x080;
169 
170 /*!
171  * Plugin needs a constant, fixed-size audio buffer.
172  */
173 static const uint PLUGIN_NEEDS_FIXED_BUFFERS = 0x100;
174 
175 /*!
176  * Plugin needs to receive all UI events in the main thread.
177  */
178 static const uint PLUGIN_NEEDS_UI_MAIN_THREAD = 0x200;
179 
180 /*!
181  * Plugin uses 1 program per MIDI channel.
182  * @note: Only used in some internal plugins and sf2 files.
183  */
184 static const uint PLUGIN_USES_MULTI_PROGS = 0x400;
185 
186 /*!
187  * Plugin can make use of inline display API.
188  */
189 static const uint PLUGIN_HAS_INLINE_DISPLAY = 0x800;
190 
191 /*!
192  * Plugin has its own custom UI which can be embed into another Window.
193  * @see CarlaPlugin::embedCustomUI() and carla_embed_custom_ui()
194  * @note This is very experimental and subject to change at this point
195  */
196 static const uint PLUGIN_HAS_CUSTOM_EMBED_UI = 0x1000;
197 
198 /** @} */
199 
200 /* ------------------------------------------------------------------------------------------------------------
201  * Plugin Options */
202 
203 /*!
204  * @defgroup PluginOptions Plugin Options
205  *
206  * Various plugin options.
207  * @note Do not modify these values, as they are saved as-is in project files.
208  * @see CarlaPlugin::getOptionsAvailable(), CarlaPlugin::getOptionsEnabled(), carla_get_plugin_info() and carla_set_option()
209  * @{
210  */
211 
212 /*!
213  * Use constant/fixed-size audio buffers.
214  */
215 static const uint PLUGIN_OPTION_FIXED_BUFFERS = 0x001;
216 
217 /*!
218  * Force mono plugin as stereo.
219  */
220 static const uint PLUGIN_OPTION_FORCE_STEREO = 0x002;
221 
222 /*!
223  * Map MIDI programs to plugin programs.
224  */
225 static const uint PLUGIN_OPTION_MAP_PROGRAM_CHANGES = 0x004;
226 
227 /*!
228  * Use chunks to save and restore data instead of parameter values.
229  */
230 static const uint PLUGIN_OPTION_USE_CHUNKS = 0x008;
231 
232 /*!
233  * Send MIDI control change events.
234  */
235 static const uint PLUGIN_OPTION_SEND_CONTROL_CHANGES = 0x010;
236 
237 /*!
238  * Send MIDI channel pressure events.
239  */
240 static const uint PLUGIN_OPTION_SEND_CHANNEL_PRESSURE = 0x020;
241 
242 /*!
243  * Send MIDI note after-touch events.
244  */
245 static const uint PLUGIN_OPTION_SEND_NOTE_AFTERTOUCH = 0x040;
246 
247 /*!
248  * Send MIDI pitch-bend events.
249  */
250 static const uint PLUGIN_OPTION_SEND_PITCHBEND = 0x080;
251 
252 /*!
253  * Send MIDI all-sounds/notes-off events, single note-offs otherwise.
254  */
255 static const uint PLUGIN_OPTION_SEND_ALL_SOUND_OFF = 0x100;
256 
257 /*!
258  * Send MIDI bank/program changes.
259  * @note: This option conflicts with PLUGIN_OPTION_MAP_PROGRAM_CHANGES and cannot be used at the same time.
260  */
261 static const uint PLUGIN_OPTION_SEND_PROGRAM_CHANGES = 0x200;
262 
263 /*!
264  * Skip sending MIDI note events.
265  * This if off-by-default as a way to keep backwards compatibility.
266  * We always want notes enabled by default, not the contrary.
267  */
268 static const uint PLUGIN_OPTION_SKIP_SENDING_NOTES = 0x400;
269 
270 /*!
271  * Special flag to indicate that plugin options are not yet set.
272  * This flag exists because 0x0 as an option value is a valid one, so we need something else to indicate "null-ness".
273  */
274 static const uint PLUGIN_OPTIONS_NULL = 0x10000;
275 
276 /** @} */
277 
278 /* ------------------------------------------------------------------------------------------------------------
279  * Parameter Hints */
280 
281 /*!
282  * @defgroup ParameterHints Parameter Hints
283  *
284  * Various parameter hints.
285  * @see CarlaPlugin::getParameterData() and carla_get_parameter_data()
286  * @{
287  */
288 
289 /*!
290  * Parameter value is boolean.
291  * It's always at either minimum or maximum value.
292  */
293 static const uint PARAMETER_IS_BOOLEAN = 0x001;
294 
295 /*!
296  * Parameter value is integer.
297  */
298 static const uint PARAMETER_IS_INTEGER = 0x002;
299 
300 /*!
301  * Parameter value is logarithmic.
302  */
303 static const uint PARAMETER_IS_LOGARITHMIC = 0x004;
304 
305 /*!
306  * Parameter is enabled.
307  * It can be viewed, changed and stored.
308  */
309 static const uint PARAMETER_IS_ENABLED = 0x010;
310 
311 /*!
312  * Parameter is automable (real-time safe).
313  */
314 static const uint PARAMETER_IS_AUTOMABLE = 0x020;
315 
316 /*!
317  * Parameter is read-only.
318  * It cannot be changed.
319  */
320 static const uint PARAMETER_IS_READ_ONLY = 0x040;
321 
322 /*!
323  * Parameter needs sample rate to work.
324  * Value and ranges are multiplied by sample rate on usage and divided by sample rate on save.
325  */
326 static const uint PARAMETER_USES_SAMPLERATE = 0x100;
327 
328 /*!
329  * Parameter uses scale points to define internal values in a meaningful way.
330  */
331 static const uint PARAMETER_USES_SCALEPOINTS = 0x200;
332 
333 /*!
334  * Parameter uses custom text for displaying its value.
335  * @see CarlaPlugin::getParameterText() and carla_get_parameter_text()
336  */
337 static const uint PARAMETER_USES_CUSTOM_TEXT = 0x400;
338 
339 /*!
340  * Parameter can be turned into a CV control.
341  */
342 static const uint PARAMETER_CAN_BE_CV_CONTROLLED = 0x800;
343 
344 /*!
345  * Parameter should not be saved as part of the project/session.
346  * @note only valid for parameter inputs.
347  */
348 static const uint PARAMETER_IS_NOT_SAVED = 0x1000;
349 
350 /** @} */
351 
352 /* ------------------------------------------------------------------------------------------------------------
353  * Mapped Parameter Flags */
354 
355 /*!
356  * @defgroup MappedParameterFlags Mapped Parameter Flags
357  *
358  * Various flags for parameter mappings.
359  * @see ParameterData::mappedFlags
360  * @{
361  */
362 
363 /*!
364  * Parameter mapping uses delta value instead of full scale.
365  * Only relevant for MIDI CC mappings.
366  */
367 static const uint PARAMETER_MAPPING_MIDI_DELTA = 0x001;
368 
369 /** @} */
370 
371 /* ------------------------------------------------------------------------------------------------------------
372  * Patchbay Port Hints */
373 
374 /*!
375  * @defgroup PatchbayPortHints Patchbay Port Hints
376  *
377  * Various patchbay port hints.
378  * @{
379  */
380 
381 /*!
382  * Patchbay port is input.
383  * When this hint is not set, port is assumed to be output.
384  */
385 static const uint PATCHBAY_PORT_IS_INPUT = 0x01;
386 
387 /*!
388  * Patchbay port is of Audio type.
389  */
390 static const uint PATCHBAY_PORT_TYPE_AUDIO = 0x02;
391 
392 /*!
393  * Patchbay port is of CV type (Control Voltage).
394  */
395 static const uint PATCHBAY_PORT_TYPE_CV = 0x04;
396 
397 /*!
398  * Patchbay port is of MIDI type.
399  */
400 static const uint PATCHBAY_PORT_TYPE_MIDI = 0x08;
401 
402 /*!
403  * Patchbay port is of OSC type.
404  */
405 static const uint PATCHBAY_PORT_TYPE_OSC = 0x10;
406 
407 /** @} */
408 
409 /* ------------------------------------------------------------------------------------------------------------
410  * Patchbay Port Group Hints */
411 
412 /*!
413  * @defgroup PatchbayPortGroupHints Patchbay Port Group Hints
414  *
415  * Various patchbay port group hints.
416  * @{
417  */
418 
419 /*!
420  * Indicates that this group should be considered the "main" input.
421  */
422 static const uint PATCHBAY_PORT_GROUP_MAIN_INPUT = 0x01;
423 
424 /*!
425  * Indicates that this group should be considered the "main" output.
426  */
427 static const uint PATCHBAY_PORT_GROUP_MAIN_OUTPUT = 0x02;
428 
429 /*!
430  * A stereo port group, where the 1st port is left and the 2nd is right.
431  */
432 static const uint PATCHBAY_PORT_GROUP_STEREO = 0x04;
433 
434 /*!
435  * A mid-side stereo group, where the 1st port is center and the 2nd is side.
436  */
437 static const uint PATCHBAY_PORT_GROUP_MID_SIDE = 0x08;
438 
439 /** @} */
440 
441 /* ------------------------------------------------------------------------------------------------------------
442  * Custom Data Types */
443 
444 /*!
445  * @defgroup CustomDataTypes Custom Data Types
446  *
447  * These types define how the value in the CustomData struct is stored.
448  * @see CustomData::type
449  * @{
450  */
451 
452 /*!
453  * Boolean string type URI.
454  * Only "true" and "false" are valid values.
455  */
456 static const char* const CUSTOM_DATA_TYPE_BOOLEAN = "http://kxstudio.sf.net/ns/carla/boolean";
457 
458 /*!
459  * Chunk type URI.
460  */
461 static const char* const CUSTOM_DATA_TYPE_CHUNK = "http://kxstudio.sf.net/ns/carla/chunk";
462 
463 /*!
464  * Property type URI.
465  */
466 static const char* const CUSTOM_DATA_TYPE_PROPERTY = "http://kxstudio.sf.net/ns/carla/property";
467 
468 /*!
469  * String type URI.
470  */
471 static const char* const CUSTOM_DATA_TYPE_STRING = "http://kxstudio.sf.net/ns/carla/string";
472 
473 /** @} */
474 
475 /* ------------------------------------------------------------------------------------------------------------
476  * Custom Data Keys */
477 
478 /*!
479  * @defgroup CustomDataKeys Custom Data Keys
480  *
481  * Pre-defined keys used internally in Carla.
482  * @see CustomData::key
483  * @{
484  */
485 
486 /*!
487  * UI position key.
488  */
489 static const char* const CUSTOM_DATA_KEY_UI_POSITION = "CarlaUiPosition";
490 
491 /*!
492  * UI size key.
493  */
494 static const char* const CUSTOM_DATA_KEY_UI_SIZE = "CarlaUiSize";
495 
496 /*!
497  * UI visible key.
498  */
499 static const char* const CUSTOM_DATA_KEY_UI_VISIBLE = "CarlaUiVisible";
500 
501 /** @} */
502 
503 /* ------------------------------------------------------------------------------------------------------------
504  * Binary Type */
505 
506 /*!
507  * The binary type of a plugin.
508  */
509 typedef enum {
510     /*!
511      * Null binary type.
512      */
513     BINARY_NONE = 0,
514 
515     /*!
516      * POSIX 32bit binary.
517      */
518     BINARY_POSIX32 = 1,
519 
520     /*!
521      * POSIX 64bit binary.
522      */
523     BINARY_POSIX64 = 2,
524 
525     /*!
526      * Windows 32bit binary.
527      */
528     BINARY_WIN32 = 3,
529 
530     /*!
531      * Windows 64bit binary.
532      */
533     BINARY_WIN64 = 4,
534 
535     /*!
536      * Other binary type.
537      */
538     BINARY_OTHER = 5
539 
540 } BinaryType;
541 
542 /* ------------------------------------------------------------------------------------------------------------
543  * File Type */
544 
545 /*!
546  * File type.
547  */
548 typedef enum {
549     /*!
550      * Null file type.
551      */
552     FILE_NONE = 0,
553 
554     /*!
555      * Audio file.
556      */
557     FILE_AUDIO = 1,
558 
559     /*!
560      * MIDI file.
561      */
562     FILE_MIDI = 2
563 
564 } FileType;
565 
566 /* ------------------------------------------------------------------------------------------------------------
567  * Plugin Type */
568 
569 /*!
570  * Plugin type.
571  * Some files are handled as if they were plugins.
572  */
573 typedef enum {
574     /*!
575      * Null plugin type.
576      */
577     PLUGIN_NONE = 0,
578 
579     /*!
580      * Internal plugin.
581      */
582     PLUGIN_INTERNAL = 1,
583 
584     /*!
585      * LADSPA plugin.
586      */
587     PLUGIN_LADSPA = 2,
588 
589     /*!
590      * DSSI plugin.
591      */
592     PLUGIN_DSSI = 3,
593 
594     /*!
595      * LV2 plugin.
596      */
597     PLUGIN_LV2 = 4,
598 
599     /*!
600      * VST2 plugin.
601      */
602     PLUGIN_VST2 = 5,
603 
604     /*!
605      * VST3 plugin.
606      * @note Windows and MacOS only
607      */
608     PLUGIN_VST3 = 6,
609 
610     /*!
611      * AU plugin.
612      * @note MacOS only
613      */
614     PLUGIN_AU = 7,
615 
616     /*!
617      * DLS file.
618      */
619     PLUGIN_DLS = 8,
620 
621     /*!
622      * GIG file.
623      */
624     PLUGIN_GIG = 9,
625 
626     /*!
627      * SF2/3 file (SoundFont).
628      */
629     PLUGIN_SF2 = 10,
630 
631     /*!
632      * SFZ file.
633      */
634     PLUGIN_SFZ = 11,
635 
636     /*!
637      * JACK application.
638      */
639     PLUGIN_JACK = 12
640 
641 } PluginType;
642 
643 /* ------------------------------------------------------------------------------------------------------------
644  * Plugin Category */
645 
646 /*!
647  * Plugin category, which describes the functionality of a plugin.
648  */
649 typedef enum {
650     /*!
651      * Null plugin category.
652      */
653     PLUGIN_CATEGORY_NONE = 0,
654 
655     /*!
656      * A synthesizer or generator.
657      */
658     PLUGIN_CATEGORY_SYNTH = 1,
659 
660     /*!
661      * A delay or reverb.
662      */
663     PLUGIN_CATEGORY_DELAY = 2,
664 
665     /*!
666      * An equalizer.
667      */
668     PLUGIN_CATEGORY_EQ = 3,
669 
670     /*!
671      * A filter.
672      */
673     PLUGIN_CATEGORY_FILTER = 4,
674 
675     /*!
676      * A distortion plugin.
677      */
678     PLUGIN_CATEGORY_DISTORTION = 5,
679 
680     /*!
681      * A 'dynamic' plugin (amplifier, compressor, gate, etc).
682      */
683     PLUGIN_CATEGORY_DYNAMICS = 6,
684 
685     /*!
686      * A 'modulator' plugin (chorus, flanger, phaser, etc).
687      */
688     PLUGIN_CATEGORY_MODULATOR = 7,
689 
690     /*!
691      * An 'utility' plugin (analyzer, converter, mixer, etc).
692      */
693     PLUGIN_CATEGORY_UTILITY = 8,
694 
695     /*!
696      * Miscellaneous plugin (used to check if the plugin has a category).
697      */
698     PLUGIN_CATEGORY_OTHER = 9
699 
700 } PluginCategory;
701 
702 /* ------------------------------------------------------------------------------------------------------------
703  * Parameter Type */
704 
705 /*!
706  * Plugin parameter type.
707  */
708 typedef enum {
709     /*!
710      * Null parameter type.
711      */
712     PARAMETER_UNKNOWN = 0,
713 
714     /*!
715      * Input parameter.
716      */
717     PARAMETER_INPUT = 1,
718 
719     /*!
720      * Output parameter.
721      */
722     PARAMETER_OUTPUT = 2
723 
724 } ParameterType;
725 
726 /* ------------------------------------------------------------------------------------------------------------
727  * Internal Parameter Index */
728 
729 /*!
730  * Special parameters used internally in Carla.
731  * Plugins do not know about their existence.
732  */
733 typedef enum {
734     /*!
735      * Null parameter.
736      */
737     PARAMETER_NULL = -1,
738 
739 #ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
740     /*!
741      * Active parameter, boolean type.
742      * Default is 'false'.
743      */
744     PARAMETER_ACTIVE = -2,
745 
746     /*!
747      * Dry/Wet parameter.
748      * Range 0.0...1.0; default is 1.0.
749      */
750     PARAMETER_DRYWET = -3,
751 
752     /*!
753      * Volume parameter.
754      * Range 0.0...1.27; default is 1.0.
755      */
756     PARAMETER_VOLUME = -4,
757 
758     /*!
759      * Stereo Balance-Left parameter.
760      * Range -1.0...1.0; default is -1.0.
761      */
762     PARAMETER_BALANCE_LEFT = -5,
763 
764     /*!
765      * Stereo Balance-Right parameter.
766      * Range -1.0...1.0; default is 1.0.
767      */
768     PARAMETER_BALANCE_RIGHT = -6,
769 
770     /*!
771      * Mono Panning parameter.
772      * Range -1.0...1.0; default is 0.0.
773      */
774     PARAMETER_PANNING = -7,
775 
776     /*!
777      * MIDI Control channel, integer type.
778      * Range -1...15 (-1 = off).
779      */
780     PARAMETER_CTRL_CHANNEL = -8,
781 #endif
782 
783     /*!
784      * Max value, defined only for convenience.
785      */
786     PARAMETER_MAX = -9
787 
788 } InternalParameterIndex;
789 
790 /* ------------------------------------------------------------------------------------------------------------
791  * Special Mapped Control Index */
792 
793 /*!
794  * Specially designated mapped control indexes.
795  * Values between 0 and 119 (0x77) are reserved for MIDI CC, which uses direct values.
796  * @see ParameterData::mappedControlIndex
797  */
798 typedef enum {
799     /*!
800      * Unused control index, meaning no mapping is enabled.
801      */
802     CONTROL_INDEX_NONE = -1,
803 
804     /*!
805      * CV control index, meaning the parameter is exposed as CV port.
806      */
807     CONTROL_INDEX_CV = 130,
808 
809     /*!
810      * Special value to indicate MIDI pitchbend.
811      */
812     CONTROL_INDEX_MIDI_PITCHBEND = 131,
813 
814     /*!
815      * Special value to indicate MIDI learn.
816      */
817     CONTROL_INDEX_MIDI_LEARN = 132,
818 
819     /*!
820      * Highest index allowed for mappings.
821      */
822     CONTROL_INDEX_MAX_ALLOWED = CONTROL_INDEX_MIDI_LEARN
823 
824 } SpecialMappedControlIndex;
825 
826 /* ------------------------------------------------------------------------------------------------------------
827  * Engine Callback Opcode */
828 
829 /*!
830  * Engine callback opcodes.
831  * Front-ends must never block indefinitely during a callback.
832  * @see EngineCallbackFunc, CarlaEngine::setCallback() and carla_set_engine_callback()
833  */
834 typedef enum {
835     /*!
836      * Debug.
837      * This opcode is undefined and used only for testing purposes.
838      */
839     ENGINE_CALLBACK_DEBUG = 0,
840 
841     /*!
842      * A plugin has been added.
843      * @a pluginId Plugin Id
844      * @a valueStr Plugin name
845      */
846     ENGINE_CALLBACK_PLUGIN_ADDED = 1,
847 
848     /*!
849      * A plugin has been removed.
850      * @a pluginId Plugin Id
851      */
852     ENGINE_CALLBACK_PLUGIN_REMOVED = 2,
853 
854     /*!
855      * A plugin has been renamed.
856      * @a pluginId Plugin Id
857      * @a valueStr New plugin name
858      */
859     ENGINE_CALLBACK_PLUGIN_RENAMED = 3,
860 
861     /*!
862      * A plugin has become unavailable.
863      * @a pluginId Plugin Id
864      * @a valueStr Related error string
865      */
866     ENGINE_CALLBACK_PLUGIN_UNAVAILABLE = 4,
867 
868     /*!
869      * A parameter value has changed.
870      * @a pluginId Plugin Id
871      * @a value1   Parameter index
872      * @a valuef   New parameter value
873      */
874     ENGINE_CALLBACK_PARAMETER_VALUE_CHANGED = 5,
875 
876     /*!
877      * A parameter default has changed.
878      * @a pluginId Plugin Id
879      * @a value1   Parameter index
880      * @a valuef   New default value
881      */
882     ENGINE_CALLBACK_PARAMETER_DEFAULT_CHANGED = 6,
883 
884 #ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
885     /*!
886      * A parameter's mapped control index has changed.
887      * @a pluginId Plugin Id
888      * @a value1   Parameter index
889      * @a value2   New control index
890      */
891     ENGINE_CALLBACK_PARAMETER_MAPPED_CONTROL_INDEX_CHANGED = 7,
892 
893     /*!
894      * A parameter's MIDI channel has changed.
895      * @a pluginId Plugin Id
896      * @a value1   Parameter index
897      * @a value2   New MIDI channel
898      */
899     ENGINE_CALLBACK_PARAMETER_MIDI_CHANNEL_CHANGED = 8,
900 
901     /*!
902      * A plugin option has changed.
903      * @a pluginId Plugin Id
904      * @a value1   Option
905      * @a value2   New on/off state (1 for on, 0 for off)
906      * @see PluginOptions
907      */
908     ENGINE_CALLBACK_OPTION_CHANGED = 9,
909 #endif
910 
911     /*!
912      * The current program of a plugin has changed.
913      * @a pluginId Plugin Id
914      * @a value1   New program index
915      */
916     ENGINE_CALLBACK_PROGRAM_CHANGED = 10,
917 
918     /*!
919      * The current MIDI program of a plugin has changed.
920      * @a pluginId Plugin Id
921      * @a value1   New MIDI program index
922      */
923     ENGINE_CALLBACK_MIDI_PROGRAM_CHANGED = 11,
924 
925     /*!
926      * A plugin's custom UI state has changed.
927      * @a pluginId Plugin Id
928      * @a value1   New state, as follows:
929      *                  0: UI is now hidden
930      *                  1: UI is now visible
931      *                 -1: UI has crashed and should not be shown again
932      */
933     ENGINE_CALLBACK_UI_STATE_CHANGED = 12,
934 
935     /*!
936      * A note has been pressed.
937      * @a pluginId Plugin Id
938      * @a value1   Channel
939      * @a value2   Note
940      * @a value3   Velocity
941      */
942     ENGINE_CALLBACK_NOTE_ON = 13,
943 
944     /*!
945      * A note has been released.
946      * @a pluginId Plugin Id
947      * @a value1   Channel
948      * @a value2   Note
949      */
950     ENGINE_CALLBACK_NOTE_OFF = 14,
951 
952     /*!
953      * A plugin needs update.
954      * @a pluginId Plugin Id
955      */
956     ENGINE_CALLBACK_UPDATE = 15,
957 
958     /*!
959      * A plugin's data/information has changed.
960      * @a pluginId Plugin Id
961      */
962     ENGINE_CALLBACK_RELOAD_INFO = 16,
963 
964     /*!
965      * A plugin's parameters have changed.
966      * @a pluginId Plugin Id
967      */
968     ENGINE_CALLBACK_RELOAD_PARAMETERS = 17,
969 
970     /*!
971      * A plugin's programs have changed.
972      * @a pluginId Plugin Id
973      */
974     ENGINE_CALLBACK_RELOAD_PROGRAMS = 18,
975 
976     /*!
977      * A plugin state has changed.
978      * @a pluginId Plugin Id
979      */
980     ENGINE_CALLBACK_RELOAD_ALL = 19,
981 
982 #ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
983     /*!
984      * A patchbay client has been added.
985      * @a pluginId Client Id
986      * @a value1   Client icon
987      * @a value2   Plugin Id (-1 if not a plugin)
988      * @a valueStr Client name
989      * @see PatchbayIcon
990      */
991     ENGINE_CALLBACK_PATCHBAY_CLIENT_ADDED = 20,
992 
993     /*!
994      * A patchbay client has been removed.
995      * @a pluginId Client Id
996      */
997     ENGINE_CALLBACK_PATCHBAY_CLIENT_REMOVED = 21,
998 
999     /*!
1000      * A patchbay client has been renamed.
1001      * @a pluginId Client Id
1002      * @a valueStr New client name
1003      */
1004     ENGINE_CALLBACK_PATCHBAY_CLIENT_RENAMED = 22,
1005 
1006     /*!
1007      * A patchbay client data has changed.
1008      * @a pluginId Client Id
1009      * @a value1   New icon
1010      * @a value2   New plugin Id (-1 if not a plugin)
1011      * @see PatchbayIcon
1012      */
1013     ENGINE_CALLBACK_PATCHBAY_CLIENT_DATA_CHANGED = 23,
1014 
1015     /*!
1016      * A patchbay port has been added.
1017      * @a pluginId Client Id
1018      * @a value1   Port Id
1019      * @a value2   Port hints
1020      * @a value3   Port group Id (0 for none)
1021      * @a valueStr Port name
1022      * @see PatchbayPortHints
1023      */
1024     ENGINE_CALLBACK_PATCHBAY_PORT_ADDED = 24,
1025 
1026     /*!
1027      * A patchbay port has been removed.
1028      * @a pluginId Client Id
1029      * @a value1   Port Id
1030      */
1031     ENGINE_CALLBACK_PATCHBAY_PORT_REMOVED = 25,
1032 
1033     /*!
1034      * A patchbay port has changed (like the name or group Id).
1035      * @a pluginId Client Id
1036      * @a value1   Port Id
1037      * @a value2   Port hints
1038      * @a value3   Port group Id (0 for none)
1039      * @a valueStr Port name
1040      */
1041     ENGINE_CALLBACK_PATCHBAY_PORT_CHANGED = 26,
1042 
1043     /*!
1044      * A patchbay connection has been added.
1045      * @a pluginId Connection Id
1046      * @a valueStr Out group and port plus in group and port, in "og:op:ig:ip" syntax.
1047      */
1048     ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED = 27,
1049 
1050     /*!
1051      * A patchbay connection has been removed.
1052      * @a pluginId Connection Id
1053      */
1054     ENGINE_CALLBACK_PATCHBAY_CONNECTION_REMOVED = 28,
1055 #endif
1056 
1057     /*!
1058      * Engine started.
1059      * @a pluginId How many plugins are known to be running
1060      * @a value1   Process mode
1061      * @a value2   Transport mode
1062      * @a value3   Buffer size
1063      * @a valuef   Sample rate
1064      * @a valuestr Engine driver
1065      * @see EngineProcessMode
1066      * @see EngineTransportMode
1067      */
1068     ENGINE_CALLBACK_ENGINE_STARTED = 29,
1069 
1070     /*!
1071      * Engine stopped.
1072      */
1073     ENGINE_CALLBACK_ENGINE_STOPPED = 30,
1074 
1075     /*!
1076      * Engine process mode has changed.
1077      * @a value1 New process mode
1078      * @see EngineProcessMode
1079      */
1080     ENGINE_CALLBACK_PROCESS_MODE_CHANGED = 31,
1081 
1082     /*!
1083      * Engine transport mode has changed.
1084      * @a value1   New transport mode
1085      * @a valueStr New transport features enabled
1086      * @see EngineTransportMode
1087      */
1088     ENGINE_CALLBACK_TRANSPORT_MODE_CHANGED = 32,
1089 
1090     /*!
1091      * Engine buffer-size changed.
1092      * @a value1 New buffer size
1093      */
1094     ENGINE_CALLBACK_BUFFER_SIZE_CHANGED = 33,
1095 
1096     /*!
1097      * Engine sample-rate changed.
1098      * @a valuef New sample rate
1099      */
1100     ENGINE_CALLBACK_SAMPLE_RATE_CHANGED = 34,
1101 
1102     /*!
1103      * A cancelable action has been started or stopped.
1104      * @a pluginId Plugin Id the action relates to, -1 for none
1105      * @a value1   1 for action started, 0 for stopped
1106      * @a valueStr Action name
1107      */
1108     ENGINE_CALLBACK_CANCELABLE_ACTION = 35,
1109 
1110     /*!
1111      * Project has finished loading.
1112      */
1113     ENGINE_CALLBACK_PROJECT_LOAD_FINISHED = 36,
1114 
1115     /*!
1116      * NSM callback, to be handled by a frontend.
1117      * Frontend must call carla_nsm_ready() with opcode as parameter as a response
1118      * @a value1   NSM opcode
1119      * @a value2   Integer value
1120      * @a valueStr String value
1121      * @see NsmCallbackOpcode
1122      */
1123     ENGINE_CALLBACK_NSM = 37,
1124 
1125     /*!
1126      * Idle frontend.
1127      * This is used by the engine during long operations that might block the frontend,
1128      * giving it the possibility to idle while the operation is still in place.
1129      */
1130     ENGINE_CALLBACK_IDLE = 38,
1131 
1132     /*!
1133      * Show a message as information.
1134      * @a valueStr The message
1135      */
1136     ENGINE_CALLBACK_INFO = 39,
1137 
1138     /*!
1139      * Show a message as an error.
1140      * @a valueStr The message
1141      */
1142     ENGINE_CALLBACK_ERROR = 40,
1143 
1144     /*!
1145      * The engine has crashed or malfunctioned and will no longer work.
1146      */
1147     ENGINE_CALLBACK_QUIT = 41,
1148 
1149     /*!
1150      * A plugin requested for its inline display to be redrawn.
1151      * @a pluginId Plugin Id to redraw
1152      */
1153     ENGINE_CALLBACK_INLINE_DISPLAY_REDRAW = 42,
1154 
1155     /*!
1156      * A patchbay port group has been added.
1157      * @a pluginId Client Id
1158      * @a value1   Group Id (unique value within this client)
1159      * @a value2   Group hints
1160      * @a valueStr Group name
1161      * @see PatchbayPortGroupHints
1162      */
1163     ENGINE_CALLBACK_PATCHBAY_PORT_GROUP_ADDED = 43,
1164 
1165     /*!
1166      * A patchbay port group has been removed.
1167      * @a pluginId Client Id
1168      * @a value1   Group Id
1169      */
1170     ENGINE_CALLBACK_PATCHBAY_PORT_GROUP_REMOVED = 44,
1171 
1172     /*!
1173      * A patchbay port group has changed.
1174      * @a pluginId Client Id
1175      * @a value1   Group Id
1176      * @a value2   Group hints
1177      * @a valueStr Group name
1178      * @see PatchbayPortGroupHints
1179      */
1180     ENGINE_CALLBACK_PATCHBAY_PORT_GROUP_CHANGED = 45,
1181 
1182     /*!
1183      * A parameter's mapped range has changed.
1184      * @a pluginId Plugin Id
1185      * @a value1   Parameter index
1186      * @a valueStr New mapped range as "%f:%f" syntax
1187      */
1188     ENGINE_CALLBACK_PARAMETER_MAPPED_RANGE_CHANGED = 46,
1189 
1190     /*!
1191      * A patchbay client position has changed.
1192      * @a pluginId Client Id
1193      * @a value1   X position 1
1194      * @a value2   Y position 1
1195      * @a value3   X position 2
1196      * @a valuef   Y position 2
1197      */
1198     ENGINE_CALLBACK_PATCHBAY_CLIENT_POSITION_CHANGED = 47,
1199 
1200     /*!
1201      * A plugin embed UI has been resized.
1202      * @a pluginId Plugin Id to resize
1203      * @a value1   New width
1204      * @a value2   New height
1205      */
1206     ENGINE_CALLBACK_EMBED_UI_RESIZED = 48
1207 
1208 } EngineCallbackOpcode;
1209 
1210 /* ------------------------------------------------------------------------------------------------------------
1211  * NSM Callback Opcode */
1212 
1213 /*!
1214  * NSM callback opcodes.
1215  * @see ENGINE_CALLBACK_NSM
1216  */
1217 typedef enum {
1218     /*!
1219      * NSM is available and initialized.
1220      */
1221     NSM_CALLBACK_INIT = 0,
1222 
1223     /*!
1224      * Error from NSM side.
1225      * @a valueInt Error code
1226      * @a valueStr Error string
1227      */
1228     NSM_CALLBACK_ERROR = 1,
1229 
1230     /*!
1231      * Announce message.
1232      * @a valueInt SM Flags (WIP, to be defined)
1233      * @a valueStr SM Name
1234      */
1235     NSM_CALLBACK_ANNOUNCE = 2,
1236 
1237     /*!
1238      * Open message.
1239      * @a valueStr Project filename
1240      */
1241     NSM_CALLBACK_OPEN = 3,
1242 
1243     /*!
1244      * Save message.
1245      */
1246     NSM_CALLBACK_SAVE = 4,
1247 
1248     /*!
1249      * Session-is-loaded message.
1250      */
1251     NSM_CALLBACK_SESSION_IS_LOADED = 5,
1252 
1253     /*!
1254      * Show-optional-gui message.
1255      */
1256     NSM_CALLBACK_SHOW_OPTIONAL_GUI = 6,
1257 
1258     /*!
1259      * Hide-optional-gui message.
1260      */
1261     NSM_CALLBACK_HIDE_OPTIONAL_GUI = 7,
1262 
1263     /*!
1264      * Set client name id message.
1265      */
1266     NSM_CALLBACK_SET_CLIENT_NAME_ID = 8
1267 
1268 } NsmCallbackOpcode;
1269 
1270 /* ------------------------------------------------------------------------------------------------------------
1271  * Engine Option */
1272 
1273 /*!
1274  * Engine options.
1275  * @see CarlaEngine::getOptions(), CarlaEngine::setOption() and carla_set_engine_option()
1276  */
1277 typedef enum {
1278     /*!
1279      * Debug.
1280      * This option is undefined and used only for testing purposes.
1281      */
1282     ENGINE_OPTION_DEBUG = 0,
1283 
1284     /*!
1285      * Set the engine processing mode.
1286      * Default is ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS on Linux and ENGINE_PROCESS_MODE_PATCHBAY for all other OSes.
1287      * @see EngineProcessMode
1288      */
1289     ENGINE_OPTION_PROCESS_MODE = 1,
1290 
1291     /*!
1292      * Set the engine transport mode.
1293      * Default is ENGINE_TRANSPORT_MODE_JACK on Linux and ENGINE_TRANSPORT_MODE_INTERNAL for all other OSes.
1294      * @see EngineTransportMode
1295      */
1296     ENGINE_OPTION_TRANSPORT_MODE = 2,
1297 
1298     /*!
1299      * Force mono plugins as stereo, by running 2 instances at the same time.
1300      * Default is false, but always true when process mode is ENGINE_PROCESS_MODE_CONTINUOUS_RACK.
1301      * @note Not supported by all plugins
1302      * @see PLUGIN_OPTION_FORCE_STEREO
1303      */
1304     ENGINE_OPTION_FORCE_STEREO = 3,
1305 
1306     /*!
1307      * Use plugin bridges whenever possible.
1308      * Default is no, EXPERIMENTAL.
1309      */
1310     ENGINE_OPTION_PREFER_PLUGIN_BRIDGES = 4,
1311 
1312     /*!
1313      * Use UI bridges whenever possible, otherwise UIs will be directly handled in the main backend thread.
1314      * Default is yes.
1315      */
1316     ENGINE_OPTION_PREFER_UI_BRIDGES = 5,
1317 
1318     /*!
1319      * Make custom plugin UIs always-on-top.
1320      * Default is yes.
1321      */
1322     ENGINE_OPTION_UIS_ALWAYS_ON_TOP = 6,
1323 
1324     /*!
1325      * Maximum number of parameters allowed.
1326      * Default is MAX_DEFAULT_PARAMETERS.
1327      */
1328     ENGINE_OPTION_MAX_PARAMETERS = 7,
1329 
1330     /*!
1331      * Reset Xrun counter after project load.
1332      */
1333     ENGINE_OPTION_RESET_XRUNS = 8,
1334 
1335     /*!
1336      * Timeout value for how much to wait for UI bridges to respond, in milliseconds.
1337      * Default is 4000 (4 seconds).
1338      */
1339     ENGINE_OPTION_UI_BRIDGES_TIMEOUT = 9,
1340 
1341     /*!
1342      * Audio buffer size.
1343      * Default is 512.
1344      */
1345     ENGINE_OPTION_AUDIO_BUFFER_SIZE = 10,
1346 
1347     /*!
1348      * Audio sample rate.
1349      * Default is 44100.
1350      */
1351     ENGINE_OPTION_AUDIO_SAMPLE_RATE = 11,
1352 
1353     /*!
1354      * Wherever to use 3 audio periods instead of the default 2.
1355      * Default is false.
1356      */
1357     ENGINE_OPTION_AUDIO_TRIPLE_BUFFER = 12,
1358 
1359     /*!
1360      * Audio driver.
1361      * Default depends on platform.
1362      */
1363     ENGINE_OPTION_AUDIO_DRIVER = 13,
1364 
1365     /*!
1366      * Audio device (within a driver).
1367      * Default unset.
1368      */
1369     ENGINE_OPTION_AUDIO_DEVICE = 14,
1370 
1371 #ifndef BUILD_BRIDGE
1372     /*!
1373      * Wherever to enable OSC support in the engine.
1374      */
1375     ENGINE_OPTION_OSC_ENABLED = 15,
1376 
1377     /*!
1378      * The network TCP port to use for OSC.
1379      * A value of 0 means use a random port.
1380      * A value of < 0 means to not enable the TCP port for OSC.
1381      * @note Valid ports begin at 1024 and end at 32767 (inclusive)
1382      */
1383     ENGINE_OPTION_OSC_PORT_TCP = 16,
1384 
1385     /*!
1386      * The network UDP port to use for OSC.
1387      * A value of 0 means use a random port.
1388      * A value of < 0 means to not enable the UDP port for OSC.
1389      * @note Disabling this option prevents DSSI UIs from working!
1390      * @note Valid ports begin at 1024 and end at 32767 (inclusive)
1391      */
1392     ENGINE_OPTION_OSC_PORT_UDP = 17,
1393 #endif
1394 
1395     /*!
1396      * Set path used for a specific file type.
1397      * Uses value as the file format, valueStr as actual path.
1398      */
1399     ENGINE_OPTION_FILE_PATH = 18,
1400 
1401     /*!
1402      * Set path used for a specific plugin type.
1403      * Uses value as the plugin format, valueStr as actual path.
1404      * @see PluginType
1405      */
1406     ENGINE_OPTION_PLUGIN_PATH = 19,
1407 
1408     /*!
1409      * Set path to the binary files.
1410      * Default unset.
1411      * @note Must be set for plugin and UI bridges to work
1412      */
1413     ENGINE_OPTION_PATH_BINARIES = 20,
1414 
1415     /*!
1416      * Set path to the resource files.
1417      * Default unset.
1418      * @note Must be set for some internal plugins to work
1419      */
1420     ENGINE_OPTION_PATH_RESOURCES = 21,
1421 
1422     /*!
1423      * Prevent bad plugin and UI behaviour.
1424      * @note: Linux only
1425      */
1426     ENGINE_OPTION_PREVENT_BAD_BEHAVIOUR = 22,
1427 
1428     /*!
1429      * Set background color used in the frontend, so backend can do the same for plugin UIs.
1430      */
1431     ENGINE_OPTION_FRONTEND_BACKGROUND_COLOR = 23,
1432 
1433     /*!
1434      * Set foreground color used in the frontend, so backend can do the same for plugin UIs.
1435      */
1436     ENGINE_OPTION_FRONTEND_FOREGROUND_COLOR = 24,
1437 
1438     /*!
1439      * Set UI scaling used in the frontend, so backend can do the same for plugin UIs.
1440      */
1441     ENGINE_OPTION_FRONTEND_UI_SCALE = 25,
1442 
1443     /*!
1444      * Set frontend winId, used to define as parent window for plugin UIs.
1445      */
1446     ENGINE_OPTION_FRONTEND_WIN_ID = 26,
1447 
1448 #if !defined(BUILD_BRIDGE_ALTERNATIVE_ARCH) && !defined(CARLA_OS_WIN)
1449     /*!
1450      * Set path to wine executable.
1451      */
1452     ENGINE_OPTION_WINE_EXECUTABLE = 27,
1453 
1454     /*!
1455      * Enable automatic wineprefix detection.
1456      */
1457     ENGINE_OPTION_WINE_AUTO_PREFIX = 28,
1458 
1459     /*!
1460      * Fallback wineprefix to use if automatic detection fails or is disabled, and WINEPREFIX is not set.
1461      */
1462     ENGINE_OPTION_WINE_FALLBACK_PREFIX = 29,
1463 
1464     /*!
1465      * Enable realtime priority for Wine application and server threads.
1466      */
1467     ENGINE_OPTION_WINE_RT_PRIO_ENABLED = 30,
1468 
1469     /*!
1470      * Base realtime priority for Wine threads.
1471      */
1472     ENGINE_OPTION_WINE_BASE_RT_PRIO = 31,
1473 
1474     /*!
1475      * Wine server realtime priority.
1476      */
1477     ENGINE_OPTION_WINE_SERVER_RT_PRIO = 32,
1478 #endif
1479 
1480 #ifndef BUILD_BRIDGE
1481     /*!
1482      * Capture console output into debug callbacks.
1483      */
1484     ENGINE_OPTION_DEBUG_CONSOLE_OUTPUT = 33,
1485 #endif
1486 
1487     /*!
1488      * A prefix to give to all plugin clients created by Carla.
1489      * Mostly useful for JACK multi-client mode.
1490      * @note MUST include at least one "." (dot).
1491      */
1492     ENGINE_OPTION_CLIENT_NAME_PREFIX = 34,
1493 
1494     /*!
1495      * Treat loaded plugins as standalone (that is, there is no host UI to manage them)
1496      */
1497     ENGINE_OPTION_PLUGINS_ARE_STANDALONE = 35
1498 
1499 } EngineOption;
1500 
1501 /* ------------------------------------------------------------------------------------------------------------
1502  * Engine Process Mode */
1503 
1504 /*!
1505  * Engine process mode.
1506  * @see ENGINE_OPTION_PROCESS_MODE
1507  */
1508 typedef enum {
1509     /*!
1510      * Single client mode.
1511      * Inputs and outputs are added dynamically as needed by plugins.
1512      */
1513     ENGINE_PROCESS_MODE_SINGLE_CLIENT = 0,
1514 
1515     /*!
1516      * Multiple client mode.
1517      * It has 1 master client + 1 client per plugin.
1518      */
1519     ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS = 1,
1520 
1521     /*!
1522      * Single client, 'rack' mode.
1523      * Processes plugins in order of Id, with forced stereo always on.
1524      */
1525     ENGINE_PROCESS_MODE_CONTINUOUS_RACK = 2,
1526 
1527     /*!
1528      * Single client, 'patchbay' mode.
1529      */
1530     ENGINE_PROCESS_MODE_PATCHBAY = 3,
1531 
1532     /*!
1533      * Special mode, used in plugin-bridges only.
1534      */
1535     ENGINE_PROCESS_MODE_BRIDGE = 4
1536 
1537 } EngineProcessMode;
1538 
1539 /* ------------------------------------------------------------------------------------------------------------
1540  * Engine Transport Mode */
1541 
1542 /*!
1543  * Engine transport mode.
1544  * @see ENGINE_OPTION_TRANSPORT_MODE
1545  */
1546 typedef enum {
1547     /*!
1548      * No transport.
1549      */
1550     ENGINE_TRANSPORT_MODE_DISABLED = 0,
1551 
1552     /*!
1553      * Internal transport mode.
1554      */
1555     ENGINE_TRANSPORT_MODE_INTERNAL = 1,
1556 
1557     /*!
1558      * Transport from JACK.
1559      * Only available if driver name is "JACK".
1560      */
1561     ENGINE_TRANSPORT_MODE_JACK = 2,
1562 
1563     /*!
1564      * Transport from host, used when Carla is a plugin.
1565      */
1566     ENGINE_TRANSPORT_MODE_PLUGIN = 3,
1567 
1568     /*!
1569      * Special mode, used in plugin-bridges only.
1570      */
1571     ENGINE_TRANSPORT_MODE_BRIDGE = 4
1572 
1573 } EngineTransportMode;
1574 
1575 /* ------------------------------------------------------------------------------------------------------------
1576  * File Callback Opcode */
1577 
1578 /*!
1579  * File callback opcodes.
1580  * Front-ends must always block-wait for user input.
1581  * @see FileCallbackFunc, CarlaEngine::setFileCallback() and carla_set_file_callback()
1582  */
1583 typedef enum {
1584     /*!
1585      * Debug.
1586      * This opcode is undefined and used only for testing purposes.
1587      */
1588     FILE_CALLBACK_DEBUG = 0,
1589 
1590     /*!
1591      * Open file or folder.
1592      */
1593     FILE_CALLBACK_OPEN = 1,
1594 
1595     /*!
1596      * Save file or folder.
1597      */
1598     FILE_CALLBACK_SAVE = 2
1599 
1600 } FileCallbackOpcode;
1601 
1602 /* ------------------------------------------------------------------------------------------------------------
1603  * Patchbay Icon */
1604 
1605 /*!
1606  * The icon of a patchbay client/group.
1607  */
1608 enum PatchbayIcon {
1609     /*!
1610      * Generic application icon.
1611      * Used for all non-plugin clients that don't have a specific icon.
1612      */
1613     PATCHBAY_ICON_APPLICATION = 0,
1614 
1615     /*!
1616      * Plugin icon.
1617      * Used for all plugin clients that don't have a specific icon.
1618      */
1619     PATCHBAY_ICON_PLUGIN = 1,
1620 
1621     /*!
1622      * Hardware icon.
1623      * Used for hardware (audio or MIDI) clients.
1624      */
1625     PATCHBAY_ICON_HARDWARE = 2,
1626 
1627     /*!
1628      * Carla icon.
1629      * Used for the main app.
1630      */
1631     PATCHBAY_ICON_CARLA = 3,
1632 
1633     /*!
1634      * DISTRHO icon.
1635      * Used for DISTRHO based plugins.
1636      */
1637     PATCHBAY_ICON_DISTRHO = 4,
1638 
1639     /*!
1640      * File icon.
1641      * Used for file type plugins (like SF2 snd SFZ).
1642      */
1643     PATCHBAY_ICON_FILE = 5
1644 };
1645 
1646 /* ------------------------------------------------------------------------------------------------------------
1647  * Carla Backend API (C stuff) */
1648 
1649 /*!
1650  * Engine callback function.
1651  * Front-ends must never block indefinitely during a callback.
1652  * @see EngineCallbackOpcode, CarlaEngine::setCallback() and carla_set_engine_callback()
1653  */
1654 typedef void (*EngineCallbackFunc)(void* ptr, EngineCallbackOpcode action, uint pluginId,
1655                                    int value1, int value2, int value3,
1656                                    float valuef, const char* valueStr);
1657 
1658 /*!
1659  * File callback function.
1660  * @see FileCallbackOpcode
1661  */
1662 typedef const char* (*FileCallbackFunc)(void* ptr, FileCallbackOpcode action, bool isDir, const char* title, const char* filter);
1663 
1664 /*!
1665  * Parameter data.
1666  */
1667 typedef struct {
1668     /*!
1669      * This parameter type.
1670      */
1671     ParameterType type;
1672 
1673     /*!
1674      * This parameter hints.
1675      * @see ParameterHints
1676      */
1677     uint hints;
1678 
1679     /*!
1680      * Index as seen by Carla.
1681      */
1682     int32_t index;
1683 
1684     /*!
1685      * Real index as seen by plugins.
1686      */
1687     int32_t rindex;
1688 
1689     /*!
1690      * Currently mapped MIDI channel.
1691      * Counts from 0 to 15.
1692      */
1693     uint8_t midiChannel;
1694 
1695     /*!
1696      * Currently mapped index.
1697      * @see SpecialMappedControlIndex
1698      */
1699     int16_t mappedControlIndex;
1700 
1701     /*!
1702      * Minimum value that this parameter maps to.
1703      */
1704     float mappedMinimum;
1705 
1706     /*!
1707      * Maximum value that this parameter maps to.
1708      */
1709     float mappedMaximum;
1710 
1711     /*!
1712      * Flags related to the current mapping of this parameter.
1713      * @see MappedParameterFlags
1714      */
1715     uint mappedFlags;
1716 
1717 } ParameterData;
1718 
1719 /*!
1720  * Parameter ranges.
1721  */
1722 typedef struct _ParameterRanges {
1723     /*!
1724      * Default value.
1725      */
1726     float def;
1727 
1728     /*!
1729      * Minimum value.
1730      */
1731     float min;
1732 
1733     /*!
1734      * Maximum value.
1735      */
1736     float max;
1737 
1738     /*!
1739      * Regular, single step value.
1740      */
1741     float step;
1742 
1743     /*!
1744      * Small step value.
1745      */
1746     float stepSmall;
1747 
1748     /*!
1749      * Large step value.
1750      */
1751     float stepLarge;
1752 
1753 #ifdef __cplusplus
1754     /*!
1755      * Fix the default value within range.
1756      */
fixDefault_ParameterRanges1757     void fixDefault() noexcept
1758     {
1759         fixValue(def);
1760     }
1761 
1762     /*!
1763      * Fix a value within range.
1764      */
fixValue_ParameterRanges1765     void fixValue(float& value) const noexcept
1766     {
1767         if (value < min)
1768             value = min;
1769         else if (value > max)
1770             value = max;
1771     }
1772 
1773     /*!
1774      * Get a fixed value within range.
1775      */
getFixedValue_ParameterRanges1776     const float& getFixedValue(const float& value) const noexcept
1777     {
1778         if (value <= min)
1779             return min;
1780         if (value >= max)
1781             return max;
1782         return value;
1783     }
1784 
1785     /*!
1786      * Get a value normalized to 0.0<->1.0.
1787      */
getNormalizedValue_ParameterRanges1788     float getNormalizedValue(const float& value) const noexcept
1789     {
1790         const float normValue((value - min) / (max - min));
1791 
1792         if (normValue <= 0.0f)
1793             return 0.0f;
1794         if (normValue >= 1.0f)
1795             return 1.0f;
1796         return normValue;
1797     }
1798 
1799     /*!
1800      * Get a value normalized to 0.0<->1.0, fixed within range.
1801      */
getFixedAndNormalizedValue_ParameterRanges1802     float getFixedAndNormalizedValue(const float& value) const noexcept
1803     {
1804         if (value <= min)
1805             return 0.0f;
1806         if (value >= max)
1807             return 1.0f;
1808 
1809         const float normValue((value - min) / (max - min));
1810 
1811         if (normValue <= 0.0f)
1812             return 0.0f;
1813         if (normValue >= 1.0f)
1814             return 1.0f;
1815 
1816         return normValue;
1817     }
1818 
1819     /*!
1820      * Get a proper value previously normalized to 0.0<->1.0.
1821      */
getUnnormalizedValue_ParameterRanges1822     float getUnnormalizedValue(const float& value) const noexcept
1823     {
1824         if (value <= 0.0f)
1825             return min;
1826         if (value >= 1.0f)
1827             return max;
1828 
1829         return value * (max - min) + min;
1830     }
1831 
1832     /*!
1833      * Get a logarithmic value previously normalized to 0.0<->1.0.
1834      */
getUnnormalizedLogValue_ParameterRanges1835     float getUnnormalizedLogValue(const float& value) const noexcept
1836     {
1837         if (value <= 0.0f)
1838             return min;
1839         if (value >= 1.0f)
1840             return max;
1841 
1842         float rmin = min;
1843 
1844         if (std::abs(min) < std::numeric_limits<float>::epsilon())
1845             rmin = 0.00001f;
1846 
1847         return rmin * std::pow(max/rmin, value);
1848     }
1849 #endif /* __cplusplus */
1850 
1851 } ParameterRanges;
1852 
1853 /*!
1854  * MIDI Program data.
1855  */
1856 typedef struct {
1857     /*!
1858      * MIDI bank.
1859      */
1860     uint32_t bank;
1861 
1862     /*!
1863      * MIDI program.
1864      */
1865     uint32_t program;
1866 
1867     /*!
1868      * MIDI program name.
1869      */
1870     const char* name;
1871 
1872 } MidiProgramData;
1873 
1874 /*!
1875  * Custom data, used for saving key:value 'dictionaries'.
1876  */
1877 typedef struct _CustomData {
1878     /*!
1879      * Value type, in URI form.
1880      * @see CustomDataTypes
1881      */
1882     const char* type;
1883 
1884     /*!
1885      * Key.
1886      * @see CustomDataKeys
1887      */
1888     const char* key;
1889 
1890     /*!
1891      * Value.
1892      */
1893     const char* value;
1894 
1895 #ifdef __cplusplus
1896     /*!
1897      * Check if valid.
1898      */
isValid_CustomData1899     bool isValid() const noexcept
1900     {
1901         if (type  == nullptr || type[0] == '\0') return false;
1902         if (key   == nullptr || key [0] == '\0') return false;
1903         if (value == nullptr)                    return false;
1904         return true;
1905     }
1906 #endif /* __cplusplus */
1907 
1908 } CustomData;
1909 
1910 /*!
1911  * Engine driver device information.
1912  */
1913 typedef struct {
1914     /*!
1915      * This driver device hints.
1916      * @see EngineDriverHints
1917      */
1918     uint hints;
1919 
1920     /*!
1921      * Available buffer sizes.
1922      * Terminated with 0.
1923      */
1924     const uint32_t* bufferSizes;
1925 
1926     /*!
1927      * Available sample rates.
1928      * Terminated with 0.0.
1929      */
1930     const double* sampleRates;
1931 
1932 } EngineDriverDeviceInfo;
1933 
1934 /** @} */
1935 
1936 #ifdef __cplusplus
1937 /* Forward declarations of commonly used Carla classes */
1938 class CarlaEngine;
1939 class CarlaEngineClient;
1940 class CarlaEngineCVSourcePorts;
1941 class CarlaPlugin;
1942 /* End namespace */
1943 CARLA_BACKEND_END_NAMESPACE
1944 #endif
1945 
1946 #endif /* CARLA_BACKEND_H_INCLUDED */
1947