DPF Plugin examples
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.

MidiThroughExamplePlugin.cpp 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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 that demonstrates the latency API in DPF.
  21. */
  22. class MidiThroughExamplePlugin : public Plugin
  23. {
  24. public:
  25. MidiThroughExamplePlugin()
  26. : Plugin(0, 0, 0) {}
  27. protected:
  28. /* --------------------------------------------------------------------------------------------------------
  29. * Information */
  30. /**
  31. Get the plugin label.
  32. This label is a short restricted name consisting of only _, a-z, A-Z and 0-9 characters.
  33. */
  34. const char* getLabel() const override
  35. {
  36. return "MidiThrough";
  37. }
  38. /**
  39. Get an extensive comment/description about the plugin.
  40. */
  41. const char* getDescription() const override
  42. {
  43. return "Plugin that demonstrates the latency API in DPF.";
  44. }
  45. /**
  46. Get the plugin author/maker.
  47. */
  48. const char* getMaker() const override
  49. {
  50. return "DISTRHO";
  51. }
  52. /**
  53. Get the plugin homepage.
  54. */
  55. const char* getHomePage() const override
  56. {
  57. return "https://github.com/DISTRHO/plugin-examples";
  58. }
  59. /**
  60. Get the plugin license name (a single line of text).
  61. For commercial plugins this should return some short copyright information.
  62. */
  63. const char* getLicense() const override
  64. {
  65. return "ISC";
  66. }
  67. /**
  68. Get the plugin version, in hexadecimal.
  69. */
  70. uint32_t getVersion() const override
  71. {
  72. return d_version(1, 0, 0);
  73. }
  74. /**
  75. Get the plugin unique Id.
  76. This value is used by LADSPA, DSSI and VST plugin formats.
  77. */
  78. int64_t getUniqueId() const override
  79. {
  80. return d_cconst('d', 'M', 'T', 'r');
  81. }
  82. /* --------------------------------------------------------------------------------------------------------
  83. * Init and Internal data, unused in this plugin */
  84. void initParameter(uint32_t, Parameter&) override {}
  85. float getParameterValue(uint32_t) const override { return 0.0f;}
  86. void setParameterValue(uint32_t, float) override {}
  87. /* --------------------------------------------------------------------------------------------------------
  88. * Audio/MIDI Processing */
  89. /**
  90. Run/process function for plugins with MIDI input.
  91. In this case we just pass-through all MIDI events.
  92. */
  93. void run(const float**, float**, uint32_t,
  94. const MidiEvent* midiEvents, uint32_t midiEventCount) override
  95. {
  96. for (uint32_t i=0; i<midiEventCount; ++i)
  97. writeMidiEvent(midiEvents[i]);
  98. }
  99. // -------------------------------------------------------------------------------------------------------
  100. private:
  101. // nothing here :)
  102. /**
  103. Set our plugin class as non-copyable and add a leak detector just in case.
  104. */
  105. DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(MidiThroughExamplePlugin)
  106. };
  107. /* ------------------------------------------------------------------------------------------------------------
  108. * Plugin entry point, called by DPF to create a new plugin instance. */
  109. Plugin* createPlugin()
  110. {
  111. return new MidiThroughExamplePlugin();
  112. }
  113. // -----------------------------------------------------------------------------------------------------------
  114. END_NAMESPACE_DISTRHO