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)
33struct 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
63struct 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
118 const char *value_id;
119 const char *value_label;
120};
121
141struct ParamReg {
143 float *(*registerFloatVar)(
144 const char* id, const char* name, const char* tp,
145 const char* tooltip, float* var, float val,
146 float low, float up, float step, const value_pair* values);
147 int *(*registerIntVar)(
148 const char* id, const char* name, const char* tp,
149 const char* tooltip, int* var, int val,
150 int low, int up, const value_pair* values);
151 bool *(*registerBoolVar)(
152 const char* id, const char* name, const char* tp,
153 const char* tooltip, bool* var, bool val);
154};
155
156/*
157** structure for plugin definition
158*/
159
160typedef void (*inifunc)(unsigned int samplingFreq, PluginDef *plugin);
161typedef int (*activatefunc)(bool start, PluginDef *plugin);
162typedef void (*clearstatefunc)(PluginDef *plugin);
163// in-place would be a tad more efficient but some plugins have to be cleaned up before
164//typedef void (*process_mono_audio) (int count, float *buffer, PluginDef *plugin);
165//typedef void (*process_stereo_audio) (int count, float *buffer1, float *buffer2, PluginDef *plugin);
166typedef void (*process_mono_audio) (int count, float *input, float *output, PluginDef *plugin);
167typedef void (*process_stereo_audio) (int count, float *input1, float *input2,
168 float *output1, float *output2, PluginDef *plugin);
169typedef int (*registerfunc)(const ParamReg& reg);
170typedef int (*uiloader)(const UiBuilder& builder, int format);
171typedef void (*deletefunc)(PluginDef *plugin);
172
173enum {
174 PGN_STEREO = 0x0001, // stereo plugin (auto set when stereo_audio)
175 PGN_PRE = 0x0002, // (mono) always "pre" position
176 PGN_POST = 0x0004, // (mono) always "post" position
177 PGN_GUI = 0x0008, // register variables for gui (auto set when load_ui)
178 PGN_POST_PRE = 0x0010, // (mono) register post/pre variable (auto set when
179 // gui and not always pre or post)
180 PGN_ALTERNATIVE = 0x0020, // plugin is part of a group of modules
181 // managed by a ModuleSelector
182 PGN_SNOOP = 0x0040, // does not alter audio stream
183 PGN_MODE_NORMAL = 0x0100, // plugin is active in normal mode (default)
184 PGN_MODE_BYPASS = 0x0200, // plugin is active in bypass mode
185 PGN_MODE_MUTE = 0x0400, // plugin is active in mute mode
186 PGN_FIXED_GUI = 0x0800, // user cannot hide plugin GUI
188 // For additional flags see struct Plugin
189};
190
191#define PLUGINDEF_VERMAJOR_MASK 0xff00
192#define PLUGINDEF_VERMINOR_MASK 0x00ff
193#define PLUGINDEF_VERSION 0x0700
194
195struct PluginDef {
196 int version; // = PLUGINDEF_VERSION
197 int flags; // PGN_xx flags
198
199 const char* id; // must be unique
200 const char* name; // displayed name (not translated) (may be 0)
201 const char** groups; // list of alternating group_id, group_name (not translated)
202 // may be 0 (else end with 0 entry)
203 const char* description; // description (tooltip)
204 const char* category;
205 const char* shortname;
206
207 // maximal one of mono_audio, stereo_audio must be set
208 // all function pointers in PluginDef can be independently set to 0
209 process_mono_audio mono_audio; // function for mono audio processing
210 process_stereo_audio stereo_audio; //function for stereo audio processing
211
212 inifunc set_samplerate; // called before audio processing and when rate changes
213 activatefunc activate_plugin; // called when taking in / out of pressing chain
214 registerfunc register_params; // called once after module loading (register parameter ids)
215 uiloader load_ui; // called once after module loading (define user interface)
216 clearstatefunc clear_state; // clear internal audio state; may be called
217 // before calling the process function
218 deletefunc delete_instance; // delete this plugin instance
219};
220
221// shared libraries with plugin modules must define
222// a function "get_gx_plugin" of type plugin_inifunc
223// return != 0 for error
224extern "C" typedef int (*plugin_inifunc)(unsigned int idx, PluginDef **p);
225
226#endif /* !_GX_PLUGIN_H */
void(* process_stereo_audio)(int count, float *input1, float *input2, float *output1, float *output2, PluginDef *plugin)
Definition: gx_plugin.h:167
int(* plugin_inifunc)(unsigned int idx, PluginDef **p)
Definition: gx_plugin.h:224
void(* inifunc)(unsigned int samplingFreq, PluginDef *plugin)
Definition: gx_plugin.h:160
int(* registerfunc)(const ParamReg &reg)
Definition: gx_plugin.h:169
int(* activatefunc)(bool start, PluginDef *plugin)
Definition: gx_plugin.h:161
void(* process_mono_audio)(int count, float *input, float *output, PluginDef *plugin)
Definition: gx_plugin.h:166
int(* uiloader)(const UiBuilder &builder, int format)
Definition: gx_plugin.h:170
void(* deletefunc)(PluginDef *plugin)
Definition: gx_plugin.h:171
@ PGN_PRE
Definition: gx_plugin.h:175
@ PGN_MODE_BYPASS
Definition: gx_plugin.h:184
@ PGN_GUI
Definition: gx_plugin.h:177
@ PGN_FIXED_GUI
Definition: gx_plugin.h:186
@ PGN_MODE_NORMAL
Definition: gx_plugin.h:183
@ PGN_POST_PRE
Definition: gx_plugin.h:178
@ PGN_MODE_MUTE
Definition: gx_plugin.h:185
@ PGN_SNOOP
Definition: gx_plugin.h:182
@ PGN_POST
Definition: gx_plugin.h:176
@ PGN_NO_PRESETS
Definition: gx_plugin.h:187
@ PGN_STEREO
Definition: gx_plugin.h:174
@ PGN_ALTERNATIVE
Definition: gx_plugin.h:180
void(* clearstatefunc)(PluginDef *plugin)
Definition: gx_plugin.h:162
Parameter registration function pointers.
Definition: gx_plugin.h:141
PluginDef * plugin
Definition: gx_plugin.h:142
const char ** groups
Definition: gx_plugin.h:201
inifunc set_samplerate
Definition: gx_plugin.h:212
registerfunc register_params
Definition: gx_plugin.h:214
const char * name
Definition: gx_plugin.h:200
int flags
Definition: gx_plugin.h:197
const char * shortname
Definition: gx_plugin.h:205
const char * description
Definition: gx_plugin.h:203
clearstatefunc clear_state
Definition: gx_plugin.h:216
uiloader load_ui
Definition: gx_plugin.h:215
process_mono_audio mono_audio
Definition: gx_plugin.h:209
process_stereo_audio stereo_audio
Definition: gx_plugin.h:210
activatefunc activate_plugin
Definition: gx_plugin.h:213
const char * id
Definition: gx_plugin.h:199
deletefunc delete_instance
Definition: gx_plugin.h:218
const char * category
Definition: gx_plugin.h:204
int version
Definition: gx_plugin.h:196
void(* set_next_flags)(int flags)
Definition: gx_plugin.h:79
void(* openpaintampBox)(const char *label)
Definition: gx_plugin.h:76
void(* closeBox)()
Definition: gx_plugin.h:77
void(* create_mid_rackknob)(const char *id, const char *label)
Definition: gx_plugin.h:103
void(* create_port_display)(const char *id, const char *label)
Definition: gx_plugin.h:92
void(* create_small_rackknobr)(const char *id, const char *label)
Definition: gx_plugin.h:98
void(* openFrameBox)(const char *label)
Definition: gx_plugin.h:74
void(* create_feedback_slider)(const char *id, const char *label)
Definition: gx_plugin.h:85
void(* openVerticalBox)(const char *label)
Definition: gx_plugin.h:68
void(* create_simple_meter)(const char *id)
Definition: gx_plugin.h:96
void(* create_fload_switch)(const char *sw_type, const char *id, const char *idf)
Definition: gx_plugin.h:102
void(* load_glade_file)(const char *fname)
Definition: gx_plugin.h:66
void(* openHorizontalhideBox)(const char *label)
Definition: gx_plugin.h:72
void(* create_spin_value)(const char *id, const char *label)
Definition: gx_plugin.h:91
void(* openHorizontalBox)(const char *label)
Definition: gx_plugin.h:71
void(* create_p_display)(const char *id, const char *idl, const char *idh)
Definition: gx_plugin.h:93
void(* insertSpacer)()
Definition: gx_plugin.h:78
void(* openTabBox)(const char *label)
Definition: gx_plugin.h:67
void(* create_simple_spin_value)(const char *id)
Definition: gx_plugin.h:100
void(* create_wheel)(const char *id, const char *label)
Definition: gx_plugin.h:99
void(* openVerticalBox2)(const char *label)
Definition: gx_plugin.h:70
void(* openFlipLabelBox)(const char *label)
Definition: gx_plugin.h:75
void(* openVerticalBox1)(const char *label)
Definition: gx_plugin.h:69
void(* create_big_rackknob)(const char *id, const char *label)
Definition: gx_plugin.h:87
void(* create_simple_c_meter)(const char *id, const char *idl, const char *label)
Definition: gx_plugin.h:97
void(* create_switch_no_caption)(const char *sw_type, const char *id)
Definition: gx_plugin.h:89
PluginDef * plugin
Definition: gx_plugin.h:64
void(* create_eq_rackslider_no_caption)(const char *id)
Definition: gx_plugin.h:101
void(* create_switch)(const char *sw_type, const char *id, const char *label)
Definition: gx_plugin.h:94
void(* create_master_slider)(const char *id, const char *label)
Definition: gx_plugin.h:84
void(* openHorizontalTableBox)(const char *label)
Definition: gx_plugin.h:73
void(* create_feedback_switch)(const char *sw_type, const char *id)
Definition: gx_plugin.h:90
void(* create_small_rackknob)(const char *id, const char *label)
Definition: gx_plugin.h:86
void(* create_selector_no_caption)(const char *id)
Definition: gx_plugin.h:88
void(* load_glade)(const char *data)
Definition: gx_plugin.h:65
void(* create_selector)(const char *id, const char *label)
Definition: gx_plugin.h:95
const char * value_label
Definition: gx_plugin.h:119
const char * value_id
Definition: gx_plugin.h:118