lv2 resize, pot, slider
[goodguy/history.git] / cinelerra-5.1 / cinelerra / pluginlv2client.h
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  *
20  */
21
22 #ifndef PLUGINLV2CLIENT_H
23 #define PLUGINLV2CLIENT_H
24
25 #include "bcdisplayinfo.h"
26 #include "guicast.h"
27 #include "pluginaclient.h"
28 #include "pluginlv2client.inc"
29 #include "samples.inc"
30
31 #include <lilv/lilv.h>
32 #include <lv2/lv2plug.in/ns/ext/atom/atom.h>
33 #include <lv2/lv2plug.in/ns/ext/buf-size/buf-size.h>
34
35 class PluginLV2UriTable : public ArrayList<const char *>
36 {
37 public:
38         PluginLV2UriTable();
39         ~PluginLV2UriTable();
40         LV2_URID map(const char *uri);
41         const char *unmap(LV2_URID urid);
42 };
43
44 class PluginLV2Client_OptName : public BC_ListBoxItem
45 {
46 public:
47         PluginLV2Client_Opt *opt;
48         PluginLV2Client_OptName(PluginLV2Client_Opt *opt);
49 };
50
51 class PluginLV2Client_OptValue : public BC_ListBoxItem
52 {
53 public:
54         PluginLV2Client_Opt *opt;
55         PluginLV2Client_OptValue(PluginLV2Client_Opt *opt);
56         int update();
57 };
58
59 class PluginLV2Client_Opt
60 {
61 public:
62         int idx;
63         const char *sym;
64         PluginLV2ClientConfig *conf;
65         PluginLV2Client_OptName *item_name;
66         PluginLV2Client_OptValue *item_value;
67         float get_value();
68         void set_value(float v);
69         int update(float v);
70         const char *get_name();
71
72         PluginLV2Client_Opt(PluginLV2ClientConfig *conf, const char *sym, int idx);
73         ~PluginLV2Client_Opt();
74 };
75
76
77 class PluginLV2ClientConfig : public ArrayList<PluginLV2Client_Opt *>
78 {
79 public:
80         PluginLV2ClientConfig();
81         ~PluginLV2ClientConfig();
82
83         int equivalent(PluginLV2ClientConfig &that);
84         void copy_from(PluginLV2ClientConfig &that);
85         void interpolate(PluginLV2ClientConfig &prev, PluginLV2ClientConfig &next,
86                 int64_t prev_frame, int64_t next_frame, int64_t current_frame);
87         void reset();
88         void init_lv2(const LilvPlugin *lilv);
89         int update();
90
91         int nb_ports;
92         const char **names;
93         float *mins, *maxs, *ctls;
94 };
95
96 class PluginLV2Client_OptPanel : public BC_ListBox
97 {
98 public:
99         PluginLV2Client_OptPanel(PluginLV2ClientWindow *gui, int x, int y, int w, int h);
100         ~PluginLV2Client_OptPanel();
101
102         PluginLV2ClientWindow *gui;
103         ArrayList<BC_ListBoxItem*> items[2];
104         ArrayList<BC_ListBoxItem*> &opts;
105         ArrayList<BC_ListBoxItem*> &vals;
106
107         int selection_changed();
108         void update();
109 };
110
111 class PluginLV2ClientText : public BC_TextBox {
112 public:
113         PluginLV2ClientWindow *gui;
114
115         PluginLV2ClientText(PluginLV2ClientWindow *gui, int x, int y, int w);
116         ~PluginLV2ClientText();
117         int handle_event();
118 };
119
120 class PluginLV2ClientReset : public BC_GenericButton
121 {
122 public:
123         PluginLV2ClientWindow *gui;
124
125         PluginLV2ClientReset(PluginLV2ClientWindow *gui, int x, int y);
126         ~PluginLV2ClientReset();
127         int handle_event();
128 };
129
130 class PluginLV2ClientApply : public BC_GenericButton {
131 public:
132         PluginLV2ClientWindow *gui;
133
134         PluginLV2ClientApply(PluginLV2ClientWindow *gui, int x, int y);
135         ~PluginLV2ClientApply();
136         int handle_event();
137 };
138
139 class PluginLV2ClientPot : public BC_FPot
140 {
141 public:
142         PluginLV2ClientPot(PluginLV2ClientWindow *gui, int x, int y);
143         int handle_event();
144         PluginLV2ClientWindow *gui;
145 };
146
147 class PluginLV2ClientSlider : public BC_FSlider
148 {
149 public:
150         PluginLV2ClientSlider(PluginLV2ClientWindow *gui, int x, int y);
151         int handle_event();
152         PluginLV2ClientWindow *gui;
153 };
154
155 class PluginLV2ClientWindow : public PluginClientWindow
156 {
157 public:
158         PluginLV2ClientWindow(PluginLV2Client *plugin);
159         ~PluginLV2ClientWindow();
160
161         void create_objects();
162         int resize_event(int w, int h);
163         void update_selected();
164         void update_selected(float v);
165         int scalar(float f, char *rp);
166         void update(PluginLV2Client_Opt *opt);
167
168         PluginLV2Client *plugin;
169         PluginLV2ClientReset *reset;
170         PluginLV2ClientApply *apply;
171         PluginLV2ClientPot *pot;
172         PluginLV2ClientSlider *slider;
173         PluginLV2ClientText *text;
174         BC_Title *varbl, *range;
175         PluginLV2Client_OptPanel *panel;
176         PluginLV2Client_Opt *selected;
177 };
178
179
180 class PluginLV2Client : public PluginAClient
181 {
182 public:
183         PluginLV2Client(PluginServer *server);
184         ~PluginLV2Client();
185
186         int process_realtime(int64_t size,
187                 Samples *input_ptr,
188                 Samples *output_ptr);
189         int process_realtime(int64_t size,
190                 Samples **input_ptr,
191                 Samples **output_ptr);
192 // Update output pointers as well
193         void update_gui();
194         int is_realtime();
195         int is_multichannel();
196         int is_synthesis();
197         int uses_gui();
198         char* to_string(char *string, const char *input);
199         void save_data(KeyFrame *keyframe);
200         void read_data(KeyFrame *keyframe);
201         void reset_lv2();
202         int load_lv2(const char *path);
203         int init_lv2();
204
205         PLUGIN_CLASS_MEMBERS(PluginLV2ClientConfig)
206         char title[BCSTRLEN];
207         int bfrsz, nb_in_bfrs, nb_out_bfrs;
208         float **in_buffers, **out_buffers;
209
210         void delete_buffers();
211         void init_plugin(int size);
212         void connect_ports();
213         static LV2_URID uri_table_map(LV2_URID_Map_Handle handle, const char *uri);
214         static const char *uri_table_unmap(LV2_URID_Map_Handle handle, LV2_URID urid);
215
216 // lv2
217         LilvWorld         *world;
218         const LilvPlugin  *lilv;
219         int nb_inputs, nb_outputs;
220         int max_bufsz;
221
222         PluginLV2UriTable  uri_table;
223         LV2_URID_Map       map;
224         LV2_Feature        map_feature;
225         LV2_URID_Unmap     unmap;
226         LV2_Feature        unmap_feature;
227         const LV2_Feature  *features[6];
228         LV2_Atom_Sequence  seq_in[2];
229         LV2_Atom_Sequence  *seq_out;
230
231         LilvInstance *instance;
232         LilvNode *atom_AtomPort;
233         LilvNode *atom_Sequence;
234         LilvNode *lv2_AudioPort;
235         LilvNode *lv2_CVPort;
236         LilvNode *lv2_ControlPort;
237         LilvNode *lv2_Optional;
238         LilvNode *lv2_InputPort;
239         LilvNode *lv2_OutputPort;
240         LilvNode *urid_map;
241         LilvNode *powerOf2BlockLength;
242         LilvNode *fixedBlockLength;
243         LilvNode *boundedBlockLength;
244 };
245
246 #endif