DISTRHO Plugin Framework
 All Classes Functions Variables Modules Pages
DistrhoPlugin.hpp
1 /*
2  * DISTRHO Plugin Framework (DPF)
3  * Copyright (C) 2012-2015 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_PLUGIN_HPP_INCLUDED
18 #define DISTRHO_PLUGIN_HPP_INCLUDED
19 
20 #include "extra/d_string.hpp"
21 #include "src/DistrhoPluginChecks.h"
22 
23 #include <cmath>
24 
25 #ifdef DISTRHO_PROPER_CPP11_SUPPORT
26 # include <cstdint>
27 #else
28 # include <stdint.h>
29 #endif
30 
31 #ifndef M_PI
32 # define M_PI 3.14159265358979323846
33 #endif
34 
35 START_NAMESPACE_DISTRHO
36 
37 /**
38  @mainpage DISTRHO %Plugin Framework
39 
40  DISTRHO %Plugin Framework (or @b DPF for short)
41  is a plugin framework designed to make development of new plugins an easy and enjoyable task.@n
42  It allows developers to create plugins with custom UIs using a simple C++ API.
43 
44  @section Macros
45  You start by creating a "DistrhoPluginInfo.h" file describing the plugin via macros, see @ref PluginMacros.
46 
47  @section Plugin
48  TODO
49 
50  @section Parameters
51  describe input and output, automable and rt safe, boolean etc, cv
52 */
53 
54 /* ------------------------------------------------------------------------------------------------------------
55  * Plugin Macros */
56 
57 #ifdef DOXYGEN
58 
59 /**
60  @defgroup PluginMacros Plugin Macros
61 
62  C Macros that describe your plugin. (defined in the "DistrhoPluginInfo.h" file)
63 
64  With these macros you can tell the host what features your plugin requires.@n
65  Depending on which macros you enable, new functions will be available to call and/or override.
66 
67  All values are either integer or strings.@n
68  For boolean-like values 1 means 'on' and 0 means 'off'.
69 
70  The values defined in this file are for documentation purposes only.@n
71  All macros are disabled by default.
72 
73  Only 4 macros are required, they are:
74  - @ref DISTRHO_PLUGIN_NAME
75  - @ref DISTRHO_PLUGIN_NUM_INPUTS
76  - @ref DISTRHO_PLUGIN_NUM_OUTPUTS
77  - @ref DISTRHO_PLUGIN_URI
78  @{
79  */
80 
81 /**
82  The plugin name.@n
83  This is used to identify your plugin before a Plugin instance can be created.
84  @note This macro is required.
85  */
86 #define DISTRHO_PLUGIN_NAME "Plugin Name"
87 
88 /**
89  Number of audio inputs the plugin has.
90  @note This macro is required.
91  */
92 #define DISTRHO_PLUGIN_NUM_INPUTS 2
93 
94 /**
95  Number of audio outputs the plugin has.
96  @note This macro is required.
97  */
98 #define DISTRHO_PLUGIN_NUM_OUTPUTS 2
99 
100 /**
101  The plugin URI when exporting in LV2 format.
102  @note This macro is required.
103  */
104 #define DISTRHO_PLUGIN_URI "urn:distrho:name"
105 
106 /**
107  Wherever the plugin has a custom %UI.
108  @see DISTRHO_UI_USE_NANOVG
109  @see UI
110  */
111 #define DISTRHO_PLUGIN_HAS_UI 1
112 
113 /**
114  Wherever the plugin processing is realtime-safe.@n
115  TODO - list rtsafe requirements
116  */
117 #define DISTRHO_PLUGIN_IS_RT_SAFE 1
118 
119 /**
120  Wherever the plugin is a synth.@n
121  @ref DISTRHO_PLUGIN_WANT_MIDI_INPUT is automatically enabled when this is too.
122  @see DISTRHO_PLUGIN_WANT_MIDI_INPUT
123  */
124 #define DISTRHO_PLUGIN_IS_SYNTH 1
125 
126 /**
127  Enable direct access between the %UI and plugin code.
128  @see UI::d_getPluginInstancePointer()
129  @note DO NOT USE THIS UNLESS STRICTLY NECESSARY!!
130  Try to avoid it at all costs!
131  */
132 #define DISTRHO_PLUGIN_WANT_DIRECT_ACCESS 0
133 
134 /**
135  Wherever the plugin introduces latency during audio or midi processing.
136  @see Plugin::d_setLatency(uint32_t)
137  */
138 #define DISTRHO_PLUGIN_WANT_LATENCY 1
139 
140 /**
141  Wherever the plugin wants MIDI input.@n
142  This is automatically enabled if @ref DISTRHO_PLUGIN_IS_SYNTH is true.
143  */
144 #define DISTRHO_PLUGIN_WANT_MIDI_INPUT 1
145 
146 /**
147  Wherever the plugin wants MIDI output.
148  @see Plugin::d_writeMidiEvent(const MidiEvent&)
149  */
150 #define DISTRHO_PLUGIN_WANT_MIDI_OUTPUT 1
151 
152 /**
153  Wherever the plugin provides its own internal programs.
154  @see Plugin::d_initProgramName(uint32_t, d_string&)
155  @see Plugin::d_setProgram(uint32_t)
156  */
157 #define DISTRHO_PLUGIN_WANT_PROGRAMS 1
158 
159 /**
160  Wherever the plugin uses internal non-parameter data.
161  @see Plugin::d_initState(uint32_t, d_string&, d_string&)
162  @see Plugin::d_setState(const char*, const char*)
163  */
164 #define DISTRHO_PLUGIN_WANT_STATE 1
165 
166 /**
167  Wherever the plugin wants time position information from the host.
168  @see Plugin::d_getTimePosition()
169  */
170 #define DISTRHO_PLUGIN_WANT_TIMEPOS 1
171 
172 /**
173  Wherever the %UI uses NanoVG for drawing instead of the default raw OpenGL calls.@n
174  When enabled your %UI instance will subclass @ref NanoWidget instead of @ref Widget.
175  */
176 #define DISTRHO_UI_USE_NANOVG 1
177 
178 /**
179  The %UI URI when exporting in LV2 format.@n
180  By default this is set to @ref DISTRHO_PLUGIN_URI with "#UI" as suffix.
181  */
182 #define DISTRHO_UI_URI DISTRHO_PLUGIN_URI "#UI"
183 
184 /** @} */
185 
186 #endif
187 
188 /* ------------------------------------------------------------------------------------------------------------
189  * Parameter Hints */
190 
191 /**
192  @defgroup ParameterHints Parameter Hints
193 
194  Various parameter hints.
195  @see Parameter::hints
196  @{
197  */
198 
199 /**
200  Parameter is automable (real-time safe).
201  @see Plugin::d_setParameterValue()
202  */
203 static const uint32_t kParameterIsAutomable = 0x01;
204 
205 /**
206  Parameter value is boolean.
207  It's always at either minimum or maximum value.
208  */
209 static const uint32_t kParameterIsBoolean = 0x02;
210 
211 /**
212  Parameter value is integer.
213  */
214 static const uint32_t kParameterIsInteger = 0x04;
215 
216 /**
217  Parameter value is logarithmic.
218  */
219 static const uint32_t kParameterIsLogarithmic = 0x08;
220 
221 /**
222  Parameter is of output type.
223  When unset, parameter is assumed to be of input type.
224 
225  Parameter inputs are changed by the host and must not be changed by the plugin.
226  The only exception being when changing programs, see Plugin::d_setProgram().
227  Outputs are changed by the plugin and never modified by the host.
228  */
229 static const uint32_t kParameterIsOutput = 0x10;
230 
231 /**
232  Parameter can be used as control voltage (LV2 only).
233  */
234 static const uint32_t kParameterIsCV = 0x20;
235 
236 /** @} */
237 
238 /* ------------------------------------------------------------------------------------------------------------
239  * DPF Base structs */
240 
241 /**
242  @defgroup BaseStructs Base Structs
243  @{
244  */
245 
246 /**
247  Parameter ranges.
248  This is used to set the default, minimum and maximum values of a parameter.
249 
250  By default a parameter has 0.0 as minimum, 1.0 as maximum and 0.0 as default.
251  When changing this struct values you must ensure maximum > minimum and default is within range.
252  */
254  /**
255  Default value.
256  */
257  float def;
258 
259  /**
260  Minimum value.
261  */
262  float min;
263 
264  /**
265  Maximum value.
266  */
267  float max;
268 
269  /**
270  Default constructor.
271  */
272  ParameterRanges() noexcept
273  : def(0.0f),
274  min(0.0f),
275  max(1.0f) {}
276 
277  /**
278  Constructor using custom values.
279  */
280  ParameterRanges(const float df, const float mn, const float mx) noexcept
281  : def(df),
282  min(mn),
283  max(mx) {}
284 
285  /**
286  Fix the default value within range.
287  */
288  void fixDefault() noexcept
289  {
290  fixValue(def);
291  }
292 
293  /**
294  Fix a value within range.
295  */
296  void fixValue(float& value) const noexcept
297  {
298  if (value < min)
299  value = min;
300  else if (value > max)
301  value = max;
302  }
303 
304  /**
305  Get a fixed value within range.
306  */
307  const float& getFixedValue(const float& value) const noexcept
308  {
309  if (value <= min)
310  return min;
311  if (value >= max)
312  return max;
313  return value;
314  }
315 
316  /**
317  Get a value normalized to 0.0<->1.0.
318  */
319  float getNormalizedValue(const float& value) const noexcept
320  {
321  const float normValue((value - min) / (max - min));
322 
323  if (normValue <= 0.0f)
324  return 0.0f;
325  if (normValue >= 1.0f)
326  return 1.0f;
327  return normValue;
328  }
329 
330  /**
331  Get a value normalized to 0.0<->1.0, fixed within range.
332  */
333  float getFixedAndNormalizedValue(const float& value) const noexcept
334  {
335  if (value <= min)
336  return 0.0f;
337  if (value >= max)
338  return 1.0f;
339 
340  const float normValue((value - min) / (max - min));
341 
342  if (normValue <= 0.0f)
343  return 0.0f;
344  if (normValue >= 1.0f)
345  return 1.0f;
346 
347  return normValue;
348  }
349 
350  /**
351  Get a proper value previously normalized to 0.0<->1.0.
352  */
353  float getUnnormalizedValue(const float& value) const noexcept
354  {
355  if (value <= 0.0f)
356  return min;
357  if (value >= 1.0f)
358  return max;
359 
360  return value * (max - min) + min;
361  }
362 };
363 
364 /**
365  Parameter.
366  */
367 struct Parameter {
368  /**
369  Hints describing this parameter.
370  @see ParameterHints
371  */
372  uint32_t hints;
373 
374  /**
375  The name of this parameter.
376  A parameter name can contain any character, but hosts might have a hard time with non-ascii ones.
377  The name doesn't have to be unique within a plugin instance, but it's recommended.
378  */
379  d_string name;
380 
381  /**
382  The symbol of this parameter.
383  A parameter symbol is a short restricted name used as a machine and human readable identifier.
384  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.
385  @note: Parameter symbols MUST be unique within a plugin instance.
386  */
387  d_string symbol;
388 
389  /**
390  The unit of this parameter.
391  This means something like "dB", "kHz" and "ms".
392  Can be left blank if units do not apply to this parameter.
393  */
394  d_string unit;
395 
396  /**
397  Ranges of this parameter.
398  The ranges describe the default, minimum and maximum values.
399  */
401 
402  /**
403  Default constructor for a null parameter.
404  */
405  Parameter() noexcept
406  : hints(0x0),
407  name(),
408  symbol(),
409  unit(),
410  ranges() {}
411 };
412 
413 /**
414  MIDI event.
415  */
416 struct MidiEvent {
417  /**
418  Size of internal data.
419  */
420  static const uint32_t kDataSize = 4;
421 
422  /**
423  Time offset in frames.
424  */
425  uint32_t frame;
426 
427  /**
428  Number of bytes used.
429  */
430  uint32_t size;
431 
432  /**
433  MIDI data.
434  If size > kDataSize, dataExt is used (otherwise null).
435  */
436  uint8_t data[kDataSize];
437  const uint8_t* dataExt;
438 };
439 
440 /**
441  Time position.
442  The @a playing and @a frame values are always valid.
443  BBT values are only valid when @a bbt.valid is true.
444 
445  This struct is inspired by the JACK Transport API.
446  */
447 struct TimePosition {
448  /**
449  Wherever the host transport is playing/rolling.
450  */
451  bool playing;
452 
453  /**
454  Current host transport position in frames.
455  */
456  uint64_t frame;
457 
458  /**
459  Bar-Beat-Tick time position.
460  */
461  struct BarBeatTick {
462  /**
463  Wherever the host transport is using BBT.
464  If false you must not read from this struct.
465  */
466  bool valid;
467 
468  /**
469  Current bar.
470  Should always be > 0.
471  The first bar is bar '1'.
472  */
473  int32_t bar;
474 
475  /**
476  Current beat within bar.
477  Should always be > 0 and <= @a beatsPerBar.
478  The first beat is beat '1'.
479  */
480  int32_t beat;
481 
482  /**
483  Current tick within beat.
484  Should always be > 0 and <= @a ticksPerBeat.
485  The first tick is tick '0'.
486  */
487  int32_t tick;
488 
489  /**
490  Number of ticks that have elapsed between frame 0 and the first beat of the current measure.
491  */
492  double barStartTick;
493 
494  /**
495  Time signature "numerator".
496  */
497  float beatsPerBar;
498 
499  /**
500  Time signature "denominator".
501  */
502  float beatType;
503 
504  /**
505  Number of ticks within a bar.
506  Usually a moderately large integer with many denominators, such as 1920.0.
507  */
508  double ticksPerBeat;
509 
510  /**
511  Number of beats per minute.
512  */
514 
515  /**
516  Default constructor for a null BBT time position.
517  */
518  BarBeatTick() noexcept
519  : valid(false),
520  bar(0),
521  beat(0),
522  tick(0),
523  barStartTick(0.0),
524  beatsPerBar(0.0f),
525  beatType(0.0f),
526  ticksPerBeat(0.0),
527  beatsPerMinute(0.0) {}
528  } bbt;
529 
530  /**
531  Default constructor for a time position.
532  */
533  TimePosition() noexcept
534  : playing(false),
535  frame(0),
536  bbt() {}
537 };
538 
539 /** @} */
540 
541 /* ------------------------------------------------------------------------------------------------------------
542  * DPF Plugin */
543 
544 /**
545  DPF Plugin class from where plugin instances are created.
546 
547  The public methods (Host state) are called from the plugin to get or set host information.
548  They can be called from a plugin instance at anytime unless stated otherwise.
549  All other methods are to be implemented by the plugin and will be called by the host.
550 
551  Shortly after a plugin instance is created, the various d_init* functions will be called by the host.
552  Host will call d_activate() before d_run(), and d_deactivate() before the plugin instance is destroyed.
553  The host may call deactivate right after activate and vice-versa, but never activate/deactivate consecutively.
554  There is no limit on how many times d_run() is called, only that activate/deactivate will be called in between.
555 
556  The buffer size and sample rate values will remain constant between activate and deactivate.
557  Buffer size is only a hint though, the host might call d_run() with a higher or lower number of frames.
558 
559  Some of this class functions are only available according to some macros.
560 
561  DISTRHO_PLUGIN_WANT_PROGRAMS activates program related features.
562  When enabled you need to implement d_initProgramName() and d_setProgram().
563 
564  DISTRHO_PLUGIN_WANT_STATE activates internal state features.
565  When enabled you need to implement d_initStateKey() and d_setState().
566 
567  The process function d_run() changes wherever DISTRHO_PLUGIN_WANT_MIDI_INPUT is enabled or not.
568  When enabled it provides midi input events.
569  */
570 class Plugin
571 {
572 public:
573  /**
574  Plugin class constructor.
575  You must set all parameter values to their defaults, matching ParameterRanges::def.
576  If you're using states you must also set them to their defaults by calling d_setState().
577  */
578  Plugin(const uint32_t parameterCount, const uint32_t programCount, const uint32_t stateCount);
579 
580  /**
581  Destructor.
582  */
583  virtual ~Plugin();
584 
585  /* --------------------------------------------------------------------------------------------------------
586  * Host state */
587 
588  /**
589  Get the current buffer size that will probably be used during processing, in frames.
590  This value will remain constant between activate and deactivate.
591  @note: This value is only a hint!
592  Hosts might call d_run() with a higher or lower number of frames.
593  @see d_bufferSizeChanged(uint32_t)
594  */
595  uint32_t d_getBufferSize() const noexcept;
596 
597  /**
598  Get the current sample rate that will be used during processing.
599  This value will remain constant between activate and deactivate.
600  @see d_sampleRateChanged(double)
601  */
602  double d_getSampleRate() const noexcept;
603 
604 #if DISTRHO_PLUGIN_WANT_TIMEPOS
605  /**
606  Get the current host transport time position.
607  This function should only be called during d_run().
608  You can call this during other times, but the returned position is not guaranteed to be in sync.
609  @note: TimePos is not supported in LADSPA and DSSI plugin formats.
610  */
611  const TimePosition& d_getTimePosition() const noexcept;
612 #endif
613 
614 #if DISTRHO_PLUGIN_WANT_LATENCY
615  /**
616  Change the plugin audio output latency to @a frames.
617  This function should only be called in the constructor, d_activate() and d_run().
618  @note This function is only available if DISTRHO_PLUGIN_WANT_LATENCY is enabled.
619  */
620  void d_setLatency(uint32_t frames) noexcept;
621 #endif
622 
623 #if DISTRHO_PLUGIN_WANT_MIDI_OUTPUT
624  /**
625  Write a MIDI output event.
626  This function must only be called during d_run().
627  Returns false when the host buffer is full, in which case do not call this again until the next d_run().
628  */
629  bool d_writeMidiEvent(const MidiEvent& midiEvent) noexcept;
630 #endif
631 
632 protected:
633  /* --------------------------------------------------------------------------------------------------------
634  * Information */
635 
636  /**
637  Get the plugin name.
638  Returns DISTRHO_PLUGIN_NAME by default.
639  */
640  virtual const char* d_getName() const { return DISTRHO_PLUGIN_NAME; }
641 
642  /**
643  Get the plugin label.
644  A plugin label follows the same rules as Parameter::symbol, with the exception that it can start with numbers.
645  */
646  virtual const char* d_getLabel() const = 0;
647 
648  /**
649  Get the plugin author/maker.
650  */
651  virtual const char* d_getMaker() const = 0;
652 
653  /**
654  Get the plugin license name (a single line of text).
655  */
656  virtual const char* d_getLicense() const = 0;
657 
658  /**
659  Get the plugin version, in hexadecimal.
660  TODO format to be defined
661  */
662  virtual uint32_t d_getVersion() const = 0;
663 
664  /**
665  Get the plugin unique Id.
666  This value is used by LADSPA, DSSI and VST plugin formats.
667  */
668  virtual int64_t d_getUniqueId() const = 0;
669 
670  /* --------------------------------------------------------------------------------------------------------
671  * Init */
672 
673  /**
674  Initialize the parameter @a index.
675  This function will be called once, shortly after the plugin is created.
676  */
677  virtual void d_initParameter(uint32_t index, Parameter& parameter) = 0;
678 
679 #if DISTRHO_PLUGIN_WANT_PROGRAMS
680  /**
681  Set the name of the program @a index.
682  This function will be called once, shortly after the plugin is created.
683  Must be implemented by your plugin class only if DISTRHO_PLUGIN_WANT_PROGRAMS is enabled.
684  */
685  virtual void d_initProgramName(uint32_t index, d_string& programName) = 0;
686 #endif
687 
688 #if DISTRHO_PLUGIN_WANT_STATE
689  /**
690  Set the state key and default value of @a index.
691  This function will be called once, shortly after the plugin is created.
692  Must be implemented by your plugin class only if DISTRHO_PLUGIN_WANT_STATE is enabled.
693  */
694  virtual void d_initState(uint32_t index, d_string& stateKey, d_string& defaultStateValue) = 0;
695 #endif
696 
697  /* --------------------------------------------------------------------------------------------------------
698  * Internal data */
699 
700  /**
701  Get the current value of a parameter.
702  The host may call this function from any context, including realtime processing.
703  */
704  virtual float d_getParameterValue(uint32_t index) const = 0;
705 
706  /**
707  Change a parameter value.
708  The host may call this function from any context, including realtime processing.
709  When a parameter is marked as automable, you must ensure no non-realtime operations are called.
710  @note This function will only be called for parameter inputs.
711  */
712  virtual void d_setParameterValue(uint32_t index, float value) = 0;
713 
714 #if DISTRHO_PLUGIN_WANT_PROGRAMS
715  /**
716  Change the currently used program to @a index.
717  The host may call this function from any context, including realtime processing.
718  Must be implemented by your plugin class only if DISTRHO_PLUGIN_WANT_PROGRAMS is enabled.
719  */
720  virtual void d_setProgram(uint32_t index) = 0;
721 #endif
722 
723 #if DISTRHO_PLUGIN_WANT_STATE
724  /**
725  Change an internal state @a key to @a value.
726  Must be implemented by your plugin class only if DISTRHO_PLUGIN_WANT_STATE is enabled.
727  */
728  virtual void d_setState(const char* key, const char* value) = 0;
729 #endif
730 
731  /* --------------------------------------------------------------------------------------------------------
732  * Process */
733 
734  /**
735  Activate this plugin.
736  */
737  virtual void d_activate() {}
738 
739  /**
740  Deactivate this plugin.
741  */
742  virtual void d_deactivate() {}
743 
744 #if DISTRHO_PLUGIN_WANT_MIDI_INPUT
745  /**
746  Run/process function for plugins with MIDI input.
747  @note: Some parameters might be null if there are no audio inputs/outputs or MIDI events.
748  */
749  virtual void d_run(const float** inputs, float** outputs, uint32_t frames,
750  const MidiEvent* midiEvents, uint32_t midiEventCount) = 0;
751 #else
752  /**
753  Run/process function for plugins without MIDI input.
754  @note: Some parameters might be null if there are no audio inputs or outputs.
755  */
756  virtual void d_run(const float** inputs, float** outputs, uint32_t frames) = 0;
757 #endif
758 
759  /* --------------------------------------------------------------------------------------------------------
760  * Callbacks (optional) */
761 
762  /**
763  Optional callback to inform the plugin about a buffer size change.
764  This function will only be called when the plugin is deactivated.
765  @note: This value is only a hint!
766  Hosts might call d_run() with a higher or lower number of frames.
767  @see d_getBufferSize()
768  */
769  virtual void d_bufferSizeChanged(uint32_t newBufferSize);
770 
771  /**
772  Optional callback to inform the plugin about a sample rate change.
773  This function will only be called when the plugin is deactivated.
774  @see d_getSampleRate()
775  */
776  virtual void d_sampleRateChanged(double newSampleRate);
777 
778  // -------------------------------------------------------------------------------------------------------
779 
780 private:
781  struct PrivateData;
782  PrivateData* const pData;
783  friend class PluginExporter;
784 
785  DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(Plugin)
786 };
787 
788 /* ------------------------------------------------------------------------------------------------------------
789  * Create plugin, entry point */
790 
791 /**
792  TODO.
793  */
794 extern Plugin* createPlugin();
795 
796 // -----------------------------------------------------------------------------------------------------------
797 
798 END_NAMESPACE_DISTRHO
799 
800 #endif // DISTRHO_PLUGIN_HPP_INCLUDED
float min
Definition: DistrhoPlugin.hpp:262
virtual const char * d_getMaker() const =0
virtual void d_initState(uint32_t index, d_string &stateKey, d_string &defaultStateValue)=0
virtual void d_deactivate()
Definition: DistrhoPlugin.hpp:742
Plugin(const uint32_t parameterCount, const uint32_t programCount, const uint32_t stateCount)
const TimePosition & d_getTimePosition() const noexcept
virtual int64_t d_getUniqueId() const =0
Parameter() noexcept
Definition: DistrhoPlugin.hpp:405
uint32_t frame
Definition: DistrhoPlugin.hpp:425
virtual uint32_t d_getVersion() const =0
uint32_t size
Definition: DistrhoPlugin.hpp:430
bool d_writeMidiEvent(const MidiEvent &midiEvent) noexcept
uint8_t data[kDataSize]
Definition: DistrhoPlugin.hpp:436
virtual float d_getParameterValue(uint32_t index) const =0
virtual void d_setParameterValue(uint32_t index, float value)=0
virtual const char * d_getLabel() const =0
void fixValue(float &value) const noexcept
Definition: DistrhoPlugin.hpp:296
virtual void d_sampleRateChanged(double newSampleRate)
double ticksPerBeat
Definition: DistrhoPlugin.hpp:508
virtual const char * d_getName() const
Definition: DistrhoPlugin.hpp:640
Definition: DistrhoPlugin.hpp:416
int32_t bar
Definition: DistrhoPlugin.hpp:473
virtual void d_run(const float **inputs, float **outputs, uint32_t frames, const MidiEvent *midiEvents, uint32_t midiEventCount)=0
virtual const char * d_getLicense() const =0
#define DISTRHO_PLUGIN_NAME
Definition: DistrhoPlugin.hpp:86
ParameterRanges() noexcept
Definition: DistrhoPlugin.hpp:272
double beatsPerMinute
Definition: DistrhoPlugin.hpp:513
uint32_t hints
Definition: DistrhoPlugin.hpp:372
static const uint32_t kParameterIsCV
Definition: DistrhoPlugin.hpp:234
Definition: DistrhoPlugin.hpp:570
float getUnnormalizedValue(const float &value) const noexcept
Definition: DistrhoPlugin.hpp:353
bool playing
Definition: DistrhoPlugin.hpp:451
int32_t tick
Definition: DistrhoPlugin.hpp:487
float beatsPerBar
Definition: DistrhoPlugin.hpp:497
virtual ~Plugin()
TimePosition() noexcept
Definition: DistrhoPlugin.hpp:533
virtual void d_setProgram(uint32_t index)=0
uint64_t frame
Definition: DistrhoPlugin.hpp:456
BarBeatTick() noexcept
Definition: DistrhoPlugin.hpp:518
static const uint32_t kParameterIsAutomable
Definition: DistrhoPlugin.hpp:203
virtual void d_setState(const char *key, const char *value)=0
float beatType
Definition: DistrhoPlugin.hpp:502
float getNormalizedValue(const float &value) const noexcept
Definition: DistrhoPlugin.hpp:319
float def
Definition: DistrhoPlugin.hpp:257
double barStartTick
Definition: DistrhoPlugin.hpp:492
d_string name
Definition: DistrhoPlugin.hpp:379
void d_setLatency(uint32_t frames) noexcept
d_string unit
Definition: DistrhoPlugin.hpp:394
ParameterRanges ranges
Definition: DistrhoPlugin.hpp:400
int32_t beat
Definition: DistrhoPlugin.hpp:480
virtual void d_initParameter(uint32_t index, Parameter &parameter)=0
virtual void d_bufferSizeChanged(uint32_t newBufferSize)
const float & getFixedValue(const float &value) const noexcept
Definition: DistrhoPlugin.hpp:307
static const uint32_t kParameterIsBoolean
Definition: DistrhoPlugin.hpp:209
float max
Definition: DistrhoPlugin.hpp:267
Definition: DistrhoPlugin.hpp:253
static const uint32_t kParameterIsInteger
Definition: DistrhoPlugin.hpp:214
Definition: DistrhoPlugin.hpp:367
bool valid
Definition: DistrhoPlugin.hpp:466
static const uint32_t kDataSize
Definition: DistrhoPlugin.hpp:420
d_string symbol
Definition: DistrhoPlugin.hpp:387
void fixDefault() noexcept
Definition: DistrhoPlugin.hpp:288
double d_getSampleRate() const noexcept
float getFixedAndNormalizedValue(const float &value) const noexcept
Definition: DistrhoPlugin.hpp:333
virtual void d_activate()
Definition: DistrhoPlugin.hpp:737
static const uint32_t kParameterIsOutput
Definition: DistrhoPlugin.hpp:229
Definition: DistrhoPlugin.hpp:461
Definition: DistrhoPlugin.hpp:447
virtual void d_initProgramName(uint32_t index, d_string &programName)=0
uint32_t d_getBufferSize() const noexcept
static const uint32_t kParameterIsLogarithmic
Definition: DistrhoPlugin.hpp:219
ParameterRanges(const float df, const float mn, const float mx) noexcept
Definition: DistrhoPlugin.hpp:280