DISTRHO Plugin Framework
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

189 lines
5.8KB

  1. /*
  2. * DISTRHO Plugin Framework (DPF)
  3. * Copyright (C) 2012-2018 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. #include "DistrhoPlugin.hpp"
  17. START_NAMESPACE_DISTRHO
  18. // -----------------------------------------------------------------------------------------------------------
  19. /**
  20. Plugin to show how to get some basic information sent to the UI.
  21. */
  22. class ExternalExamplePlugin : public Plugin
  23. {
  24. public:
  25. ExternalExamplePlugin()
  26. : Plugin(kParameterCount, 0, 0),
  27. fValue(0.0f)
  28. {
  29. }
  30. protected:
  31. /* --------------------------------------------------------------------------------------------------------
  32. * Information */
  33. /**
  34. Get the plugin label.
  35. This label is a short restricted name consisting of only _, a-z, A-Z and 0-9 characters.
  36. */
  37. const char* getLabel() const override
  38. {
  39. return "ExternalUI";
  40. }
  41. /**
  42. Get an extensive comment/description about the plugin.
  43. */
  44. const char* getDescription() const override
  45. {
  46. return "Plugin to show how to use an external / remote UI.";
  47. }
  48. /**
  49. Get the plugin author/maker.
  50. */
  51. const char* getMaker() const override
  52. {
  53. return "DISTRHO";
  54. }
  55. /**
  56. Get the plugin homepage.
  57. */
  58. const char* getHomePage() const override
  59. {
  60. return "https://github.com/DISTRHO/DPF";
  61. }
  62. /**
  63. Get the plugin license name (a single line of text).
  64. For commercial plugins this should return some short copyright information.
  65. */
  66. const char* getLicense() const override
  67. {
  68. return "ISC";
  69. }
  70. /**
  71. Get the plugin version, in hexadecimal.
  72. */
  73. uint32_t getVersion() const override
  74. {
  75. return d_version(1, 0, 0);
  76. }
  77. /**
  78. Get the plugin unique Id.
  79. This value is used by LADSPA, DSSI and VST plugin formats.
  80. */
  81. int64_t getUniqueId() const override
  82. {
  83. return d_cconst('d', 'E', 'x', 't');
  84. }
  85. /* --------------------------------------------------------------------------------------------------------
  86. * Init */
  87. /**
  88. Initialize the parameter @a index.
  89. This function will be called once, shortly after the plugin is created.
  90. */
  91. void initParameter(uint32_t index, Parameter& parameter) override
  92. {
  93. if (index != 0)
  94. return;
  95. parameter.hints = kParameterIsAutomable|kParameterIsInteger;
  96. parameter.ranges.def = 0.0f;
  97. parameter.ranges.min = 0.0f;
  98. parameter.ranges.max = 100.0f;
  99. parameter.name = "Value";
  100. parameter.symbol = "value";
  101. }
  102. /* --------------------------------------------------------------------------------------------------------
  103. * Internal data */
  104. /**
  105. Get the current value of a parameter.
  106. The host may call this function from any context, including realtime processing.
  107. */
  108. float getParameterValue(uint32_t index) const override
  109. {
  110. if (index != 0)
  111. return 0.0f;
  112. return fValue;
  113. }
  114. /**
  115. Change a parameter value.
  116. The host may call this function from any context, including realtime processing.
  117. When a parameter is marked as automable, you must ensure no non-realtime operations are performed.
  118. @note This function will only be called for parameter inputs.
  119. */
  120. void setParameterValue(uint32_t index, float value) override
  121. {
  122. if (index != 0)
  123. return;
  124. fValue = value;
  125. }
  126. /* --------------------------------------------------------------------------------------------------------
  127. * Audio/MIDI Processing */
  128. /**
  129. Run/process function for plugins without MIDI input.
  130. @note Some parameters might be null if there are no audio inputs or outputs.
  131. */
  132. void run(const float** inputs, float** outputs, uint32_t frames) override
  133. {
  134. /**
  135. This plugin does nothing, it just demonstrates information usage.
  136. So here we directly copy inputs over outputs, leaving the audio untouched.
  137. We need to be careful in case the host re-uses the same buffer for both inputs and outputs.
  138. */
  139. if (outputs[0] != inputs[0])
  140. std::memcpy(outputs[0], inputs[0], sizeof(float)*frames);
  141. }
  142. // -------------------------------------------------------------------------------------------------------
  143. private:
  144. // Parameters
  145. float fValue;
  146. /**
  147. Set our plugin class as non-copyable and add a leak detector just in case.
  148. */
  149. DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ExternalExamplePlugin)
  150. };
  151. /* ------------------------------------------------------------------------------------------------------------
  152. * Plugin entry point, called by DPF to create a new plugin instance. */
  153. Plugin* createPlugin()
  154. {
  155. return new ExternalExamplePlugin();
  156. }
  157. // -----------------------------------------------------------------------------------------------------------
  158. END_NAMESPACE_DISTRHO