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.

181 lines
5.9KB

  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. #include "DistrhoPlugin.hpp"
  17. START_NAMESPACE_DISTRHO
  18. // -----------------------------------------------------------------------------------------------------------
  19. /**
  20. Simple plugin to demonstrate parameter usage (including UI).
  21. The plugin will be treated as an effect, but it will not change the host audio.
  22. */
  23. class ExamplePluginParameters : public Plugin
  24. {
  25. public:
  26. ExamplePluginParameters()
  27. : Plugin(0, 0, 0) {} // 0 parameters, 0 programs, 0 states
  28. protected:
  29. /* --------------------------------------------------------------------------------------------------------
  30. * Information */
  31. /**
  32. Get the plugin label.
  33. A plugin label follows the same rules as Parameter::symbol, with the exception that it can start with numbers.
  34. */
  35. const char* getLabel() const override
  36. {
  37. return "CVPort";
  38. }
  39. /**
  40. Get an extensive comment/description about the plugin.
  41. */
  42. const char* getDescription() const override
  43. {
  44. return "Simple plugin with CVPort.\n\
  45. The plugin will be treated as an effect, signal will bypassed.";
  46. }
  47. /**
  48. Get the plugin author/maker.
  49. */
  50. const char* getMaker() const override
  51. {
  52. return "DISTRHO";
  53. }
  54. /**
  55. Get the plugin homepage.
  56. */
  57. const char* getHomePage() const override
  58. {
  59. return "https://github.com/DISTRHO/DPF";
  60. }
  61. /**
  62. Get the plugin license name (a single line of text).
  63. For commercial plugins this should return some short copyright information.
  64. */
  65. const char* getLicense() const override
  66. {
  67. return "ISC";
  68. }
  69. /**
  70. Get the plugin version, in hexadecimal.
  71. */
  72. uint32_t getVersion() const override
  73. {
  74. return d_version(1, 0, 0);
  75. }
  76. /**
  77. Get the plugin unique Id.
  78. This value is used by LADSPA, DSSI and VST plugin formats.
  79. */
  80. int64_t getUniqueId() const override
  81. {
  82. return d_cconst('d', 'C', 'V', 'P');
  83. }
  84. /* --------------------------------------------------------------------------------------------------------
  85. * Init */
  86. /**
  87. Initialize the audio port @a index.@n
  88. This function will be called once, shortly after the plugin is created.
  89. */
  90. void initAudioPort(bool input, uint32_t index, AudioPort& port) override
  91. {
  92. /**
  93. Note that index is independent for input and output.
  94. In other words, input port index starts from 0 and output port index also starts from 0.
  95. */
  96. if (input)
  97. {
  98. if (index == 0) {
  99. port.hints = kAudioPortIsCV;
  100. port.name = "CV Input";
  101. port.symbol = "cv_in";
  102. return;
  103. }
  104. // Add more condition here when increasing DISTRHO_PLUGIN_NUM_INPUTS.
  105. }
  106. else
  107. {
  108. if (index == 0) {
  109. port.hints = kAudioPortIsCV;
  110. port.name = "CV Output";
  111. port.symbol = "cv_out";
  112. return;
  113. }
  114. // Add more condition here when increasing DISTRHO_PLUGIN_NUM_OUTPUTS.
  115. }
  116. /**
  117. It shouldn't reach here, but just in case if index is greater than 0.
  118. */
  119. Plugin::initAudioPort(input, index, port);
  120. }
  121. /* --------------------------------------------------------------------------------------------------------
  122. * Init and Internal data, unused in this plugin */
  123. void initParameter(uint32_t, Parameter&) override {}
  124. float getParameterValue(uint32_t) const override { return 0.0f;}
  125. void setParameterValue(uint32_t, float) override {}
  126. /* --------------------------------------------------------------------------------------------------------
  127. * Process */
  128. /**
  129. Run/process function for plugins without MIDI input.
  130. */
  131. void run(const float** inputs, float** outputs, uint32_t frames) override
  132. {
  133. /**
  134. This plugin does nothing, it just demonstrates CVPort usage.
  135. So here we directly copy inputs over outputs, leaving the audio untouched.
  136. We need to be careful in case the host re-uses the same buffer for both ins and outs.
  137. */
  138. if (outputs[0] != inputs[0])
  139. std::memcpy(outputs[0], inputs[0], sizeof(float)*frames);
  140. }
  141. // -------------------------------------------------------------------------------------------------------
  142. private:
  143. /**
  144. Set our plugin class as non-copyable and add a leak detector just in case.
  145. */
  146. DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ExamplePluginParameters)
  147. };
  148. /* ------------------------------------------------------------------------------------------------------------
  149. * Plugin entry point, called by DPF to create a new plugin instance. */
  150. Plugin* createPlugin()
  151. {
  152. return new ExamplePluginParameters();
  153. }
  154. // -----------------------------------------------------------------------------------------------------------
  155. END_NAMESPACE_DISTRHO