add lv2ui support
[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 "pluginaclient.h"
26 #include "pluginlv2config.h"
27 #include "pluginlv2client.inc"
28 #include "pluginlv2gui.h"
29 #include "samples.inc"
30
31 #define LV2_SEQ_SIZE  9624
32
33 class PluginLV2Client_OptPanel : public BC_ListBox
34 {
35 public:
36         PluginLV2Client_OptPanel(PluginLV2ClientWindow *gui, int x, int y, int w, int h);
37         ~PluginLV2Client_OptPanel();
38
39         PluginLV2ClientWindow *gui;
40         ArrayList<BC_ListBoxItem*> items[2];
41         ArrayList<BC_ListBoxItem*> &opts;
42         ArrayList<BC_ListBoxItem*> &vals;
43
44         int selection_changed();
45         void update();
46 };
47
48 class PluginLV2ClientText : public BC_TextBox {
49 public:
50         PluginLV2ClientWindow *gui;
51
52         PluginLV2ClientText(PluginLV2ClientWindow *gui, int x, int y, int w);
53         ~PluginLV2ClientText();
54         int handle_event();
55 };
56
57 class PluginLV2ClientReset : public BC_GenericButton
58 {
59 public:
60         PluginLV2ClientWindow *gui;
61
62         PluginLV2ClientReset(PluginLV2ClientWindow *gui, int x, int y);
63         ~PluginLV2ClientReset();
64         int handle_event();
65 };
66
67 class PluginLV2ClientUI : public BC_GenericButton {
68 public:
69         PluginLV2ClientWindow *gui;
70
71         PluginLV2ClientUI(PluginLV2ClientWindow *gui, int x, int y);
72         ~PluginLV2ClientUI();
73         int handle_event();
74 };
75
76 class PluginLV2ClientApply : public BC_GenericButton {
77 public:
78         PluginLV2ClientWindow *gui;
79
80         PluginLV2ClientApply(PluginLV2ClientWindow *gui, int x, int y);
81         ~PluginLV2ClientApply();
82         int handle_event();
83 };
84
85 class PluginLV2ClientPot : public BC_FPot
86 {
87 public:
88         PluginLV2ClientPot(PluginLV2ClientWindow *gui, int x, int y);
89         int handle_event();
90         PluginLV2ClientWindow *gui;
91 };
92
93 class PluginLV2ClientSlider : public BC_FSlider
94 {
95 public:
96         PluginLV2ClientSlider(PluginLV2ClientWindow *gui, int x, int y);
97         int handle_event();
98         PluginLV2ClientWindow *gui;
99 };
100
101 class PluginLV2ClientWindow : public PluginClientWindow
102 {
103 public:
104         PluginLV2ClientWindow(PluginLV2Client *plugin);
105         ~PluginLV2ClientWindow();
106
107         void create_objects();
108         int resize_event(int w, int h);
109         void update_selected();
110         void update_selected(float v);
111         int scalar(float f, char *rp);
112         void update(PluginLV2Client_Opt *opt);
113
114         PluginLV2Client *plugin;
115         PluginLV2ClientUI *ui;
116         PluginLV2ClientReset *reset;
117         PluginLV2ClientApply *apply;
118         PluginLV2ClientPot *pot;
119         PluginLV2ClientSlider *slider;
120         PluginLV2ClientText *text;
121         BC_Title *varbl, *range;
122         PluginLV2Client_OptPanel *panel;
123         PluginLV2Client_Opt *selected;
124 };
125
126
127 class PluginLV2Client : public PluginAClient
128 {
129 public:
130         PluginLV2Client(PluginServer *server);
131         ~PluginLV2Client();
132
133         int process_realtime(int64_t size,
134                 Samples *input_ptr,
135                 Samples *output_ptr);
136         int process_realtime(int64_t size,
137                 Samples **input_ptr,
138                 Samples **output_ptr);
139 // Update output pointers as well
140         int is_realtime();
141         int is_multichannel();
142         int is_synthesis();
143         int uses_gui();
144         char* to_string(char *string, const char *input);
145         void save_data(KeyFrame *keyframe);
146         void read_data(KeyFrame *keyframe);
147         void reset_lv2();
148         int load_lv2(const char *path);
149         int init_lv2();
150         int open_lv2_gui(PluginLV2ClientWindow *gui);
151         void update_gui();
152         void update_lv2();
153         void lv2_update();
154         void lv2_update(float *vals);
155         void lv2_set(int idx, float val);
156
157         PLUGIN_CLASS_MEMBERS(PluginLV2ClientConfig)
158         char title[BCSTRLEN];
159         int bfrsz, nb_in_bfrs, nb_out_bfrs;
160         float **in_buffers, **out_buffers;
161
162         void delete_buffers();
163         void init_plugin(int size);
164         void connect_ports();
165         static LV2_URID uri_table_map(LV2_URID_Map_Handle handle, const char *uri);
166         static const char *uri_table_unmap(LV2_URID_Map_Handle handle, LV2_URID urid);
167
168 // lv2
169         LilvWorld         *world;
170         const LilvPlugin  *lilv;
171         int nb_inputs, nb_outputs;
172         int max_bufsz;
173
174         PluginLV2UriTable  uri_table;
175         LV2_URID_Map       map;
176         LV2_Feature        map_feature;
177         LV2_URID_Unmap     unmap;
178         LV2_Feature        unmap_feature;
179         Lv2Features        features;
180         LV2_Atom_Sequence  seq_in[2];
181         LV2_Atom_Sequence  *seq_out;
182
183         LilvInstance *instance;
184         LilvNode *atom_AtomPort;
185         LilvNode *atom_Sequence;
186         LilvNode *lv2_AudioPort;
187         LilvNode *lv2_CVPort;
188         LilvNode *lv2_ControlPort;
189         LilvNode *lv2_Optional;
190         LilvNode *lv2_InputPort;
191         LilvNode *lv2_OutputPort;
192         LilvNode *powerOf2BlockLength;
193         LilvNode *fixedBlockLength;
194         LilvNode *boundedBlockLength;
195
196         PluginLV2ParentGUI *parent_gui;
197 };
198
199 #endif