Guitarix
gx_plugin.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2011, 2013 Hermann Meyer, James Warden, Andreas Degert, Pete Shorthose
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  * --------------------------------------------------------------------------
18  *
19  * This file is part of the guitarix GUI main class
20  * Note: this header file depends on gx_system.h
21  *
22  * ----------------------------------------------------------------------------
23  */
24 
25 #pragma once
26 
27 #ifndef _GX_PLUGIN_H
28 #define _GX_PLUGIN_H
29 
30 #include "gx_compiler.h"
31 
32 // forward declarations (need not be resolved for plugin definition)
33 struct PluginDef;
34 
35 /*
36 ** helper class for PluginDef::load_ui
37 */
38 
39 #define UI_NUM_TOP 0x01
40 #define UI_NUM_BOTTOM 0x03
41 #define UI_NUM_LEFT 0x05
42 #define UI_NUM_RIGHT 0x07
43 #define UI_NUM_POSITION_MASK 0x07
44 #define UI_NUM_SHOW_ALWAYS 0x08
45 #define UI_LABEL_INVERSE 0x02
46 
47 // Stock Items for Gxw::Switch
48 
49 #define sw_led "led"
50 #define sw_switch "switch"
51 #define sw_switchit "switchit"
52 #define sw_minitoggle "minitoggle"
53 #define sw_button "button"
54 #define sw_pbutton "pbutton"
55 #define sw_rbutton "rbutton"
56 #define sw_prbutton "prbutton"
57 #define sw_fbutton "fbutton"
58 #define sw_frbutton "frbutton"
59 
60 #define UI_FORM_STACK 0x01
61 #define UI_FORM_GLADE 0x02
62 
63 struct UiBuilder {
65  void (*load_glade)(const char *data);
66  void (*load_glade_file)(const char *fname);
67  void (*openTabBox)(const char* label);
68  void (*openVerticalBox)(const char* label);
69  void (*openVerticalBox1)(const char* label);
70  void (*openVerticalBox2)(const char* label);
71  void (*openHorizontalBox)(const char* label);
72  void (*openHorizontalhideBox)(const char* label);
73  void (*openHorizontalTableBox)(const char *label);
74  void (*openFrameBox)(const char *label);
75  void (*openFlipLabelBox)(const char* label);
76  void (*openpaintampBox)(const char* label);
77  void (*closeBox)();
78  void (*insertSpacer)();
79  void (*set_next_flags)(int flags);
80  // methods creating UI elements connected to parameter_id's.
81  // the check_parameter function in dsp2cc identifies these
82  // functions by the prefix create_ so please stick to this
83  // prefix or change the checker
84  void (*create_master_slider)(const char *id, const char *label);
85  void (*create_feedback_slider)(const char *id, const char *label);
86  void (*create_small_rackknob)(const char *id, const char *label);
87  void (*create_big_rackknob)(const char *id, const char *label);
88  void (*create_selector_no_caption)(const char *id);
89  void (*create_switch_no_caption)(const char *sw_type,const char * id);
90  void (*create_feedback_switch)(const char *sw_type,const char * id);
91  void (*create_spin_value)(const char * id, const char *label);
92  void (*create_port_display)(const char * id, const char *label);
93  void (*create_p_display)(const char * id, const char * idl, const char * idh);
94  void (*create_switch)(const char *sw_type,const char * id, const char *label);
95  void (*create_selector)(const char *id, const char *label);
96  void (*create_simple_meter)(const char *id);
97  void (*create_simple_c_meter)(const char *id, const char *idl, const char *label);
98  void (*create_small_rackknobr)(const char *id, const char *label);
99  void (*create_wheel)(const char *id, const char *label);
100  void (*create_simple_spin_value)(const char *id);
101  void (*create_eq_rackslider_no_caption)(const char *id);
102  void (*create_fload_switch)(const char *sw_type,const char * id,const char * idf);
103  void (*create_mid_rackknob)(const char *id, const char *label);
104  // adding additional functions:
105  // If possible don't change the order of the current defintion.
106  // new functions need to be added at the following places:
107  // StackBoxBuilder: decl, real implementation
108  // UiBuilderImpl: decl, assign to pointer, call real implementation
109  // UiBuilderVirt: decl, assign to pointer, write json
110  // GxMachineRemote::load_remote_ui(): call real implementation
111 };
112 
113 /*
114 ** helper class for PluginDef::registerfunc
115 */
116 
117 struct value_pair {
118  const char *value_id;
119  const char *value_label;
120 };
121 
122 struct ParamReg {
124  float *(*registerVar)(const char* id, const char* name, const char* tp,
125  const char* tooltip, float* var, float val,
126  float low, float up, float step);
127  void (*registerBoolVar)(const char* id, const char* name, const char* tp,
128  const char* tooltip, bool* var, bool val);
129  void (*registerNonMidiVar)(const char * id, bool*var, bool preset, bool nosave);
130  void (*registerNonMidiFloatVar)(const char * id, float *var, bool preset, bool nosave,
131  float val, float low, float up, float step);
132  void (*registerEnumVar)(const char *id, const char* name, const char* tp,
133  const char* tooltip, const value_pair* values, float *var, float val,
134  float low, float up, float step);
135  float *(*registerSharedEnumVar)(const char *id, const char* name, const char* tp,
136  const char* tooltip, const value_pair* values, float *var, float val,
137  float low, float up, float step);
138  void (*registerIEnumVar)(const char *id, const char* name, const char* tp,
139  const char* tooltip, const value_pair* values, int *var, int val);
140  float *(*registerNonMidiSharedVar)(const char * id, float *var, bool preset, bool nosave,
141  float val, float low, float up, float step);
142 };
143 
144 /*
145 ** structure for plugin definition
146 */
147 
148 typedef void (*inifunc)(unsigned int samplingFreq, PluginDef *plugin);
149 typedef int (*activatefunc)(bool start, PluginDef *plugin);
150 typedef void (*clearstatefunc)(PluginDef *plugin);
151 // in-place would be a tad more efficient but some plugins have to be cleaned up before
152 //typedef void (*process_mono_audio) (int count, float *buffer, PluginDef *plugin);
153 //typedef void (*process_stereo_audio) (int count, float *buffer1, float *buffer2, PluginDef *plugin);
154 typedef void (*process_mono_audio) (int count, float *input, float *output, PluginDef *plugin);
155 typedef void (*process_stereo_audio) (int count, float *input1, float *input2,
156  float *output1, float *output2, PluginDef *plugin);
157 typedef int (*registerfunc)(const ParamReg& reg);
158 typedef int (*uiloader)(const UiBuilder& builder, int format);
159 typedef void (*deletefunc)(PluginDef *plugin);
160 
161 enum {
162  PGN_STEREO = 0x0001, // stereo plugin (auto set when stereo_audio)
163  PGN_PRE = 0x0002, // (mono) always "pre" position
164  PGN_POST = 0x0004, // (mono) always "post" position
165  PGN_GUI = 0x0008, // register variables for gui (auto set when load_ui)
166  PGN_POST_PRE = 0x0010, // (mono) register post/pre variable (auto set when
167  // gui and not always pre or post)
168  PGN_ALTERNATIVE = 0x0020, // plugin is part of a group of modules
169  // managed by a ModuleSelector
170  PGN_SNOOP = 0x0040, // does not alter audio stream
171  PGN_MODE_NORMAL = 0x0100, // plugin is active in normal mode (default)
172  PGN_MODE_BYPASS = 0x0200, // plugin is active in bypass mode
173  PGN_MODE_MUTE = 0x0400, // plugin is active in mute mode
174  PGN_FIXED_GUI = 0x0800, // user cannot hide plugin GUI
175  PGN_NO_PRESETS = 0x1000,
176  // For additional flags see struct Plugin
177 };
178 
179 #define PLUGINDEF_VERMAJOR_MASK 0xff00
180 #define PLUGINDEF_VERMINOR_MASK 0x00ff
181 #define PLUGINDEF_VERSION 0x0600
182 
183 struct PluginDef {
184  int version; // = PLUGINDEF_VERSION
185  int flags; // PGN_xx flags
186 
187  const char* id; // must be unique
188  const char* name; // displayed name (not translated) (may be 0)
189  const char** groups; // list of alternating group_id, group_name (not translated)
190  // may be 0 (else end with 0 entry)
191  const char* description; // description (tooltip)
192  const char* category;
193  const char* shortname;
194 
195  // maximal one of mono_audio, stereo_audio must be set
196  // all function pointers in PluginDef can be independently set to 0
197  process_mono_audio mono_audio; // function for mono audio processing
198  process_stereo_audio stereo_audio; //function for stereo audio processing
199 
200  inifunc set_samplerate; // called before audio processing and when rate changes
201  activatefunc activate_plugin; // called when taking in / out of pressing chain
202  registerfunc register_params; // called once after module loading (register parameter ids)
203  uiloader load_ui; // called once after module loading (define user interface)
204  clearstatefunc clear_state; // clear internal audio state; may be called
205  // before calling the process function
206  deletefunc delete_instance; // delete this plugin instance
207 };
208 
209 // shared libraries with plugin modules must define
210 // a function "get_gx_plugin" of type plugin_inifunc
211 // return != 0 for error
212 extern "C" typedef int (*plugin_inifunc)(unsigned int idx, PluginDef **p);
213 
214 #endif /* !_GX_PLUGIN_H */
CmdConnection::msg_type start
Definition: jsonrpc.cpp:257
void(* insertSpacer)()
Definition: gx_plugin.h:78
clearstatefunc clear_state
Definition: gx_plugin.h:204
PluginDef * plugin
Definition: gx_plugin.h:64
void(* create_fload_switch)(const char *sw_type, const char *id, const char *idf)
Definition: gx_plugin.h:102
void(* load_glade)(const char *data)
Definition: gx_plugin.h:65
int(* activatefunc)(bool start, PluginDef *plugin)
Definition: gx_plugin.h:149
int(* uiloader)(const UiBuilder &builder, int format)
Definition: gx_plugin.h:158
void(* openFlipLabelBox)(const char *label)
Definition: gx_plugin.h:75
const char * value_id
Definition: gx_plugin.h:118
PluginDef * plugin
Definition: gx_plugin.h:123
const char * name
Definition: gx_plugin.h:188
void(* inifunc)(unsigned int samplingFreq, PluginDef *plugin)
Definition: gx_plugin.h:148
void(* openTabBox)(const char *label)
Definition: gx_plugin.h:67
void(* create_feedback_switch)(const char *sw_type, const char *id)
Definition: gx_plugin.h:90
void(* create_switch_no_caption)(const char *sw_type, const char *id)
Definition: gx_plugin.h:89
const char * description
Definition: gx_plugin.h:191
void(* create_p_display)(const char *id, const char *idl, const char *idh)
Definition: gx_plugin.h:93
void(* closeBox)()
Definition: gx_plugin.h:77
const char ** groups
Definition: gx_plugin.h:189
void(* load_glade_file)(const char *fname)
Definition: gx_plugin.h:66
const char * shortname
Definition: gx_plugin.h:193
const char * category
Definition: gx_plugin.h:192
void(* process_mono_audio)(int count, float *input, float *output, PluginDef *plugin)
Definition: gx_plugin.h:154
deletefunc delete_instance
Definition: gx_plugin.h:206
void(* create_wheel)(const char *id, const char *label)
Definition: gx_plugin.h:99
void(* create_selector)(const char *id, const char *label)
Definition: gx_plugin.h:95
void(* openHorizontalBox)(const char *label)
Definition: gx_plugin.h:71
registerfunc register_params
Definition: gx_plugin.h:202
const char * id
Definition: gx_plugin.h:187
void(* create_port_display)(const char *id, const char *label)
Definition: gx_plugin.h:92
const char * value_label
Definition: gx_plugin.h:119
void(* openFrameBox)(const char *label)
Definition: gx_plugin.h:74
void(* create_small_rackknobr)(const char *id, const char *label)
Definition: gx_plugin.h:98
void(* create_simple_spin_value)(const char *id)
Definition: gx_plugin.h:100
void(* create_simple_meter)(const char *id)
Definition: gx_plugin.h:96
void(* create_mid_rackknob)(const char *id, const char *label)
Definition: gx_plugin.h:103
int flags
Definition: gx_plugin.h:185
void(* openVerticalBox2)(const char *label)
Definition: gx_plugin.h:70
void(* create_small_rackknob)(const char *id, const char *label)
Definition: gx_plugin.h:86
void(* openpaintampBox)(const char *label)
Definition: gx_plugin.h:76
void(* openHorizontalhideBox)(const char *label)
Definition: gx_plugin.h:72
activatefunc activate_plugin
Definition: gx_plugin.h:201
void(* create_feedback_slider)(const char *id, const char *label)
Definition: gx_plugin.h:85
void(* create_spin_value)(const char *id, const char *label)
Definition: gx_plugin.h:91
process_stereo_audio stereo_audio
Definition: gx_plugin.h:198
int(* registerfunc)(const ParamReg &reg)
Definition: gx_plugin.h:157
void(* create_big_rackknob)(const char *id, const char *label)
Definition: gx_plugin.h:87
void(* openHorizontalTableBox)(const char *label)
Definition: gx_plugin.h:73
void(* set_next_flags)(int flags)
Definition: gx_plugin.h:79
void(* deletefunc)(PluginDef *plugin)
Definition: gx_plugin.h:159
inifunc set_samplerate
Definition: gx_plugin.h:200
process_mono_audio mono_audio
Definition: gx_plugin.h:197
void(* create_simple_c_meter)(const char *id, const char *idl, const char *label)
Definition: gx_plugin.h:97
void(* clearstatefunc)(PluginDef *plugin)
Definition: gx_plugin.h:150
void(* create_eq_rackslider_no_caption)(const char *id)
Definition: gx_plugin.h:101
int version
Definition: gx_plugin.h:184
void(* create_switch)(const char *sw_type, const char *id, const char *label)
Definition: gx_plugin.h:94
uiloader load_ui
Definition: gx_plugin.h:203
void(* openVerticalBox1)(const char *label)
Definition: gx_plugin.h:69
void(* process_stereo_audio)(int count, float *input1, float *input2, float *output1, float *output2, PluginDef *plugin)
Definition: gx_plugin.h:155
void(* create_master_slider)(const char *id, const char *label)
Definition: gx_plugin.h:84
int(* plugin_inifunc)(unsigned int idx, PluginDef **p)
Definition: gx_plugin.h:212
void(* create_selector_no_caption)(const char *id)
Definition: gx_plugin.h:88
void(* openVerticalBox)(const char *label)
Definition: gx_plugin.h:68