4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
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.
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.
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
22 #ifndef PLUGINLV2CLIENT_H
23 #define PLUGINLV2CLIENT_H
25 #include "bcdisplayinfo.h"
27 #include "pluginaclient.h"
28 #include "pluginlv2client.inc"
29 #include "samples.inc"
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>
35 class PluginLV2UriTable : public ArrayList<const char *>
40 LV2_URID map(const char *uri);
41 const char *unmap(LV2_URID urid);
44 class PluginLV2Client_OptName : public BC_ListBoxItem
47 PluginLV2Client_Opt *opt;
48 PluginLV2Client_OptName(PluginLV2Client_Opt *opt);
51 class PluginLV2Client_OptValue : public BC_ListBoxItem
54 PluginLV2Client_Opt *opt;
55 PluginLV2Client_OptValue(PluginLV2Client_Opt *opt);
59 class PluginLV2Client_Opt
64 PluginLV2ClientConfig *conf;
65 PluginLV2Client_OptName *item_name;
66 PluginLV2Client_OptValue *item_value;
68 void set_value(float v);
70 const char *get_name();
72 PluginLV2Client_Opt(PluginLV2ClientConfig *conf, const char *sym, int idx);
73 ~PluginLV2Client_Opt();
77 class PluginLV2ClientConfig : public ArrayList<PluginLV2Client_Opt *>
80 PluginLV2ClientConfig();
81 ~PluginLV2ClientConfig();
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);
88 void init_lv2(const LilvPlugin *lilv);
93 float *mins, *maxs, *ctls;
96 class PluginLV2Client_OptPanel : public BC_ListBox
99 PluginLV2Client_OptPanel(PluginLV2ClientWindow *gui, int x, int y, int w, int h);
100 ~PluginLV2Client_OptPanel();
102 PluginLV2ClientWindow *gui;
103 ArrayList<BC_ListBoxItem*> items[2];
104 ArrayList<BC_ListBoxItem*> &opts;
105 ArrayList<BC_ListBoxItem*> &vals;
107 int selection_changed();
111 class PluginLV2ClientText : public BC_TextBox {
113 PluginLV2ClientWindow *gui;
115 PluginLV2ClientText(PluginLV2ClientWindow *gui, int x, int y, int w);
116 ~PluginLV2ClientText();
120 class PluginLV2ClientReset : public BC_GenericButton
123 PluginLV2ClientWindow *gui;
125 PluginLV2ClientReset(PluginLV2ClientWindow *gui, int x, int y);
126 ~PluginLV2ClientReset();
130 class PluginLV2ClientApply : public BC_GenericButton {
132 PluginLV2ClientWindow *gui;
134 PluginLV2ClientApply(PluginLV2ClientWindow *gui, int x, int y);
135 ~PluginLV2ClientApply();
139 class PluginLV2ClientPot : public BC_FPot
142 PluginLV2ClientPot(PluginLV2ClientWindow *gui, int x, int y);
144 PluginLV2ClientWindow *gui;
147 class PluginLV2ClientSlider : public BC_FSlider
150 PluginLV2ClientSlider(PluginLV2ClientWindow *gui, int x, int y);
152 PluginLV2ClientWindow *gui;
155 class PluginLV2ClientWindow : public PluginClientWindow
158 PluginLV2ClientWindow(PluginLV2Client *plugin);
159 ~PluginLV2ClientWindow();
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);
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;
180 class PluginLV2Client : public PluginAClient
183 PluginLV2Client(PluginServer *server);
186 int process_realtime(int64_t size,
188 Samples *output_ptr);
189 int process_realtime(int64_t size,
191 Samples **output_ptr);
192 // Update output pointers as well
195 int is_multichannel();
198 char* to_string(char *string, const char *input);
199 void save_data(KeyFrame *keyframe);
200 void read_data(KeyFrame *keyframe);
202 int load_lv2(const char *path);
205 PLUGIN_CLASS_MEMBERS(PluginLV2ClientConfig)
206 char title[BCSTRLEN];
207 int bfrsz, nb_in_bfrs, nb_out_bfrs;
208 float **in_buffers, **out_buffers;
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);
218 const LilvPlugin *lilv;
219 int nb_inputs, nb_outputs;
222 PluginLV2UriTable uri_table;
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;
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;
241 LilvNode *powerOf2BlockLength;
242 LilvNode *fixedBlockLength;
243 LilvNode *boundedBlockLength;