1 /* -----------------------------------------------------------------------------
2  *
3  * Giada - Your Hardcore Loopmachine
4  *
5  * -----------------------------------------------------------------------------
6  *
7  * Copyright (C) 2010-2020 Giovanni A. Zuliani | Monocasual
8  *
9  * This file is part of Giada - Your Hardcore Loopmachine.
10  *
11  * Giada - Your Hardcore Loopmachine is free software: you can
12  * redistribute it and/or modify it under the terms of the GNU General
13  * Public License as published by the Free Software Foundation, either
14  * version 3 of the License, or (at your option) any later version.
15  *
16  * Giada - Your Hardcore Loopmachine is distributed in the hope that it
17  * will be useful, but WITHOUT ANY WARRANTY; without even the implied
18  * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19  * See the GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with Giada - Your Hardcore Loopmachine. If not, see
23  * <http://www.gnu.org/licenses/>.
24  *
25  * -------------------------------------------------------------------------- */
26 
27 
28 #ifndef G_GLUE_PLUGIN_H
29 #define G_GLUE_PLUGIN_H
30 
31 
32 #ifdef WITH_VST
33 
34 
35 #include <vector>
36 #include <string>
37 #include "core/plugins/pluginHost.h"
38 #include "core/types.h"
39 
40 
41 namespace juce {
42 class AudioProcessorEditor;
43 }
44 
45 
46 namespace giada {
47 namespace m
48 {
49 class Plugin;
50 class Channel;
51 }
52 namespace c {
53 namespace plugin
54 {
55 struct Program
56 {
57     int         index;
58     std::string name;
59 };
60 
61 struct Param
62 {
63     Param() = default;
64     Param(const m::Plugin&, int index);
65 
66     int         index;
67     ID          pluginId;
68     std::string name;
69     std::string text;
70     std::string label;
71     float       value;
72 };
73 
74 struct Plugin
75 {
76     Plugin(m::Plugin&, ID channelId);
77 
78     juce::AudioProcessorEditor* createEditor() const;
79 
80     void setResizeCallback(std::function<void(int, int)> f);
81 
82     ID          id;
83     ID          channelId;
84     bool        valid;
85     bool        hasEditor;
86     bool        isBypassed;
87     std::string name;
88     std::string uniqueId;
89     int         currentProgram;
90 
91     std::vector<Program> programs;
92     std::vector<int>     paramIndexes;
93 
94 private:
95 
96     m::Plugin& m_plugin;
97 };
98 
99 struct Plugins
100 {
101     Plugins() = default;
102     Plugins(const m::Channel&);
103 
104     ID channelId;
105     std::vector<ID> pluginIds;
106 };
107 
108 /* get*
109 Returns ViewModel objects. */
110 
111 Plugins getPlugins(ID channelId);
112 Plugin  getPlugin (ID pluginId, ID channelId);
113 Param   getParam  (int index, ID pluginId);
114 
115 /* updateWindow
116 Updates the editor-less plug-in window. This is useless if the plug-in has an
117 editor. */
118 
119 void updateWindow(ID pluginId, bool gui);
120 
121 void addPlugin(int pluginListIndex, ID channelId);
122 void swapPlugins(ID pluginId1, ID pluginId2, ID channelId);
123 void freePlugin(ID pluginId, ID channelId);
124 void setProgram(ID pluginId, int programIndex);
125 void toggleBypass(ID pluginId);
126 
127 /* setPluginPathCb
128 Callback attached to the DirBrowser for adding new Plug-in search paths in the
129 configuration window. */
130 
131 void setPluginPathCb(void* data);
132 }}} // giada::c::plugin::
133 
134 
135 #endif
136 
137 
138 #endif
139