DPF

DISTRHO Plugin Framework
Log | Files | Refs | Submodules | README | LICENSE

MidiThroughExamplePlugin.cpp (4097B)


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