Beast - Music Synthesizer and Composer  0.11.1+10.g2da35
sfiparams.hh
Go to the documentation of this file.
1  // Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
2 #ifndef __SFI_PARAMS_H__
3 #define __SFI_PARAMS_H__
4 
5 #include <sfi/sfivalues.hh>
6 #include <sfi/sfiprimitives.hh>
7 
8 
9 /* --- Sfi param spec macros --- */
10 #define SFI_TYPE_PARAM_BOOL (G_TYPE_PARAM_BOOLEAN)
11 #define SFI_IS_PSPEC_BOOL(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), SFI_TYPE_PARAM_BOOL))
12 #define SFI_PSPEC_BOOL(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), SFI_TYPE_PARAM_BOOL, SfiParamSpecBool))
13 #define SFI_TYPE_PARAM_INT (G_TYPE_PARAM_INT)
14 #define SFI_IS_PSPEC_INT(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), SFI_TYPE_PARAM_INT))
15 #define SFI_PSPEC_INT(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), SFI_TYPE_PARAM_INT, SfiParamSpecInt))
16 #define SFI_TYPE_PARAM_NUM (G_TYPE_PARAM_INT64)
17 #define SFI_IS_PSPEC_NUM(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), SFI_TYPE_PARAM_NUM))
18 #define SFI_PSPEC_NUM(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), SFI_TYPE_PARAM_NUM, SfiParamSpecNum))
19 #define SFI_TYPE_PARAM_REAL (G_TYPE_PARAM_DOUBLE)
20 #define SFI_IS_PSPEC_REAL(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), SFI_TYPE_PARAM_REAL))
21 #define SFI_PSPEC_REAL(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), SFI_TYPE_PARAM_REAL, SfiParamSpecReal))
22 #define SFI_TYPE_PARAM_STRING (G_TYPE_PARAM_STRING)
23 #define SFI_IS_PSPEC_STRING(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), SFI_TYPE_PARAM_STRING))
24 #define SFI_PSPEC_STRING(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), SFI_TYPE_PARAM_STRING, SfiParamSpecString))
25 #define SFI_TYPE_PARAM_CHOICE (sfi__param_spec_types[0])
26 #define SFI_IS_PSPEC_CHOICE(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), SFI_TYPE_PARAM_CHOICE))
27 #define SFI_PSPEC_CHOICE(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), SFI_TYPE_PARAM_CHOICE, SfiParamSpecChoice))
28 #define SFI_TYPE_PARAM_BBLOCK (sfi__param_spec_types[1])
29 #define SFI_IS_PSPEC_BBLOCK(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), SFI_TYPE_PARAM_BBLOCK))
30 #define SFI_PSPEC_BBLOCK(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), SFI_TYPE_PARAM_BBLOCK, SfiParamSpecBBlock))
31 #define SFI_TYPE_PARAM_FBLOCK (sfi__param_spec_types[2])
32 #define SFI_IS_PSPEC_FBLOCK(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), SFI_TYPE_PARAM_FBLOCK))
33 #define SFI_PSPEC_FBLOCK(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), SFI_TYPE_PARAM_FBLOCK, SfiParamSpecFBlock))
34 #define SFI_TYPE_PARAM_PSPEC (G_TYPE_PARAM_PARAM)
35 #define SFI_IS_PSPEC_PSPEC(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), SFI_TYPE_PARAM_PSPEC))
36 #define SFI_PSPEC_PSPEC(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), SFI_TYPE_PARAM_PSPEC, SfiParamSpecPSpec))
37 #define SFI_TYPE_PARAM_SEQ (sfi__param_spec_types[3])
38 #define SFI_IS_PSPEC_SEQ(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), SFI_TYPE_PARAM_SEQ))
39 #define SFI_PSPEC_SEQ(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), SFI_TYPE_PARAM_SEQ, SfiParamSpecSeq))
40 #define SFI_TYPE_PARAM_REC (sfi__param_spec_types[4])
41 #define SFI_IS_PSPEC_REC(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), SFI_TYPE_PARAM_REC))
42 #define SFI_PSPEC_REC(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), SFI_TYPE_PARAM_REC, SfiParamSpecRec))
43 #define SFI_TYPE_PARAM_PROXY (sfi__param_spec_types[5])
44 #define SFI_IS_PSPEC_PROXY(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), SFI_TYPE_PARAM_PROXY))
45 #define SFI_PSPEC_PROXY(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), SFI_TYPE_PARAM_PROXY, SfiParamSpecProxy))
46 #define SFI_TYPE_PARAM_NOTE (sfi__param_spec_types[6])
47 #define SFI_IS_PSPEC_NOTE(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), SFI_TYPE_PARAM_NOTE))
48 #define SFI_PSPEC_NOTE(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), SFI_TYPE_PARAM_NOTE, SfiParamSpecNote))
49 
50 
51 /* --- Sfi param spec aliases --- */
52 typedef GParamSpecBoolean SfiParamSpecBool;
53 typedef GParamSpecInt SfiParamSpecInt;
54 typedef GParamSpecInt64 SfiParamSpecNum;
55 typedef GParamSpecDouble SfiParamSpecReal;
56 typedef GParamSpecString SfiParamSpecString;
57 typedef GParamSpecParam SfiParamSpecPSpec;
58 
59 
60 /* --- Sfi param specs --- */
61 struct SfiChoiceValue { // auxillary
62  const gchar *choice_ident;
63  const gchar *choice_label;
64  const gchar *choice_blurb;
65  SfiChoiceValue (const char *ident = NULL, const char *label = NULL, const char *blurb = NULL) :
66  choice_ident (ident), choice_label (label), choice_blurb (blurb)
67  {}
68 };
69 struct SfiChoiceValues { // auxillary
70  guint n_values;
71  const SfiChoiceValue *values;
72  SfiChoiceValues (uint nv = 0, const SfiChoiceValue *vl = NULL) :
73  n_values (nv), values (vl)
74  {}
75 };
76 typedef struct {
77  GParamSpecString pspec;
78  SfiChoiceValues cvalues;
80 typedef struct {
81  GParamSpecBoxed pspec;
83 typedef struct {
84  GParamSpecBoxed pspec;
86 typedef struct {
87  GParamSpecBoxed pspec;
88  GParamSpec *element;
90 typedef struct {
91  GParamSpecBoxed pspec;
92  SfiRecFields fields;
94 typedef struct {
95  GParamSpecPointer pspec;
97 typedef struct {
98  GParamSpecInt pspec;
99  gboolean allow_void;
101 
102 
103 /* --- Sfi GParamSpec constructors --- */
104 GParamSpec* sfi_pspec_bool (const gchar *name,
105  const gchar *nick,
106  const gchar *blurb,
107  SfiBool default_value,
108  const gchar *hints);
109 GParamSpec* sfi_pspec_int (const gchar *name,
110  const gchar *nick,
111  const gchar *blurb,
112  SfiInt default_value,
113  SfiInt minimum_value,
114  SfiInt maximum_value,
115  SfiInt stepping,
116  const gchar *hints);
117 GParamSpec* sfi_pspec_num (const gchar *name,
118  const gchar *nick,
119  const gchar *blurb,
120  SfiNum default_value,
121  SfiNum minimum_value,
122  SfiNum maximum_value,
123  SfiNum stepping,
124  const gchar *hints);
125 GParamSpec* sfi_pspec_real (const gchar *name,
126  const gchar *nick,
127  const gchar *blurb,
128  SfiReal default_value,
129  SfiReal minimum_value,
130  SfiReal maximum_value,
131  SfiReal stepping,
132  const gchar *hints);
133 GParamSpec* sfi_pspec_log_scale (const gchar *name,
134  const gchar *nick,
135  const gchar *blurb,
136  SfiReal default_value,
137  SfiReal minimum_value,
138  SfiReal maximum_value,
139  SfiReal stepping,
140  SfiReal center,
141  SfiReal base,
142  SfiReal n_steps,
143  const gchar *hints);
144 GParamSpec* sfi_pspec_string (const gchar *name,
145  const gchar *nick,
146  const gchar *blurb,
147  const gchar *default_value,
148  const gchar *hints);
149 GParamSpec* sfi_pspec_choice (const gchar *name,
150  const gchar *nick,
151  const gchar *blurb,
152  const gchar *default_value,
153  SfiChoiceValues static_const_evalues,
154  const gchar *hints);
155 GParamSpec* sfi_pspec_bblock (const gchar *name,
156  const gchar *nick,
157  const gchar *blurb,
158  const gchar *hints);
159 GParamSpec* sfi_pspec_fblock (const gchar *name,
160  const gchar *nick,
161  const gchar *blurb,
162  const gchar *hints);
163 GParamSpec* sfi_pspec_pspec (const gchar *name,
164  const gchar *nick,
165  const gchar *blurb,
166  const gchar *hints);
167 GParamSpec* sfi_pspec_seq (const gchar *name,
168  const gchar *nick,
169  const gchar *blurb,
170  GParamSpec *element_spec,
171  const gchar *hints);
172 GParamSpec* sfi_pspec_rec (const gchar *name,
173  const gchar *nick,
174  const gchar *blurb,
175  SfiRecFields static_const_fields,
176  const gchar *hints);
177 GParamSpec* sfi_pspec_rec_generic (const gchar *name,
178  const gchar *nick,
179  const gchar *blurb,
180  const gchar *hints);
181 GParamSpec* sfi_pspec_proxy (const gchar *name,
182  const gchar *nick,
183  const gchar *blurb,
184  const gchar *hints);
185 
186 
187 /* --- pspec wrappers --- */
188 #define sfi_pspec_ref g_param_spec_ref
189 #define sfi_pspec_unref g_param_spec_unref
190 #define sfi_pspec_sink g_param_spec_sink
191 #define sfi_pspec_get_qdata g_param_spec_get_qdata
192 #define sfi_pspec_set_qdata g_param_spec_set_qdata
193 #define sfi_pspec_set_qdata_full g_param_spec_set_qdata_full
194 #define sfi_pspec_steal_qdata g_param_spec_steal_qdata
195 #define sfi_pspec_get_name g_param_spec_get_name
196 #define sfi_pspec_get_nick g_param_spec_get_nick
197 #define sfi_pspec_get_blurb g_param_spec_get_blurb
198 
199 
200 /* --- conversion --- */
201 typedef SfiChoiceValues (*SfiChoiceValueGetter) (GType enum_type);
202 GParamSpec* sfi_pspec_to_serializable (GParamSpec *pspec);
203 GParamSpec* sfi_pspec_choice_from_enum (GParamSpec *enum_pspec);
204 GParamSpec* sfi_pspec_proxy_from_object (GParamSpec *object_pspec);
205 void sfi_enum_type_set_choice_value_getter (GType gtype,
206  SfiChoiceValueGetter cvgetter);
207 void sfi_boxed_type_set_rec_fields (GType boxed_type,
208  const SfiRecFields static_const_fields);
209 SfiRecFields sfi_boxed_type_get_rec_fields (GType boxed_type);
210 void sfi_boxed_type_set_seq_element (GType boxed_type,
211  GParamSpec *element);
212 GParamSpec* sfi_boxed_type_get_seq_element (GType boxed_type);
213 
214 
215 /* --- Sfi PSpec Options --- */
216 /* provide common option combinations: */
217 #define SFI_PARAM_READWRITE ":r:w:"
218 #define SFI_PARAM_STORAGE ":r:w:S:"
219 #define SFI_PARAM_STANDARD ":r:w:S:G:"
220 #define SFI_PARAM_STANDARD_RDONLY ":r:w:S:G:ro:"
221 #define SFI_PARAM_GUI ":r:w:G:"
222 #define SFI_PARAM_GUI_RDONLY ":r:w:G:ro:"
223 #define SFI_PARAM_GUI_READABLE ":r:G:"
224 
225 
226 /* --- serializable categories --- */
227 typedef enum /*< skip >*/
228 {
229  SFI_SCAT_INVAL = 0,
230  SFI_SCAT_BOOL = 'b',
231  SFI_SCAT_INT = 'i',
232  SFI_SCAT_NUM = 'n',
233  SFI_SCAT_REAL = 'r',
234  SFI_SCAT_STRING = 's',
235  SFI_SCAT_CHOICE = 'C',
236  SFI_SCAT_BBLOCK = 'B',
237  SFI_SCAT_FBLOCK = 'F',
238  SFI_SCAT_PSPEC = 'P',
239  SFI_SCAT_SEQ = 'Q',
240  SFI_SCAT_REC = 'R',
241  SFI_SCAT_PROXY = 'p',
242  SFI_SCAT_TYPE_MASK = 0x00ff,
243  SFI_SCAT_NOTE = 0x0100 | SFI_SCAT_INT,
244  SFI_SCAT_TIME = 0x0200 | SFI_SCAT_NUM,
245 } SfiSCategory;
246 
247 SfiSCategory sfi_categorize_type (GType value_type);
248 SfiSCategory sfi_categorize_pspec (GParamSpec *pspec);
249 GType sfi_category_type (SfiSCategory pspec_cat);
250 GType sfi_category_param_type (SfiSCategory pspec_cat);
251 
252 
253 /* --- convenience aliases --- */
254 GParamSpec* sfi_pspec_note (const gchar *name,
255  const gchar *nick,
256  const gchar *blurb,
257  SfiInt default_value,
258  SfiInt min_note,
259  SfiInt max_note,
260  gboolean allow_void,
261  const gchar *hints);
262 #define SFI_IS_PSPEC_TIME SFI_IS_PSPEC_TIME
263 GParamSpec* sfi_pspec_time (const gchar *name,
264  const gchar *nick,
265  const gchar *blurb,
266  const gchar *hints);
267 
268 
269 /* --- pspec accessors --- */
270 GParamSpec* sfi_pspec_set_group (GParamSpec *pspec,
271  const gchar *group);
272 const gchar* sfi_pspec_get_group (GParamSpec *pspec);
273 void sfi_pspec_set_owner (GParamSpec *pspec,
274  const gchar *owner);
275 const gchar* sfi_pspec_get_owner (GParamSpec *pspec);
276 #define sfi_pspec_set_options(pspec, opts) g_param_spec_set_options (pspec, opts)
277 #define sfi_pspec_add_option(pspec, opt, val) g_param_spec_add_option (pspec, opt, val)
278 #define sfi_pspec_check_option(pspec, opt) g_param_spec_check_option (pspec, opt)
279 #define sfi_pspec_provides_options(pspec, opts) g_param_spec_provides_options (pspec, opts)
280 #define sfi_pspec_get_options(pspec) g_param_spec_get_options (pspec)
281 SfiBool sfi_pspec_get_bool_default (GParamSpec *pspec);
282 SfiInt sfi_pspec_get_int_default (GParamSpec *pspec);
283 void sfi_pspec_get_int_range (GParamSpec *pspec,
284  SfiInt *minimum_value,
285  SfiInt *maximum_value,
286  SfiInt *stepping);
287 gboolean sfi_pspec_allows_void_note (GParamSpec *pspec);
288 #define sfi_pspec_get_note_default sfi_pspec_get_int_default
289 #define sfi_pspec_get_note_range sfi_pspec_get_int_range
290 SfiNum sfi_pspec_get_num_default (GParamSpec *pspec);
291 void sfi_pspec_get_num_range (GParamSpec *pspec,
292  SfiNum *minimum_value,
293  SfiNum *maximum_value,
294  SfiNum *stepping);
295 SfiReal sfi_pspec_get_real_default (GParamSpec *pspec);
296 void sfi_pspec_get_real_range (GParamSpec *pspec,
297  SfiReal *minimum_value,
298  SfiReal *maximum_value,
299  SfiReal *stepping);
300 #define sfi_pspec_set_log_scale(p, c, b, n) g_param_spec_set_log_scale (p, c, b, n)
301 #define sfi_pspec_get_log_scale(p, c, b, n) g_param_spec_get_log_scale (p, c, b, n)
302 const gchar* sfi_pspec_get_string_default (GParamSpec *pspec);
303 const gchar* sfi_pspec_get_choice_default (GParamSpec *pspec);
304 SfiChoiceValues sfi_pspec_get_choice_values (GParamSpec *pspec);
305 guint64 sfi_pspec_get_choice_hash (GParamSpec *pspec);
306 GParamSpec* sfi_pspec_get_seq_element (GParamSpec *pspec);
307 SfiRecFields sfi_pspec_get_rec_fields (GParamSpec *pspec);
308 GParamSpec* sfi_pspec_get_rec_field (GParamSpec *pspec,
309  const gchar *field_name);
310 
311 
312 /* --- internal --- */
313 void _sfi_init_params (void);
314 extern GType* sfi__param_spec_types;
315 SfiRec* sfi_pspec_to_rec (GParamSpec *pspec);
316 GParamSpec* sfi_pspec_from_rec (SfiRec *prec);
317 
318 namespace Bse { // bsecore
319 
320 SfiChoiceValues choice_values_from_enum_values (const String &enumname, const ::Rapicorn::Aida::EnumValueVector &evvec);
321 template<class EnumType> SfiChoiceValues
322 choice_values_from_enum ()
323 {
324  ::Rapicorn::Aida::EnumInfo einfo = ::Rapicorn::Aida::enum_info<EnumType>();
325  return choice_values_from_enum_values (einfo.name(), einfo.value_vector());
326 }
327 
328 } // Bse
329 
330 
331 #endif /* __SFI_PARAMS_H__ */
332 
333 /* vim:set ts=8 sts=2 sw=2: */
The Bse namespace contains all functions of the synthesis engine.
Definition: bstbseutils.cc:91
STL class.
Definition: sfiparams.hh:61
Definition: sfiparams.hh:97
Pointer sized integer object handle.
Definition: sfitypes.hh:29
Definition: sfiparams.hh:69
Definition: sfiparams.hh:86
Definition: sfiparams.hh:76
Definition: sfiparams.hh:90
Definition: sfiparams.hh:80
Definition: sfiparams.hh:83
Definition: sfiparams.hh:94