Dusk Audio Framework
Loading...
Searching...
No Matches
DafDetails.hpp
1/*
2 * DISTRHO Plugin Framework (DPF)
3 * Copyright (C) 2012-2024 Filipe Coelho <falktx@falktx.com>
4 *
5 * Permission to use, copy, modify, and/or distribute this software for any purpose with
6 * or without fee is hereby granted, provided that the above copyright notice and this
7 * permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
10 * TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
11 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
12 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
13 * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
14 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17#ifndef DAF_DETAILS_HPP_INCLUDED
18#define DAF_DETAILS_HPP_INCLUDED
19
20#include "extra/String.hpp"
21
23
24/* --------------------------------------------------------------------------------------------------------------------
25 * Audio Port Hints */
26
27/**
28 @defgroup AudioPortHints Audio Port Hints
29
30 Various audio port hints.
31 @see AudioPort::hints
32 @{
33 */
34
35/**
36 Audio port can be used as control voltage (LV2 and JACK standalone only).
37 */
38static constexpr const uint32_t kAudioPortIsCV = 0x1;
39
40/**
41 Audio port should be used as sidechan (LV2 and VST3 only).
42 This hint should not be used with CV style ports.
43 @note non-sidechain audio ports must exist in the plugin if this flag is set.
44 */
45static constexpr const uint32_t kAudioPortIsSidechain = 0x2;
46
47/**
48 CV port has bipolar range (-1 to +1, or -5 to +5 if scaled).
49 This is merely a hint to tell the host what value range to expect.
50 */
51static constexpr const uint32_t kCVPortHasBipolarRange = 0x10;
52
53/**
54 CV port has negative unipolar range (-1 to 0, or -10 to 0 if scaled).
55 This is merely a hint to tell the host what value range to expect.
56 */
57static constexpr const uint32_t kCVPortHasNegativeUnipolarRange = 0x20;
58
59/**
60 CV port has positive unipolar range (0 to +1, or 0 to +10 if scaled).
61 This is merely a hint to tell the host what value range to expect.
62 */
63static constexpr const uint32_t kCVPortHasPositiveUnipolarRange = 0x40;
64
65/**
66 CV port has scaled range to match real values (-5 to +5v bipolar, +/-10 to 0v unipolar).
67 One other range flag is required if this flag is set.
68
69 When enabled, this makes the port a mod:CVPort, compatible with the MOD Devices platform.
70 */
71static constexpr const uint32_t kCVPortHasScaledRange = 0x80;
72
73/**
74 CV port is optional, allowing hosts that do no CV ports to load the plugin.
75 When loaded in hosts that don't support CV, the float* buffer for this port will be null.
76 */
77static constexpr const uint32_t kCVPortIsOptional = 0x100;
78
79/** @} */
80
81/* --------------------------------------------------------------------------------------------------------------------
82 * Parameter Hints */
83
84/**
85 @defgroup ParameterHints Parameter Hints
86
87 Various parameter hints.
88 @see Parameter::hints
89 @{
90 */
91
92/**
93 Parameter is automatable (real-time safe).
94 @see Plugin::setParameterValue(uint32_t, float)
95 */
96static constexpr const uint32_t kParameterIsAutomatable = 0x01;
97
98/** It was a typo, sorry.. */
99DAF_DEPRECATED_BY("kParameterIsAutomatable")
100static constexpr const uint32_t kParameterIsAutomable = kParameterIsAutomatable;
101
102/**
103 Parameter value is boolean.@n
104 It's always at either minimum or maximum value.
105 */
106static constexpr const uint32_t kParameterIsBoolean = 0x02;
107
108/**
109 Parameter value is integer.
110 */
111static constexpr const uint32_t kParameterIsInteger = 0x04;
112
113/**
114 Parameter value is logarithmic.
115 */
116static constexpr const uint32_t kParameterIsLogarithmic = 0x08;
117
118/**
119 Parameter is of output type.@n
120 When unset, parameter is assumed to be of input type.
121
122 Parameter inputs are changed by the host and typically should not be changed by the plugin.@n
123 One exception is when changing programs, see Plugin::loadProgram().@n
124 The other exception is with parameter change requests, see Plugin::requestParameterValueChange().@n
125 Outputs are changed by the plugin and never modified by the host.
126
127 If you are targeting VST2, make sure to order your parameters so that all inputs are before any outputs.
128 */
129static constexpr const uint32_t kParameterIsOutput = 0x10;
130
131/**
132 Parameter value is a trigger.@n
133 This means the value resets back to its default after each process/run call.@n
134 Cannot be used for output parameters.
135
136 @note Only officially supported under LV2. For other formats DAF simulates the behaviour.
137*/
138static constexpr const uint32_t kParameterIsTrigger = 0x20 | kParameterIsBoolean;
139
140/**
141 Parameter should be hidden from the host and user-visible GUIs.@n
142 It is still saved and handled as any regular parameter, just not visible to the user
143 (for example in a host generated GUI)
144 */
145static constexpr const uint32_t kParameterIsHidden = 0x40;
146
147/** @} */
148
149/* --------------------------------------------------------------------------------------------------------------------
150 * State Hints */
151
152/**
153 @defgroup StateHints State Hints
154
155 Various state hints.
156 @see State::hints
157 @{
158 */
159
160/**
161 State is visible and readable by hosts that support string-type plugin parameters.
162 */
163static constexpr const uint32_t kStateIsHostReadable = 0x01;
164
165/**
166 State is writable by the host, allowing users to arbitrarily change the state.@n
167 For obvious reasons a writable state is also readable by the host.
168 */
169static constexpr const uint32_t kStateIsHostWritable = 0x02 | kStateIsHostReadable;
170
171/**
172 State is a filename path instead of a regular string.@n
173 The readable and writable hints are required for filenames to work, and thus are automatically set.
174 */
175static constexpr const uint32_t kStateIsFilenamePath = 0x04 | kStateIsHostWritable;
176
177/**
178 State is a base64 encoded string.
179 */
180static constexpr const uint32_t kStateIsBase64Blob = 0x08;
181
182/**
183 State is for Plugin/DSP side only, meaning there is never a need to notify the UI when it changes.
184 */
185static constexpr const uint32_t kStateIsOnlyForDSP = 0x10;
186
187/**
188 State is for UI side only.@n
189 If the DSP and UI are separate and the UI is not available, this property won't be saved.
190 */
191static constexpr const uint32_t kStateIsOnlyForUI = 0x20;
192
193/**
194 State value is an immutable complete parameter snapshot.
195
196 Applying this state is a non-realtime operation at the plugin boundary. Adapters
197 must refresh their parameter caches and host/UI mirrors as one complete update;
198 they must not replay it as individual UI parameter edits.
199 */
200static constexpr const uint32_t kStateIsParameterSnapshot = 0x40;
201
202/**
203 This key must occur exactly once when restoring a complete host state.
204 Opt in for authoritative snapshots whose absence must not fall back to a
205 partial parameter recall. Other plugins retain their existing restore policy.
206 */
207static constexpr const uint32_t kStateIsRequired = 0x80;
208
209/** @} */
210
211/* --------------------------------------------------------------------------------------------------------------------
212 * Base Plugin structs */
213
214/**
215 @defgroup BasePluginStructs Base Plugin Structs
216 @{
217 */
218
219/**
220 Parameter designation.@n
221 Allows a parameter to be specially designated for a task, like bypass and reset.
222
223 Each designation is unique, there must be only one parameter that uses it.@n
224 The use of designated parameters is completely optional.
225
226 @note Designated parameters have strict ranges.
227 @see ParameterRanges::adjustForDesignation()
228 */
230 /**
231 Null or unset designation.
232 */
234
235 /**
236 Bypass designation.@n
237 When on (> 0.5f), it means the plugin must run in a bypassed state.
238 */
240
241 /**
242 Reset designation.@n
243 When on (> 0.5f), it means the plugin should reset its internal processing state
244 (like filters, oscillators, envelopes, lfos, etc) and kill all voices.
245 */
247};
248
249/**
250 Parameter designation symbols.@n
251 These are static, hard-coded definitions to ensure consistency across DAF and plugins.
252*/
254 /**
255 Bypass designation symbol.
256 */
257 static constexpr const char bypass[] = "daf_bypass";
258
259 /**
260 Reset designation symbol.
261 */
262 static constexpr const char reset[] = "daf_reset";
263
264 /**
265 LV2 bypass designation symbol, inverted for LV2 so it becomes "enabled".
266 */
267 static constexpr const char bypass_lv2[] = "lv2_enabled";
268};
269
270/**
271 Predefined Port Groups Ids.
272
273 This enumeration provides a few commonly used groups for convenient use in plugins.
274 For preventing conflicts with user code, negative values are used here.
275 When rolling your own port groups, you MUST start their group ids from 0 and they MUST be sequential.
276
277 @see PortGroup
278 */
280 /**
281 Null or unset port group.
282 */
283 kPortGroupNone = (uint32_t)-1,
284
285 /**
286 A single channel audio group.
287 */
288 kPortGroupMono = (uint32_t)-2,
289
290 /**
291 A 2-channel discrete stereo audio group,
292 where the 1st audio port is the left channel and the 2nd port is the right channel.
293 */
294 kPortGroupStereo = (uint32_t)-3
295};
296
297/**
298 Audio Port.
299
300 Can be used as CV port by specifying kAudioPortIsCV in hints,@n
301 but this is only supported in LV2 and JACK standalone formats.
302 */
303struct AudioPort {
304 /**
305 Hints describing this audio port.
306 @see AudioPortHints
307 */
308 uint32_t hints;
309
310 /**
311 The name of this audio port.@n
312 An audio port name can contain any character, but hosts might have a hard time with non-ascii ones.@n
313 The name doesn't have to be unique within a plugin instance, but it's recommended.
314 */
316
317 /**
318 The symbol of this audio port.@n
319 An audio port symbol is a short restricted name used as a machine and human readable identifier.@n
320 The first character must be one of _, a-z or A-Z and subsequent characters can be from _, a-z, A-Z and 0-9.
321 @note Audio port and parameter symbols MUST be unique within a plugin instance.
322 */
324
325 /**
326 The group id that this audio/cv port belongs to.
327 No group is assigned by default.
328
329 You can use a group from PredefinedPortGroups or roll your own.@n
330 When rolling your own port groups, you MUST start their group ids from 0 and they MUST be sequential.
331 @see PortGroup, Plugin::initPortGroup
332 */
333 uint32_t groupId;
334
335 /**
336 Default constructor for a regular audio port.
337 */
338 AudioPort() noexcept
339 : hints(0x0),
340 name(),
341 symbol(),
343};
344
345/**
346 Parameter ranges.@n
347 This is used to set the default, minimum and maximum values of a parameter.
348
349 By default a parameter has 0.0 as minimum, 1.0 as maximum and 0.0 as default.@n
350 When changing this struct values you must ensure maximum > minimum and default is within range.
351 */
353 /**
354 Default value.
355 */
356 float def;
357
358 /**
359 Minimum value.
360 */
361 float min;
362
363 /**
364 Maximum value.
365 */
366 float max;
367
368 /**
369 Default constructor, using 0.0 as default, 0.0 as minimum, 1.0 as maximum.
370 */
371 constexpr ParameterRanges() noexcept
372 : def(0.0f),
373 min(0.0f),
374 max(1.0f) {}
375
376 /**
377 Constructor using custom values.
378 */
379 constexpr ParameterRanges(const float df, const float mn, const float mx) noexcept
380 : def(df),
381 min(mn),
382 max(mx) {}
383
384 /**
385 Fix the default value within range.
386 */
387 void fixDefault() noexcept
388 {
389 fixValue(def);
390 }
391
392 /**
393 Fix a value within range.
394 */
395 void fixValue(float& value) const noexcept
396 {
397 if (value < min)
398 value = min;
399 else if (value > max)
400 value = max;
401 }
402
403 /**
404 Get a fixed value within range.
405 */
406 float getFixedValue(const float value) const noexcept
407 {
408 if (value <= min)
409 return min;
410 if (value >= max)
411 return max;
412 return value;
413 }
414
415 /**
416 Get a value normalized to 0.0<->1.0.
417 */
418 float getNormalizedValue(const float value) const noexcept
419 {
420 const float normValue = (value - min) / (max - min);
421
422 if (normValue <= 0.0f)
423 return 0.0f;
424 if (normValue >= 1.0f)
425 return 1.0f;
426 return normValue;
427 }
428
429 /**
430 Get a value normalized to 0.0<->1.0.
431 Overloaded function using double precision values.
432 */
433 double getNormalizedValue(const double& value) const noexcept
434 {
435 const double normValue = (value - min) / (max - min);
436
437 if (normValue <= 0.0)
438 return 0.0;
439 if (normValue >= 1.0)
440 return 1.0;
441 return normValue;
442 }
443
444 /**
445 Get a value normalized to 0.0<->1.0, fixed within range.
446 */
447 float getFixedAndNormalizedValue(const float value) const noexcept
448 {
449 if (value <= min)
450 return 0.0f;
451 if (value >= max)
452 return 1.0f;
453
454 const float normValue = (value - min) / (max - min);
455
456 if (normValue <= 0.0f)
457 return 0.0f;
458 if (normValue >= 1.0f)
459 return 1.0f;
460
461 return normValue;
462 }
463
464 /**
465 Get a value normalized to 0.0<->1.0, fixed within range.
466 Overloaded function using double precision values.
467 */
468 double getFixedAndNormalizedValue(const double value) const noexcept
469 {
470 if (value <= min)
471 return 0.0;
472 if (value >= max)
473 return 1.0;
474
475 const double normValue = (value - min) / (max - min);
476
477 if (normValue <= 0.0)
478 return 0.0;
479 if (normValue >= 1.0)
480 return 1.0;
481
482 return normValue;
483 }
484
485 /**
486 Get a proper value previously normalized to 0.0<->1.0.
487 */
488 float getUnnormalizedValue(const float value) const noexcept
489 {
490 if (value <= 0.0f)
491 return min;
492 if (value >= 1.0f)
493 return max;
494
495 return value * (max - min) + min;
496 }
497
498 /**
499 Get a proper value previously normalized to 0.0<->1.0.
500 Overloaded function using double precision values.
501 */
502 double getUnnormalizedValue(const double value) const noexcept
503 {
504 if (value <= 0.0)
505 return min;
506 if (value >= 1.0)
507 return max;
508
509 return value * (max - min) + min;
510 }
511};
512
513/**
514 Parameter enumeration value.@n
515 A string representation of a plugin parameter value.@n
516 Used together can be used to give meaning to parameter values, working as an enumeration.
517 */
519 /**
520 Parameter value.
521 */
522 float value;
523
524 /**
525 String representation of this value.
526 */
528
529 /**
530 Default constructor, using 0.0 as value and empty label.
531 */
533 : value(0.0f),
534 label() {}
535
536 /**
537 Constructor using custom values.
538 */
539 ParameterEnumerationValue(float v, const char* l) noexcept
540 : value(v),
541 label(l) {}
542};
543
544/**
545 Details around parameter enumeration values.@n
546 Wraps ParameterEnumerationValues and provides a few extra details to the host about these values.
547 */
549 /**
550 Number of elements allocated in @values.
551 */
552 uint8_t count;
553
554 /**
555 Whether the host is to be restricted to only use enumeration values.
556
557 @note This mode is only a hint! Not all hosts and plugin formats support this mode.
558 */
560
561 /**
562 Array of @ParameterEnumerationValue items.@n
563 When assigning this pointer manually, it must be allocated on the heap with `new ParameterEnumerationValue[count]`.@n
564 The array pointer will be automatically deleted later unless @p deleteLater is set to false.
565 */
567
568 /**
569 Whether to take ownership of the @p values pointer.@n
570 Defaults to true unless stated otherwise.
571 */
573
574 /**
575 Default constructor, for zero enumeration values.
576 */
577 constexpr ParameterEnumerationValues() noexcept
578 : count(0),
579 restrictedMode(false),
580 values(nullptr),
581 deleteLater(true) {}
582
583 /**
584 Constructor using custom values.@n
585 When using this constructor the pointer to @values MUST have been statically declared.@n
586 It will not be automatically deleted later.
587 */
588 constexpr ParameterEnumerationValues(uint8_t c, bool r, ParameterEnumerationValue* v) noexcept
589 : count(c),
591 values(v),
592 deleteLater(false) {}
593
594 // constexpr
596 {
597 if (deleteLater)
598 delete[] values;
599 }
600
601 DAF_DECLARE_NON_COPYABLE(ParameterEnumerationValues)
602};
603
604/**
605 Parameter.
606 */
607struct Parameter {
608 /**
609 Hints describing this parameter.
610 @see ParameterHints
611 */
612 uint32_t hints;
613
614 /**
615 The name of this parameter.@n
616 A parameter name can contain any character, but hosts might have a hard time with non-ascii ones.@n
617 The name doesn't have to be unique within a plugin instance, but it's recommended.
618 */
620
621 /**
622 The short name of this parameter.@n
623 Used when displaying the parameter name in a very limited space.
624 @note This value is optional, the full name is used when the short one is missing.
625 */
627
628 /**
629 The symbol of this parameter.@n
630 A parameter symbol is a short restricted name used as a machine and human readable identifier.@n
631 The first character must be one of _, a-z or A-Z and subsequent characters can be from _, a-z, A-Z and 0-9.
632 @note Parameter symbols MUST be unique within a plugin instance.
633 */
635
636 /**
637 The unit of this parameter.@n
638 This means something like "dB", "kHz" and "ms".@n
639 Can be left blank if a unit does not apply to this parameter.
640 */
642
643 /**
644 An extensive description/comment about the parameter.
645 @note This value is optional and only used for LV2.
646 */
648
649 /**
650 Ranges of this parameter.@n
651 The ranges describe the default, minimum and maximum values.
652 */
654
655 /**
656 Enumeration details.@n
657 Can be used to give meaning to parameter values, working as an enumeration.
658 */
660
661 /**
662 Designation for this parameter.
663 */
665
666 /**
667 MIDI CC to use by default on this parameter.@n
668 A value of 0 or 32 (bank change) is considered invalid.@n
669 Must also be less or equal to 120.
670 @note This value is only a hint! Hosts might map it automatically or completely ignore it.
671 */
672 uint8_t midiCC;
673
674 /**
675 The group id that this parameter belongs to.
676 No group is assigned by default.
677
678 You can use a group from PredefinedPortGroups or roll your own.@n
679 When rolling your own port groups, you MUST start their group ids from 0 and they MUST be sequential.
680 @see PortGroup, Plugin::initPortGroup
681 */
682 uint32_t groupId;
683
684 /**
685 Default constructor for a null parameter.
686 */
687 Parameter() noexcept
688 : hints(0x0),
689 name(),
690 shortName(),
691 symbol(),
692 unit(),
693 description(),
694 ranges(),
695 enumValues(),
697 midiCC(0),
699
700 /**
701 Constructor using custom values.
702 */
703 Parameter(uint32_t h, const char* n, const char* s, const char* u, float def, float min, float max) noexcept
704 : hints(h),
705 name(n),
706 shortName(),
707 symbol(s),
708 unit(u),
709 description(),
710 ranges(def, min, max),
711 enumValues(),
713 midiCC(0),
715
716#ifdef DAF_PROPER_CPP11_SUPPORT
717 /**
718 Constructor using custom values and enumeration.
719 Assumes enumeration details should have `restrictedMode` on.
720 */
721 Parameter(uint32_t h, const char* n, const char* s, const char* u, float def, float min, float max,
722 uint8_t evcount, ParameterEnumerationValue ev[]) noexcept
723 : hints(h),
724 name(n),
725 shortName(),
726 symbol(s),
727 unit(u),
728 description(),
729 ranges(def, min, max),
730 enumValues(evcount, true, ev),
732 midiCC(0),
734#endif
735
736 /**
737 Initialize a parameter for a specific designation.
738 */
740 {
741 designation = d;
742
743 switch (d)
744 {
746 break;
749 name = "Bypass";
750 shortName = "Bypass";
752 unit = "";
753 midiCC = 0;
755 ranges.def = 0.0f;
756 ranges.min = 0.0f;
757 ranges.max = 1.0f;
758 break;
761 name = "Reset";
762 shortName = "Reset";
764 unit = "";
765 midiCC = 0;
767 ranges.def = 0.0f;
768 ranges.min = 0.0f;
769 ranges.max = 1.0f;
770 break;
771 }
772 }
773
774 Parameter& operator=(Parameter& other) noexcept
775 {
776 hints = other.hints;
777 name = other.name;
778 shortName = other.shortName;
779 symbol = other.symbol;
780 unit = other.unit;
781 description = other.description;
782 ranges = other.ranges;
783 designation = other.designation;
784 midiCC = other.midiCC;
785 groupId = other.groupId;
786
787 // enumValues needs special handling
788 enumValues.count = other.enumValues.count;
789 enumValues.restrictedMode = other.enumValues.restrictedMode;
790 enumValues.values = other.enumValues.values;
791 enumValues.deleteLater = other.enumValues.deleteLater;
792
793 // make sure to not delete data twice
794 other.enumValues.deleteLater = false;
795
796 return *this;
797 }
798
799 Parameter& operator=(const Parameter& other) noexcept
800 {
801 hints = other.hints;
802 name = other.name;
803 shortName = other.shortName;
804 symbol = other.symbol;
805 unit = other.unit;
806 description = other.description;
807 ranges = other.ranges;
808 designation = other.designation;
809 midiCC = other.midiCC;
810 groupId = other.groupId;
811
812 // make sure to not delete data twice
813 DAF_SAFE_ASSERT_RETURN(other.enumValues.values == nullptr || !other.enumValues.deleteLater, *this);
814
815 // enumValues needs special handling
816 enumValues.count = other.enumValues.count;
817 enumValues.restrictedMode = other.enumValues.restrictedMode;
818 enumValues.values = other.enumValues.values;
819 enumValues.deleteLater = other.enumValues.deleteLater;
820
821 return *this;
822 }
823};
824
825/**
826 Port Group.@n
827 Allows to group together audio/cv ports or parameters.
828
829 Each unique group MUST have an unique symbol and a name.
830 A group can be applied to both inputs and outputs (at the same time).
831 The same group cannot be used in audio ports and parameters.
832
833 When both audio and parameter groups are used, audio groups MUST be defined first.
834 That is, group indexes start with audio ports, then parameters.
835
836 An audio port group logically combines ports which should be considered part of the same stream.@n
837 For example, two audio ports in a group may form a stereo stream.
838
839 A parameter group provides meta-data to the host to indicate that some parameters belong together.
840
841 The use of port groups is completely optional.
842
843 @see Plugin::initPortGroup, AudioPort::group, Parameter::group
844 */
845struct PortGroup {
846 /**
847 The name of this port group.@n
848 A port group name can contain any character, but hosts might have a hard time with non-ascii ones.@n
849 The name doesn't have to be unique within a plugin instance, but it's recommended.
850 */
852
853 /**
854 The symbol of this port group.@n
855 A port group symbol is a short restricted name used as a machine and human readable identifier.@n
856 The first character must be one of _, a-z or A-Z and subsequent characters can be from _, a-z, A-Z and 0-9.
857 @note Port group symbols MUST be unique within a plugin instance.
858 */
860};
861
862/**
863 State.
864
865 In DAF states refer to key:value string pairs, used to store arbitrary non-parameter data.@n
866 By default states are completely internal to the plugin and not visible by the host.@n
867 Flags can be set to allow hosts to see and/or change them.
868
869 TODO API under construction
870 */
871struct State {
872 /**
873 Hints describing this state.
874 @note Changing these hints can break compatibility with previously saved data.
875 @see StateHints
876 */
877 uint32_t hints;
878
879 /**
880 The key or "symbol" of this state.@n
881 A state key is a short restricted name used as a machine and human readable identifier.
882 @note State keys MUST be unique within a plugin instance.
883 TODO define rules for allowed characters, must be usable as URI non-encoded parameters
884 */
886
887 /**
888 The default value of this state.@n
889 Can be left empty if considered a valid initial state.
890 */
892
893 /**
894 String representation of this state.
895 */
897
898 /**
899 An extensive description/comment about this state.
900 @note This value is optional and only used for LV2.
901 */
903
904 #ifdef __MOD_DEVICES__
905 /**
906 The file types that a filename path state supports, written as a comma-separated string without whitespace.
907 Currently supported file types are:
908 - audioloop: Audio Loops, meant to be used for looper-style plugins
909 - audiorecording: Audio Recordings, triggered by plugins and stored in the unit
910 - audiosample: One-shot Audio Samples, meant to be used for sampler-style plugins
911 - audiotrack: Audio Tracks, meant to be used as full-performance/song or backtrack
912 - cabsim: Speaker Cabinets, meant as small IR audio files
913 - h2drumkit: Hydrogen Drumkits, must use h2drumkit file extension
914 - ir: Impulse Responses
915 - midiclip: MIDI Clips, to be used in sync with host tempo, must have mid or midi file extension
916 - midisong: MIDI Songs, meant to be used as full-performance/song or backtrack
917 - sf2: SF2 Instruments, must have sf2 or sf3 file extension
918 - sfz: SFZ Instruments, must have sfz file extension
919
920 @note This is a custom extension only valid in builds MOD Audio.
921 */
922 String fileTypes;
923 #endif
924
925 /**
926 Default constructor for a null state.
927 */
928 State() noexcept
929 : hints(0x0),
930 key(),
931 defaultValue(),
932 label(),
933 description() {}
934};
935
936/**
937 MIDI event.
938 */
939struct MidiEvent {
940 /**
941 Size of internal data.
942 */
943 static constexpr const uint32_t kDataSize = 4;
944
945 /**
946 Time offset in frames.
947 */
948 uint32_t frame;
949
950 /**
951 Number of bytes used.
952 */
953 uint32_t size;
954
955 /**
956 MIDI data.@n
957 If size > kDataSize, dataExt is used (otherwise null).
958
959 When dataExt is used, the event holder is responsible for
960 keeping the pointer valid during the entirety of the run function.
961 */
962 uint8_t data[kDataSize];
963 const uint8_t* dataExt;
964};
965
966/**
967 Time position.@n
968 The @a playing and @a frame values are always valid.@n
969 BBT values are only valid when @a bbt.valid is true.
970
971 This struct is inspired by the [JACK Transport API](https://jackaudio.org/api/structjack__position__t.html).
972 */
974 /**
975 Wherever the host transport is playing/rolling.
976 */
978
979 /**
980 Current host transport position in frames.
981 @note This value is not always monotonic,
982 with some plugin hosts assigning it based on a source that can accumulate rounding errors.
983 */
984 uint64_t frame;
985
986 /**
987 Wherever the host supplied a valid tempo value.
988 This is independent of @a bbt.valid, which requires a complete BBT position.
989 */
991
992 /**
993 Bar-Beat-Tick time position.
994 */
995 struct BarBeatTick {
996 /**
997 Wherever the host transport is using BBT.@n
998 If false you must not read from this struct.
999 */
1000 bool valid;
1001
1002 /**
1003 Current bar.@n
1004 Should always be > 0.@n
1005 The first bar is bar '1'.
1006 */
1007 int32_t bar;
1008
1009 /**
1010 Current beat within bar.@n
1011 Should always be > 0 and <= @a beatsPerBar.@n
1012 The first beat is beat '1'.
1013 */
1014 int32_t beat;
1015
1016 /**
1017 Current tick within beat.@n
1018 Should always be >= 0 and < @a ticksPerBeat.@n
1019 The first tick is tick '0'.
1020 @note Fraction part of tick is only available on some plugin formats.
1021 */
1022 double tick;
1023
1024 /**
1025 Number of ticks that have elapsed between frame 0 and the first beat of the current measure.
1026 */
1028
1029 /**
1030 Time signature "numerator".
1031 */
1033
1034 /**
1035 Time signature "denominator".
1036 */
1038
1039 /**
1040 Number of ticks within a beat.@n
1041 Usually a moderately large integer with many denominators, such as 1920.0.
1042 */
1044
1045 /**
1046 Number of beats per minute.
1047 */
1049
1050 /**
1051 Default constructor for a null BBT time position.
1052 */
1053 BarBeatTick() noexcept
1054 : valid(false),
1055 bar(0),
1056 beat(0),
1057 tick(0),
1058 barStartTick(0.0),
1059 beatsPerBar(0.0f),
1060 beatType(0.0f),
1061 ticksPerBeat(0.0),
1062 beatsPerMinute(0.0) {}
1063
1064 /**
1065 Reinitialize this position using the default null initialization.
1066 */
1067 void clear() noexcept
1068 {
1069 valid = false;
1070 bar = 0;
1071 beat = 0;
1072 tick = 0;
1073 barStartTick = 0.0;
1074 beatsPerBar = 0.0f;
1075 beatType = 0.0f;
1076 ticksPerBeat = 0.0;
1077 beatsPerMinute = 0.0;
1078 }
1079 } bbt;
1080
1081 /**
1082 Default constructor for a time position.
1083 */
1084 TimePosition() noexcept
1085 : playing(false),
1086 frame(0),
1087 bpmValid(false),
1088 bbt() {}
1089
1090 /**
1091 Reinitialize this position using the default null initialization.
1092 */
1093 void clear() noexcept
1094 {
1095 playing = false;
1096 frame = 0;
1097 bpmValid = false;
1098 bbt.clear();
1099 }
1100};
1101
1102/** @} */
1103
1104// --------------------------------------------------------------------------------------------------------------------
1105
1107
1108#endif // DAF_DETAILS_HPP_INCLUDED
Definition String.hpp:35
static constexpr const uint32_t kCVPortIsOptional
Definition DafDetails.hpp:77
static constexpr const uint32_t kCVPortHasPositiveUnipolarRange
Definition DafDetails.hpp:63
static constexpr const uint32_t kCVPortHasBipolarRange
Definition DafDetails.hpp:51
static constexpr const uint32_t kCVPortHasScaledRange
Definition DafDetails.hpp:71
static constexpr const uint32_t kAudioPortIsSidechain
Definition DafDetails.hpp:45
static constexpr const uint32_t kCVPortHasNegativeUnipolarRange
Definition DafDetails.hpp:57
static constexpr const uint32_t kAudioPortIsCV
Definition DafDetails.hpp:38
PredefinedPortGroupsIds
Definition DafDetails.hpp:279
ParameterDesignation
Definition DafDetails.hpp:229
@ kPortGroupMono
Definition DafDetails.hpp:288
@ kPortGroupNone
Definition DafDetails.hpp:283
@ kPortGroupStereo
Definition DafDetails.hpp:294
@ kParameterDesignationBypass
Definition DafDetails.hpp:239
@ kParameterDesignationReset
Definition DafDetails.hpp:246
@ kParameterDesignationNull
Definition DafDetails.hpp:233
#define END_NAMESPACE_DAF
Definition DafInfo.hpp:996
#define START_NAMESPACE_DAF
Definition DafInfo.hpp:990
static constexpr const uint32_t kParameterIsOutput
Definition DafDetails.hpp:129
static constexpr const uint32_t kParameterIsHidden
Definition DafDetails.hpp:145
static constexpr const uint32_t kParameterIsAutomable
Definition DafDetails.hpp:100
static constexpr const uint32_t kParameterIsInteger
Definition DafDetails.hpp:111
static constexpr const uint32_t kParameterIsTrigger
Definition DafDetails.hpp:138
static constexpr const uint32_t kParameterIsLogarithmic
Definition DafDetails.hpp:116
static constexpr const uint32_t kParameterIsBoolean
Definition DafDetails.hpp:106
static constexpr const uint32_t kParameterIsAutomatable
Definition DafDetails.hpp:96
static constexpr const uint32_t kStateIsOnlyForDSP
Definition DafDetails.hpp:185
static constexpr const uint32_t kStateIsOnlyForUI
Definition DafDetails.hpp:191
static constexpr const uint32_t kStateIsHostReadable
Definition DafDetails.hpp:163
static constexpr const uint32_t kStateIsFilenamePath
Definition DafDetails.hpp:175
static constexpr const uint32_t kStateIsParameterSnapshot
Definition DafDetails.hpp:200
static constexpr const uint32_t kStateIsBase64Blob
Definition DafDetails.hpp:180
static constexpr const uint32_t kStateIsHostWritable
Definition DafDetails.hpp:169
static constexpr const uint32_t kStateIsRequired
Definition DafDetails.hpp:207
Definition DafDetails.hpp:253
static constexpr const char bypass[]
Definition DafDetails.hpp:257
static constexpr const char bypass_lv2[]
Definition DafDetails.hpp:267
static constexpr const char reset[]
Definition DafDetails.hpp:262
uint32_t groupId
Definition DafDetails.hpp:333
AudioPort() noexcept
Definition DafDetails.hpp:338
String name
Definition DafDetails.hpp:315
String symbol
Definition DafDetails.hpp:323
uint32_t hints
Definition DafDetails.hpp:308
Definition DafDetails.hpp:939
uint32_t size
Definition DafDetails.hpp:953
static constexpr const uint32_t kDataSize
Definition DafDetails.hpp:943
uint8_t data[kDataSize]
Definition DafDetails.hpp:962
uint32_t frame
Definition DafDetails.hpp:948
Definition DafDetails.hpp:518
ParameterEnumerationValue() noexcept
Definition DafDetails.hpp:532
float value
Definition DafDetails.hpp:522
ParameterEnumerationValue(float v, const char *l) noexcept
Definition DafDetails.hpp:539
String label
Definition DafDetails.hpp:527
Definition DafDetails.hpp:548
bool restrictedMode
Definition DafDetails.hpp:559
constexpr ParameterEnumerationValues(uint8_t c, bool r, ParameterEnumerationValue *v) noexcept
Definition DafDetails.hpp:588
constexpr ParameterEnumerationValues() noexcept
Definition DafDetails.hpp:577
bool deleteLater
Definition DafDetails.hpp:572
ParameterEnumerationValue * values
Definition DafDetails.hpp:566
uint8_t count
Definition DafDetails.hpp:552
Definition DafDetails.hpp:352
float getUnnormalizedValue(const float value) const noexcept
Definition DafDetails.hpp:488
float getFixedAndNormalizedValue(const float value) const noexcept
Definition DafDetails.hpp:447
void fixDefault() noexcept
Definition DafDetails.hpp:387
float max
Definition DafDetails.hpp:366
void fixValue(float &value) const noexcept
Definition DafDetails.hpp:395
float getNormalizedValue(const float value) const noexcept
Definition DafDetails.hpp:418
float min
Definition DafDetails.hpp:361
constexpr ParameterRanges(const float df, const float mn, const float mx) noexcept
Definition DafDetails.hpp:379
double getFixedAndNormalizedValue(const double value) const noexcept
Definition DafDetails.hpp:468
float getFixedValue(const float value) const noexcept
Definition DafDetails.hpp:406
constexpr ParameterRanges() noexcept
Definition DafDetails.hpp:371
float def
Definition DafDetails.hpp:356
double getNormalizedValue(const double &value) const noexcept
Definition DafDetails.hpp:433
double getUnnormalizedValue(const double value) const noexcept
Definition DafDetails.hpp:502
Definition DafDetails.hpp:607
Parameter() noexcept
Definition DafDetails.hpp:687
String shortName
Definition DafDetails.hpp:626
ParameterRanges ranges
Definition DafDetails.hpp:653
String unit
Definition DafDetails.hpp:641
uint32_t hints
Definition DafDetails.hpp:612
ParameterDesignation designation
Definition DafDetails.hpp:664
String symbol
Definition DafDetails.hpp:634
uint8_t midiCC
Definition DafDetails.hpp:672
String description
Definition DafDetails.hpp:647
uint32_t groupId
Definition DafDetails.hpp:682
ParameterEnumerationValues enumValues
Definition DafDetails.hpp:659
void initDesignation(ParameterDesignation d) noexcept
Definition DafDetails.hpp:739
String name
Definition DafDetails.hpp:619
Parameter(uint32_t h, const char *n, const char *s, const char *u, float def, float min, float max) noexcept
Definition DafDetails.hpp:703
Definition DafDetails.hpp:845
String symbol
Definition DafDetails.hpp:859
String name
Definition DafDetails.hpp:851
String key
Definition DafDetails.hpp:885
State() noexcept
Definition DafDetails.hpp:928
String label
Definition DafDetails.hpp:896
uint32_t hints
Definition DafDetails.hpp:877
String defaultValue
Definition DafDetails.hpp:891
String description
Definition DafDetails.hpp:902
float beatType
Definition DafDetails.hpp:1037
bool valid
Definition DafDetails.hpp:1000
float beatsPerBar
Definition DafDetails.hpp:1032
double barStartTick
Definition DafDetails.hpp:1027
double ticksPerBeat
Definition DafDetails.hpp:1043
BarBeatTick() noexcept
Definition DafDetails.hpp:1053
int32_t bar
Definition DafDetails.hpp:1007
void clear() noexcept
Definition DafDetails.hpp:1067
double tick
Definition DafDetails.hpp:1022
int32_t beat
Definition DafDetails.hpp:1014
double beatsPerMinute
Definition DafDetails.hpp:1048
bool playing
Definition DafDetails.hpp:977
uint64_t frame
Definition DafDetails.hpp:984
void clear() noexcept
Definition DafDetails.hpp:1093
bool bpmValid
Definition DafDetails.hpp:990
TimePosition() noexcept
Definition DafDetails.hpp:1084