DISTRHO Plugin Framework
DistrhoDetails.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 DISTRHO_DETAILS_HPP_INCLUDED
18 #define DISTRHO_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  */
38 static 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  */
45 static 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  */
51 static 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  */
57 static 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  */
63 static 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  */
71 static 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  */
77 static 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  */
96 static constexpr const uint32_t kParameterIsAutomatable = 0x01;
97 
98 /** It was a typo, sorry.. */
99 DISTRHO_DEPRECATED_BY("kParameterIsAutomatable")
100 static 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  */
106 static constexpr const uint32_t kParameterIsBoolean = 0x02;
107 
108 /**
109  Parameter value is integer.
110  */
111 static constexpr const uint32_t kParameterIsInteger = 0x04;
112 
113 /**
114  Parameter value is logarithmic.
115  */
116 static 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 targetting VST2, make sure to order your parameters so that all inputs are before any outputs.
128  */
129 static 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 DPF simulates the behaviour.
137 */
138 static 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  */
145 static 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  */
163 static 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  */
169 static 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  */
175 static constexpr const uint32_t kStateIsFilenamePath = 0x04 | kStateIsHostWritable;
176 
177 /**
178  State is a base64 encoded string.
179  */
180 static 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  */
185 static 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  */
191 static constexpr const uint32_t kStateIsOnlyForUI = 0x20;
192 
193 /** @} */
194 
195 /* --------------------------------------------------------------------------------------------------------------------
196  * Base Plugin structs */
197 
198 /**
199  @defgroup BasePluginStructs Base Plugin Structs
200  @{
201  */
202 
203 /**
204  Parameter designation.@n
205  Allows a parameter to be specially designated for a task, like bypass.
206 
207  Each designation is unique, there must be only one parameter that uses it.@n
208  The use of designated parameters is completely optional.
209 
210  @note Designated parameters have strict ranges.
211  @see ParameterRanges::adjustForDesignation()
212  */
214  /**
215  Null or unset designation.
216  */
218 
219  /**
220  Bypass designation.@n
221  When on (> 0.5f), it means the plugin must run in a bypassed state.
222  */
224 };
225 
226 /**
227  Parameter designation symbols.@n
228  These are static, hard-coded definitions to ensure consistency across DPF and plugins.
229 */
231  /**
232  Bypass designation symbol.
233  */
234  static constexpr const char bypass[] = "dpf_bypass";
235 
236  /**
237  Bypass designation symbol, inverted for LV2 so it becomes "enabled".
238  */
239  static constexpr const char bypass_lv2[] = "lv2_enabled";
240 };
241 
242 /**
243  Predefined Port Groups Ids.
244 
245  This enumeration provides a few commonly used groups for convenient use in plugins.
246  For preventing conflicts with user code, negative values are used here.
247  When rolling your own port groups, you MUST start their group ids from 0 and they MUST be sequential.
248 
249  @see PortGroup
250  */
252  /**
253  Null or unset port group.
254  */
255  kPortGroupNone = (uint32_t)-1,
256 
257  /**
258  A single channel audio group.
259  */
260  kPortGroupMono = (uint32_t)-2,
261 
262  /**
263  A 2-channel discrete stereo audio group,
264  where the 1st audio port is the left channel and the 2nd port is the right channel.
265  */
266  kPortGroupStereo = (uint32_t)-3
267 };
268 
269 /**
270  Audio Port.
271 
272  Can be used as CV port by specifying kAudioPortIsCV in hints,@n
273  but this is only supported in LV2 and JACK standalone formats.
274  */
275 struct AudioPort {
276  /**
277  Hints describing this audio port.
278  @see AudioPortHints
279  */
280  uint32_t hints;
281 
282  /**
283  The name of this audio port.@n
284  An audio port name can contain any character, but hosts might have a hard time with non-ascii ones.@n
285  The name doesn't have to be unique within a plugin instance, but it's recommended.
286  */
288 
289  /**
290  The symbol of this audio port.@n
291  An audio port symbol is a short restricted name used as a machine and human readable identifier.@n
292  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.
293  @note Audio port and parameter symbols MUST be unique within a plugin instance.
294  */
296 
297  /**
298  The group id that this audio/cv port belongs to.
299  No group is assigned by default.
300 
301  You can use a group from PredefinedPortGroups or roll your own.@n
302  When rolling your own port groups, you MUST start their group ids from 0 and they MUST be sequential.
303  @see PortGroup, Plugin::initPortGroup
304  */
305  uint32_t groupId;
306 
307  /**
308  Default constructor for a regular audio port.
309  */
310  AudioPort() noexcept
311  : hints(0x0),
312  name(),
313  symbol(),
315 };
316 
317 /**
318  Parameter ranges.@n
319  This is used to set the default, minimum and maximum values of a parameter.
320 
321  By default a parameter has 0.0 as minimum, 1.0 as maximum and 0.0 as default.@n
322  When changing this struct values you must ensure maximum > minimum and default is within range.
323  */
325  /**
326  Default value.
327  */
328  float def;
329 
330  /**
331  Minimum value.
332  */
333  float min;
334 
335  /**
336  Maximum value.
337  */
338  float max;
339 
340  /**
341  Default constructor, using 0.0 as default, 0.0 as minimum, 1.0 as maximum.
342  */
343  constexpr ParameterRanges() noexcept
344  : def(0.0f),
345  min(0.0f),
346  max(1.0f) {}
347 
348  /**
349  Constructor using custom values.
350  */
351  constexpr ParameterRanges(const float df, const float mn, const float mx) noexcept
352  : def(df),
353  min(mn),
354  max(mx) {}
355 
356  /**
357  Fix the default value within range.
358  */
359  void fixDefault() noexcept
360  {
361  fixValue(def);
362  }
363 
364  /**
365  Fix a value within range.
366  */
367  void fixValue(float& value) const noexcept
368  {
369  if (value < min)
370  value = min;
371  else if (value > max)
372  value = max;
373  }
374 
375  /**
376  Get a fixed value within range.
377  */
378  float getFixedValue(const float value) const noexcept
379  {
380  if (value <= min)
381  return min;
382  if (value >= max)
383  return max;
384  return value;
385  }
386 
387  /**
388  Get a value normalized to 0.0<->1.0.
389  */
390  float getNormalizedValue(const float value) const noexcept
391  {
392  const float normValue = (value - min) / (max - min);
393 
394  if (normValue <= 0.0f)
395  return 0.0f;
396  if (normValue >= 1.0f)
397  return 1.0f;
398  return normValue;
399  }
400 
401  /**
402  Get a value normalized to 0.0<->1.0.
403  Overloaded function using double precision values.
404  */
405  double getNormalizedValue(const double& value) const noexcept
406  {
407  const double normValue = (value - min) / (max - min);
408 
409  if (normValue <= 0.0)
410  return 0.0;
411  if (normValue >= 1.0)
412  return 1.0;
413  return normValue;
414  }
415 
416  /**
417  Get a value normalized to 0.0<->1.0, fixed within range.
418  */
419  float getFixedAndNormalizedValue(const float value) const noexcept
420  {
421  if (value <= min)
422  return 0.0f;
423  if (value >= max)
424  return 1.0f;
425 
426  const float normValue = (value - min) / (max - min);
427 
428  if (normValue <= 0.0f)
429  return 0.0f;
430  if (normValue >= 1.0f)
431  return 1.0f;
432 
433  return normValue;
434  }
435 
436  /**
437  Get a value normalized to 0.0<->1.0, fixed within range.
438  Overloaded function using double precision values.
439  */
440  double getFixedAndNormalizedValue(const double value) const noexcept
441  {
442  if (value <= min)
443  return 0.0;
444  if (value >= max)
445  return 1.0;
446 
447  const double normValue = (value - min) / (max - min);
448 
449  if (normValue <= 0.0)
450  return 0.0;
451  if (normValue >= 1.0)
452  return 1.0;
453 
454  return normValue;
455  }
456 
457  /**
458  Get a proper value previously normalized to 0.0<->1.0.
459  */
460  float getUnnormalizedValue(const float value) const noexcept
461  {
462  if (value <= 0.0f)
463  return min;
464  if (value >= 1.0f)
465  return max;
466 
467  return value * (max - min) + min;
468  }
469 
470  /**
471  Get a proper value previously normalized to 0.0<->1.0.
472  Overloaded function using double precision values.
473  */
474  double getUnnormalizedValue(const double value) const noexcept
475  {
476  if (value <= 0.0)
477  return min;
478  if (value >= 1.0)
479  return max;
480 
481  return value * (max - min) + min;
482  }
483 };
484 
485 /**
486  Parameter enumeration value.@n
487  A string representation of a plugin parameter value.@n
488  Used together can be used to give meaning to parameter values, working as an enumeration.
489  */
491  /**
492  Parameter value.
493  */
494  float value;
495 
496  /**
497  String representation of this value.
498  */
500 
501  /**
502  Default constructor, using 0.0 as value and empty label.
503  */
505  : value(0.0f),
506  label() {}
507 
508  /**
509  Constructor using custom values.
510  */
511  ParameterEnumerationValue(float v, const char* l) noexcept
512  : value(v),
513  label(l) {}
514 
515 #if __cplusplus >= 201703L
516  /**
517  Constructor using custom values, constexpr compatible variant.
518  */
519  constexpr ParameterEnumerationValue(float v, const std::string_view& l) noexcept
520  : value(v),
521  label(l) {}
522 #endif
523 };
524 
525 /**
526  Details around parameter enumeration values.@n
527  Wraps ParameterEnumerationValues and provides a few extra details to the host about these values.
528  */
530  /**
531  Number of elements allocated in @values.
532  */
533  uint8_t count;
534 
535  /**
536  Whether the host is to be restricted to only use enumeration values.
537 
538  @note This mode is only a hint! Not all hosts and plugin formats support this mode.
539  */
541 
542  /**
543  Array of @ParameterEnumerationValue items.@n
544  When assining this pointer manually, it must be allocated on the heap with `new ParameterEnumerationValue[count]`.@n
545  The array pointer will be automatically deleted later unless @p deleteLater is set to false.
546  */
548 
549  /**
550  Whether to take ownership of the @p values pointer.@n
551  Defaults to true unless stated otherwise.
552  */
554 
555  /**
556  Default constructor, for zero enumeration values.
557  */
558  constexpr ParameterEnumerationValues() noexcept
559  : count(0),
560  restrictedMode(false),
561  values(nullptr),
562  deleteLater(true) {}
563 
564  /**
565  Constructor using custom values.@n
566  When using this constructor the pointer to @values MUST have been statically declared.@n
567  It will not be automatically deleted later.
568  */
569  constexpr ParameterEnumerationValues(uint8_t c, bool r, ParameterEnumerationValue* v) noexcept
570  : count(c),
571  restrictedMode(r),
572  values(v),
573  deleteLater(false) {}
574 
575  // constexpr
576  ~ParameterEnumerationValues() noexcept
577  {
578  if (deleteLater)
579  delete[] values;
580  }
581 
582  DISTRHO_DECLARE_NON_COPYABLE(ParameterEnumerationValues)
583 };
584 
585 /**
586  Parameter.
587  */
588 struct Parameter {
589  /**
590  Hints describing this parameter.
591  @see ParameterHints
592  */
593  uint32_t hints;
594 
595  /**
596  The name of this parameter.@n
597  A parameter name can contain any character, but hosts might have a hard time with non-ascii ones.@n
598  The name doesn't have to be unique within a plugin instance, but it's recommended.
599  */
601 
602  /**
603  The short name of this parameter.@n
604  Used when displaying the parameter name in a very limited space.
605  @note This value is optional, the full name is used when the short one is missing.
606  */
608 
609  /**
610  The symbol of this parameter.@n
611  A parameter symbol is a short restricted name used as a machine and human readable identifier.@n
612  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.
613  @note Parameter symbols MUST be unique within a plugin instance.
614  */
616 
617  /**
618  The unit of this parameter.@n
619  This means something like "dB", "kHz" and "ms".@n
620  Can be left blank if a unit does not apply to this parameter.
621  */
623 
624  /**
625  An extensive description/comment about the parameter.
626  @note This value is optional and only used for LV2.
627  */
629 
630  /**
631  Ranges of this parameter.@n
632  The ranges describe the default, minimum and maximum values.
633  */
635 
636  /**
637  Enumeration details.@n
638  Can be used to give meaning to parameter values, working as an enumeration.
639  */
641 
642  /**
643  Designation for this parameter.
644  */
646 
647  /**
648  MIDI CC to use by default on this parameter.@n
649  A value of 0 or 32 (bank change) is considered invalid.@n
650  Must also be less or equal to 120.
651  @note This value is only a hint! Hosts might map it automatically or completely ignore it.
652  */
653  uint8_t midiCC;
654 
655  /**
656  The group id that this parameter belongs to.
657  No group is assigned by default.
658 
659  You can use a group from PredefinedPortGroups or roll your own.@n
660  When rolling your own port groups, you MUST start their group ids from 0 and they MUST be sequential.
661  @see PortGroup, Plugin::initPortGroup
662  */
663  uint32_t groupId;
664 
665  /**
666  Default constructor for a null parameter.
667  */
668  Parameter() noexcept
669  : hints(0x0),
670  name(),
671  shortName(),
672  symbol(),
673  unit(),
674  description(),
675  ranges(),
676  enumValues(),
678  midiCC(0),
680 
681  /**
682  Constructor using custom values.
683  */
684  Parameter(uint32_t h, const char* n, const char* s, const char* u, float def, float min, float max) noexcept
685  : hints(h),
686  name(n),
687  shortName(),
688  symbol(s),
689  unit(u),
690  description(),
691  ranges(def, min, max),
692  enumValues(),
694  midiCC(0),
696 
697 #ifdef DISTRHO_PROPER_CPP11_SUPPORT
698  /**
699  Constructor using custom values and enumeration.
700  Assumes enumeration details should have `restrictedMode` on.
701  */
702  Parameter(uint32_t h, const char* n, const char* s, const char* u, float def, float min, float max,
703  uint8_t evcount, ParameterEnumerationValue ev[]) noexcept
704  : hints(h),
705  name(n),
706  shortName(),
707  symbol(s),
708  unit(u),
709  description(),
710  ranges(def, min, max),
711  enumValues(evcount, true, ev),
713  midiCC(0),
715 #endif
716 
717 #if __cplusplus >= 201703L
718  /**
719  Constructor for constexpr compatible data.
720  */
721  constexpr Parameter(uint32_t h,
722  const std::string_view& n,
723  const std::string_view& sn,
724  const std::string_view& sym,
725  const std::string_view& u,
726  const std::string_view& desc) noexcept
727  : hints(h),
728  name(n),
729  shortName(sn),
730  symbol(sym),
731  unit(u),
732  description(desc),
733  ranges(),
734  enumValues(),
736  midiCC(0),
738 #endif
739 
740  /**
741  Initialize a parameter for a specific designation.
742  */
744  {
745  designation = d;
746 
747  switch (d)
748  {
750  break;
753  name = "Bypass";
754  shortName = "Bypass";
756  unit = "";
757  midiCC = 0;
759  ranges.def = 0.0f;
760  ranges.min = 0.0f;
761  ranges.max = 1.0f;
762  break;
763  }
764  }
765 };
766 
767 #if __cplusplus >= 202001L /* TODO */
768 /**
769  Bypass parameter definition in constexpr form.
770  */
771 static constexpr const Parameter kParameterBypass = {
773  "Bypass", "Bypass", ParameterDesignationSymbols::bypass, "", "", {}, {}, 0, kPortGroupNone,
774 };
775 #endif
776 
777 /**
778  Port Group.@n
779  Allows to group together audio/cv ports or parameters.
780 
781  Each unique group MUST have an unique symbol and a name.
782  A group can be applied to both inputs and outputs (at the same time).
783  The same group cannot be used in audio ports and parameters.
784 
785  When both audio and parameter groups are used, audio groups MUST be defined first.
786  That is, group indexes start with audio ports, then parameters.
787 
788  An audio port group logically combines ports which should be considered part of the same stream.@n
789  For example, two audio ports in a group may form a stereo stream.
790 
791  A parameter group provides meta-data to the host to indicate that some parameters belong together.
792 
793  The use of port groups is completely optional.
794 
795  @see Plugin::initPortGroup, AudioPort::group, Parameter::group
796  */
797 struct PortGroup {
798  /**
799  The name of this port group.@n
800  A port group name can contain any character, but hosts might have a hard time with non-ascii ones.@n
801  The name doesn't have to be unique within a plugin instance, but it's recommended.
802  */
804 
805  /**
806  The symbol of this port group.@n
807  A port group symbol is a short restricted name used as a machine and human readable identifier.@n
808  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.
809  @note Port group symbols MUST be unique within a plugin instance.
810  */
812 };
813 
814 /**
815  State.
816 
817  In DPF states refer to key:value string pairs, used to store arbitrary non-parameter data.@n
818  By default states are completely internal to the plugin and not visible by the host.@n
819  Flags can be set to allow hosts to see and/or change them.
820 
821  TODO API under construction
822  */
823 struct State {
824  /**
825  Hints describing this state.
826  @note Changing these hints can break compatibility with previously saved data.
827  @see StateHints
828  */
829  uint32_t hints;
830 
831  /**
832  The key or "symbol" of this state.@n
833  A state key is a short restricted name used as a machine and human readable identifier.
834  @note State keys MUST be unique within a plugin instance.
835  TODO define rules for allowed characters, must be usable as URI non-encoded parameters
836  */
838 
839  /**
840  The default value of this state.@n
841  Can be left empty if considered a valid initial state.
842  */
844 
845  /**
846  String representation of this state.
847  */
849 
850  /**
851  An extensive description/comment about this state.
852  @note This value is optional and only used for LV2.
853  */
855 
856  #ifdef __MOD_DEVICES__
857  /**
858  The file types that a filename path state supports, written as a comma-separated string without whitespace.
859  Currently supported file types are:
860  - audioloop: Audio Loops, meant to be used for looper-style plugins
861  - audiorecording: Audio Recordings, triggered by plugins and stored in the unit
862  - audiosample: One-shot Audio Samples, meant to be used for sampler-style plugins
863  - audiotrack: Audio Tracks, meant to be used as full-performance/song or backtrack
864  - cabsim: Speaker Cabinets, meant as small IR audio files
865  - h2drumkit: Hydrogen Drumkits, must use h2drumkit file extension
866  - ir: Impulse Responses
867  - midiclip: MIDI Clips, to be used in sync with host tempo, must have mid or midi file extension
868  - midisong: MIDI Songs, meant to be used as full-performance/song or backtrack
869  - sf2: SF2 Instruments, must have sf2 or sf3 file extension
870  - sfz: SFZ Instruments, must have sfz file extension
871 
872  @note This is a custom extension only valid in builds MOD Audio.
873  */
874  String fileTypes;
875  #endif
876 
877  /**
878  Default constructor for a null state.
879  */
880  State() noexcept
881  : hints(0x0),
882  key(),
883  defaultValue(),
884  label(),
885  description() {}
886 };
887 
888 /**
889  MIDI event.
890  */
891 struct MidiEvent {
892  /**
893  Size of internal data.
894  */
895  static constexpr const uint32_t kDataSize = 4;
896 
897  /**
898  Time offset in frames.
899  */
900  uint32_t frame;
901 
902  /**
903  Number of bytes used.
904  */
905  uint32_t size;
906 
907  /**
908  MIDI data.@n
909  If size > kDataSize, dataExt is used (otherwise null).
910 
911  When dataExt is used, the event holder is responsible for
912  keeping the pointer valid during the entirety of the run function.
913  */
914  uint8_t data[kDataSize];
915  const uint8_t* dataExt;
916 };
917 
918 /**
919  Time position.@n
920  The @a playing and @a frame values are always valid.@n
921  BBT values are only valid when @a bbt.valid is true.
922 
923  This struct is inspired by the [JACK Transport API](https://jackaudio.org/api/structjack__position__t.html).
924  */
925 struct TimePosition {
926  /**
927  Wherever the host transport is playing/rolling.
928  */
929  bool playing;
930 
931  /**
932  Current host transport position in frames.
933  @note This value is not always monotonic,
934  with some plugin hosts assigning it based on a source that can accumulate rounding errors.
935  */
936  uint64_t frame;
937 
938  /**
939  Bar-Beat-Tick time position.
940  */
941  struct BarBeatTick {
942  /**
943  Wherever the host transport is using BBT.@n
944  If false you must not read from this struct.
945  */
946  bool valid;
947 
948  /**
949  Current bar.@n
950  Should always be > 0.@n
951  The first bar is bar '1'.
952  */
953  int32_t bar;
954 
955  /**
956  Current beat within bar.@n
957  Should always be > 0 and <= @a beatsPerBar.@n
958  The first beat is beat '1'.
959  */
960  int32_t beat;
961 
962  /**
963  Current tick within beat.@n
964  Should always be >= 0 and < @a ticksPerBeat.@n
965  The first tick is tick '0'.
966  @note Fraction part of tick is only available on some plugin formats.
967  */
968  double tick;
969 
970  /**
971  Number of ticks that have elapsed between frame 0 and the first beat of the current measure.
972  */
973  double barStartTick;
974 
975  /**
976  Time signature "numerator".
977  */
978  float beatsPerBar;
979 
980  /**
981  Time signature "denominator".
982  */
983  float beatType;
984 
985  /**
986  Number of ticks within a beat.@n
987  Usually a moderately large integer with many denominators, such as 1920.0.
988  */
989  double ticksPerBeat;
990 
991  /**
992  Number of beats per minute.
993  */
995 
996  /**
997  Default constructor for a null BBT time position.
998  */
999  BarBeatTick() noexcept
1000  : valid(false),
1001  bar(0),
1002  beat(0),
1003  tick(0),
1004  barStartTick(0.0),
1005  beatsPerBar(0.0f),
1006  beatType(0.0f),
1007  ticksPerBeat(0.0),
1008  beatsPerMinute(0.0) {}
1009 
1010  /**
1011  Reinitialize this position using the default null initialization.
1012  */
1013  void clear() noexcept
1014  {
1015  valid = false;
1016  bar = 0;
1017  beat = 0;
1018  tick = 0;
1019  barStartTick = 0.0;
1020  beatsPerBar = 0.0f;
1021  beatType = 0.0f;
1022  ticksPerBeat = 0.0;
1023  beatsPerMinute = 0.0;
1024  }
1025  } bbt;
1026 
1027  /**
1028  Default constructor for a time position.
1029  */
1030  TimePosition() noexcept
1031  : playing(false),
1032  frame(0),
1033  bbt() {}
1034 
1035  /**
1036  Reinitialize this position using the default null initialization.
1037  */
1038  void clear() noexcept
1039  {
1040  playing = false;
1041  frame = 0;
1042  bbt.clear();
1043  }
1044 };
1045 
1046 /** @} */
1047 
1048 // --------------------------------------------------------------------------------------------------------------------
1049 
1051 
1052 #endif // DISTRHO_DETAILS_HPP_INCLUDED
Definition: String.hpp:35
static constexpr const uint32_t kCVPortIsOptional
Definition: DistrhoDetails.hpp:77
static constexpr const uint32_t kCVPortHasPositiveUnipolarRange
Definition: DistrhoDetails.hpp:63
static constexpr const uint32_t kCVPortHasBipolarRange
Definition: DistrhoDetails.hpp:51
static constexpr const uint32_t kCVPortHasScaledRange
Definition: DistrhoDetails.hpp:71
static constexpr const uint32_t kAudioPortIsSidechain
Definition: DistrhoDetails.hpp:45
static constexpr const uint32_t kCVPortHasNegativeUnipolarRange
Definition: DistrhoDetails.hpp:57
static constexpr const uint32_t kAudioPortIsCV
Definition: DistrhoDetails.hpp:38
PredefinedPortGroupsIds
Definition: DistrhoDetails.hpp:251
ParameterDesignation
Definition: DistrhoDetails.hpp:213
@ kPortGroupMono
Definition: DistrhoDetails.hpp:260
@ kPortGroupNone
Definition: DistrhoDetails.hpp:255
@ kPortGroupStereo
Definition: DistrhoDetails.hpp:266
@ kParameterDesignationBypass
Definition: DistrhoDetails.hpp:223
@ kParameterDesignationNull
Definition: DistrhoDetails.hpp:217
#define END_NAMESPACE_DISTRHO
Definition: DistrhoInfo.hpp:949
#define START_NAMESPACE_DISTRHO
Definition: DistrhoInfo.hpp:943
static constexpr const uint32_t kParameterIsOutput
Definition: DistrhoDetails.hpp:129
static constexpr const uint32_t kParameterIsHidden
Definition: DistrhoDetails.hpp:145
static constexpr const uint32_t kParameterIsAutomable
Definition: DistrhoDetails.hpp:100
static constexpr const uint32_t kParameterIsInteger
Definition: DistrhoDetails.hpp:111
static constexpr const uint32_t kParameterIsTrigger
Definition: DistrhoDetails.hpp:138
static constexpr const uint32_t kParameterIsLogarithmic
Definition: DistrhoDetails.hpp:116
static constexpr const uint32_t kParameterIsBoolean
Definition: DistrhoDetails.hpp:106
static constexpr const uint32_t kParameterIsAutomatable
Definition: DistrhoDetails.hpp:96
static constexpr const uint32_t kStateIsOnlyForDSP
Definition: DistrhoDetails.hpp:185
static constexpr const uint32_t kStateIsOnlyForUI
Definition: DistrhoDetails.hpp:191
static constexpr const uint32_t kStateIsHostReadable
Definition: DistrhoDetails.hpp:163
static constexpr const uint32_t kStateIsFilenamePath
Definition: DistrhoDetails.hpp:175
static constexpr const uint32_t kStateIsBase64Blob
Definition: DistrhoDetails.hpp:180
static constexpr const uint32_t kStateIsHostWritable
Definition: DistrhoDetails.hpp:169
Definition: DistrhoDetails.hpp:230
static constexpr const char bypass[]
Definition: DistrhoDetails.hpp:234
static constexpr const char bypass_lv2[]
Definition: DistrhoDetails.hpp:239
Definition: DistrhoDetails.hpp:275
uint32_t groupId
Definition: DistrhoDetails.hpp:305
AudioPort() noexcept
Definition: DistrhoDetails.hpp:310
String name
Definition: DistrhoDetails.hpp:287
String symbol
Definition: DistrhoDetails.hpp:295
uint32_t hints
Definition: DistrhoDetails.hpp:280
Definition: DistrhoDetails.hpp:891
uint32_t size
Definition: DistrhoDetails.hpp:905
static constexpr const uint32_t kDataSize
Definition: DistrhoDetails.hpp:895
uint8_t data[kDataSize]
Definition: DistrhoDetails.hpp:914
uint32_t frame
Definition: DistrhoDetails.hpp:900
Definition: DistrhoDetails.hpp:490
ParameterEnumerationValue() noexcept
Definition: DistrhoDetails.hpp:504
float value
Definition: DistrhoDetails.hpp:494
ParameterEnumerationValue(float v, const char *l) noexcept
Definition: DistrhoDetails.hpp:511
String label
Definition: DistrhoDetails.hpp:499
Definition: DistrhoDetails.hpp:529
bool restrictedMode
Definition: DistrhoDetails.hpp:540
constexpr ParameterEnumerationValues(uint8_t c, bool r, ParameterEnumerationValue *v) noexcept
Definition: DistrhoDetails.hpp:569
constexpr ParameterEnumerationValues() noexcept
Definition: DistrhoDetails.hpp:558
bool deleteLater
Definition: DistrhoDetails.hpp:553
ParameterEnumerationValue * values
Definition: DistrhoDetails.hpp:547
uint8_t count
Definition: DistrhoDetails.hpp:533
Definition: DistrhoDetails.hpp:324
float getUnnormalizedValue(const float value) const noexcept
Definition: DistrhoDetails.hpp:460
float getFixedAndNormalizedValue(const float value) const noexcept
Definition: DistrhoDetails.hpp:419
void fixDefault() noexcept
Definition: DistrhoDetails.hpp:359
float max
Definition: DistrhoDetails.hpp:338
void fixValue(float &value) const noexcept
Definition: DistrhoDetails.hpp:367
float getNormalizedValue(const float value) const noexcept
Definition: DistrhoDetails.hpp:390
float min
Definition: DistrhoDetails.hpp:333
constexpr ParameterRanges(const float df, const float mn, const float mx) noexcept
Definition: DistrhoDetails.hpp:351
double getFixedAndNormalizedValue(const double value) const noexcept
Definition: DistrhoDetails.hpp:440
float getFixedValue(const float value) const noexcept
Definition: DistrhoDetails.hpp:378
constexpr ParameterRanges() noexcept
Definition: DistrhoDetails.hpp:343
float def
Definition: DistrhoDetails.hpp:328
double getNormalizedValue(const double &value) const noexcept
Definition: DistrhoDetails.hpp:405
double getUnnormalizedValue(const double value) const noexcept
Definition: DistrhoDetails.hpp:474
Definition: DistrhoDetails.hpp:588
Parameter() noexcept
Definition: DistrhoDetails.hpp:668
String shortName
Definition: DistrhoDetails.hpp:607
ParameterRanges ranges
Definition: DistrhoDetails.hpp:634
String unit
Definition: DistrhoDetails.hpp:622
uint32_t hints
Definition: DistrhoDetails.hpp:593
ParameterDesignation designation
Definition: DistrhoDetails.hpp:645
String symbol
Definition: DistrhoDetails.hpp:615
uint8_t midiCC
Definition: DistrhoDetails.hpp:653
String description
Definition: DistrhoDetails.hpp:628
uint32_t groupId
Definition: DistrhoDetails.hpp:663
ParameterEnumerationValues enumValues
Definition: DistrhoDetails.hpp:640
void initDesignation(ParameterDesignation d) noexcept
Definition: DistrhoDetails.hpp:743
String name
Definition: DistrhoDetails.hpp:600
Parameter(uint32_t h, const char *n, const char *s, const char *u, float def, float min, float max) noexcept
Definition: DistrhoDetails.hpp:684
Definition: DistrhoDetails.hpp:797
String symbol
Definition: DistrhoDetails.hpp:811
String name
Definition: DistrhoDetails.hpp:803
Definition: DistrhoDetails.hpp:823
String key
Definition: DistrhoDetails.hpp:837
State() noexcept
Definition: DistrhoDetails.hpp:880
String label
Definition: DistrhoDetails.hpp:848
uint32_t hints
Definition: DistrhoDetails.hpp:829
String defaultValue
Definition: DistrhoDetails.hpp:843
String description
Definition: DistrhoDetails.hpp:854
Definition: DistrhoDetails.hpp:941
float beatType
Definition: DistrhoDetails.hpp:983
bool valid
Definition: DistrhoDetails.hpp:946
float beatsPerBar
Definition: DistrhoDetails.hpp:978
double barStartTick
Definition: DistrhoDetails.hpp:973
double ticksPerBeat
Definition: DistrhoDetails.hpp:989
BarBeatTick() noexcept
Definition: DistrhoDetails.hpp:999
int32_t bar
Definition: DistrhoDetails.hpp:953
void clear() noexcept
Definition: DistrhoDetails.hpp:1013
double tick
Definition: DistrhoDetails.hpp:968
int32_t beat
Definition: DistrhoDetails.hpp:960
double beatsPerMinute
Definition: DistrhoDetails.hpp:994
Definition: DistrhoDetails.hpp:925
bool playing
Definition: DistrhoDetails.hpp:929
uint64_t frame
Definition: DistrhoDetails.hpp:936
void clear() noexcept
Definition: DistrhoDetails.hpp:1038
TimePosition() noexcept
Definition: DistrhoDetails.hpp:1030