1 /*
2  * DISTRHO Plugin Framework (DPF)
3  * Copyright (C) 2012-2019 Filipe Coelho <falktx@falktx.com>
4  * Copyright (C) 2019-2021 Jean Pierre Cimalando <jp-dev@inbox.ru>
5  *
6  * Permission to use, copy, modify, and/or distribute this software for any purpose with
7  * or without fee is hereby granted, provided that the above copyright notice and this
8  * permission notice appear in all copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
11  * TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
12  * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
14  * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
15  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16  */
17 
18 #include "DistrhoPlugin.hpp"
19 
20 #include <string.h>
21 
22 START_NAMESPACE_DISTRHO
23 
24 class CairoExamplePlugin : public Plugin
25 {
26 public:
CairoExamplePlugin()27     CairoExamplePlugin()
28         : Plugin(0, 0, 0)
29     {
30     }
31 
getLabel() const32     const char* getLabel() const
33     {
34         return "Cairo DPF Example";
35     }
36 
getMaker() const37     const char* getMaker() const
38     {
39         return "Jean Pierre Cimalando";
40     }
41 
getLicense() const42     const char* getLicense() const
43     {
44         return "ISC";
45     }
46 
getVersion() const47     uint32_t getVersion() const
48     {
49         return d_version(1, 0, 0);
50     }
51 
getUniqueId() const52     int64_t getUniqueId() const
53     {
54         return d_cconst('d', 'C', 'a', 'i');
55     }
56 
initParameter(uint32_t index,Parameter & parameter)57     void initParameter(uint32_t index, Parameter& parameter)
58     {
59         // unused
60         (void)index;
61         (void)parameter;
62     }
63 
getParameterValue(uint32_t index) const64     float getParameterValue(uint32_t index) const
65     {
66         return 0;
67 
68         // unused
69         (void)index;
70     }
71 
setParameterValue(uint32_t index,float value)72     void setParameterValue(uint32_t index, float value)
73     {
74         // unused
75         (void)index;
76         (void)value;
77     }
78 
run(const float ** inputs,float ** outputs,uint32_t frames)79     void run(const float** inputs, float** outputs, uint32_t frames)
80     {
81        /**
82           This plugin does nothing, it just demonstrates cairo UI usage.
83           So here we directly copy inputs over outputs, leaving the audio untouched.
84           We need to be careful in case the host re-uses the same buffer for both inputs and outputs.
85         */
86         if (outputs[0] != inputs[0])
87             std::memcpy(outputs[0], inputs[0], sizeof(float)*frames);
88     }
89 };
90 
createPlugin()91 Plugin* createPlugin()
92 {
93     return new CairoExamplePlugin;
94 }
95 
96 END_NAMESPACE_DISTRHO
97