comparison DPF-Prymula-audioplugins/dpf/distrho/src/DistrhoPluginStub.cpp @ 3:84e66ea83026

DPF-Prymula-audioplugins-0.231015-2
author prymula <prymula76@outlook.com>
date Mon, 16 Oct 2023 21:53:34 +0200
parents
children
comparison
equal deleted inserted replaced
2:cf2cb71d31dd 3:84e66ea83026
1 /*
2 * DISTRHO Plugin Framework (DPF)
3 * Copyright (C) 2012-2022 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 "DistrhoPluginInternal.hpp"
18
19 START_NAMESPACE_DISTRHO
20
21 // --------------------------------------------------------------------------------------------------------------------
22
23 #if ! DISTRHO_PLUGIN_WANT_MIDI_OUTPUT
24 static constexpr const writeMidiFunc writeMidiCallback = nullptr;
25 #endif
26 #if ! DISTRHO_PLUGIN_WANT_PARAMETER_VALUE_CHANGE_REQUEST
27 static constexpr const requestParameterValueChangeFunc requestParameterValueChangeCallback = nullptr;
28 #endif
29 #if ! DISTRHO_PLUGIN_WANT_STATE
30 static const updateStateValueFunc updateStateValueCallback = nullptr;
31 #endif
32
33 // --------------------------------------------------------------------------------------------------------------------
34
35 /**
36 * Stub plugin class, does nothing but serving as example code for other implementations.
37 */
38 class PluginStub
39 {
40 public:
41 PluginStub()
42 : fPlugin(this,
43 writeMidiCallback,
44 requestParameterValueChangeCallback,
45 updateStateValueCallback)
46 {
47 }
48
49 // ----------------------------------------------------------------------------------------------------------------
50
51 private:
52 // Plugin
53 PluginExporter fPlugin;
54
55 // ----------------------------------------------------------------------------------------------------------------
56 // DPF callbacks
57
58 #if DISTRHO_PLUGIN_WANT_MIDI_OUTPUT
59 bool writeMidi(const MidiEvent&)
60 {
61 return true;
62 }
63
64 static bool writeMidiCallback(void* const ptr, const MidiEvent& midiEvent)
65 {
66 return ((PluginStub*)ptr)->writeMidi(midiEvent);
67 }
68 #endif
69
70 #if DISTRHO_PLUGIN_WANT_PARAMETER_VALUE_CHANGE_REQUEST
71 bool requestParameterValueChange(uint32_t, float)
72 {
73 return true;
74 }
75
76 static bool requestParameterValueChangeCallback(void* const ptr, const uint32_t index, const float value)
77 {
78 return ((PluginStub*)ptr)->requestParameterValueChange(index, value);
79 }
80 #endif
81
82 #if DISTRHO_PLUGIN_WANT_STATE
83 bool updateState(const char*, const char*)
84 {
85 return true;
86 }
87
88 static bool updateStateValueCallback(void* const ptr, const char* const key, const char* const value)
89 {
90 return ((PluginStub*)ptr)->updateState(key, value);
91 }
92 #endif
93 };
94
95 END_NAMESPACE_DISTRHO
96
97 // --------------------------------------------------------------------------------------------------------------------