Debian Codegraph @

iOS/Csound iOS Obj-C Examples/csound-iOS/headers/cfgvar.h

raw symbols SCIP
1 /*
2 cfgvar.h:
3
4 Copyright (C) 2005 Istvan Varga
5
6 This file is part of Csound.
7
8 The Csound Library is free software; you can redistribute it
9 and/or modify it under the terms of the GNU Lesser General Public
10 License as published by the Free Software Foundation; either
11 version 2.1 of the License, or (at your option) any later version.
12
13 Csound is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU Lesser General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public
19 License along with Csound; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21 02110-1301 USA
22 */
23
24 #ifndef CSOUND_CFGVAR_H
25 #define CSOUND_CFGVAR_H
26
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30
31 /* generic header structure */
32
33 typedef struct csCfgVariableHead_s {
34 union csCfgVariable_u *nxt; /* pointer to next structure in chain */
35 unsigned char *name; /* name of the variable */
36 void *p; /* pointer to value */
37 int type; /* type (e.g. CSOUNDCFG_INTEGER) */
38 int flags; /* bitwise OR of flags */
39 unsigned char *shortDesc; /* short description (NULL if none) */
40 unsigned char *longDesc; /* long description (NULL if none) */
41 } csCfgVariableHead_t;
42
43 /* int type */
44
45 typedef struct csCfgVariableInt_s {
46 union csCfgVariable_u *nxt; /* pointer to next structure in chain */
47 unsigned char *name; /* name of the variable */
48 int *p; /* pointer to value */
49 int type; /* type (CSOUNDCFG_INTEGER) */
50 int flags; /* bitwise OR of flags */
51 unsigned char *shortDesc; /* short description (NULL if none) */
52 unsigned char *longDesc; /* long description (NULL if none) */
53 int min; /* minimum allowed value */
54 int max; /* maximum allowed value */
55 } csCfgVariableInt_t;
56
57 /* boolean type (int with a value of 0 or 1) */
58
59 typedef struct csCfgVariableBoolean_s {
60 union csCfgVariable_u *nxt; /* pointer to next structure in chain */
61 unsigned char *name; /* name of the variable */
62 int *p; /* pointer to value */
63 int type; /* type (CSOUNDCFG_BOOLEAN) */
64 int flags; /* bitwise OR of flags */
65 unsigned char *shortDesc; /* short description (NULL if none) */
66 unsigned char *longDesc; /* long description (NULL if none) */
67 } csCfgVariableBoolean_t;
68
69 /* float type */
70
71 typedef struct csCfgVariableFloat_s {
72 union csCfgVariable_u *nxt; /* pointer to next structure in chain */
73 unsigned char *name; /* name of the variable */
74 float *p; /* pointer to value */
75 int type; /* type (CSOUNDCFG_FLOAT) */
76 int flags; /* bitwise OR of flags */
77 unsigned char *shortDesc; /* short description (NULL if none) */
78 unsigned char *longDesc; /* long description (NULL if none) */
79 float min; /* minimum allowed value */
80 float max; /* maximum allowed value */
81 } csCfgVariableFloat_t;
82
83 /* double type */
84
85 typedef struct csCfgVariableDouble_s {
86 union csCfgVariable_u *nxt; /* pointer to next structure in chain */
87 unsigned char *name; /* name of the variable */
88 double *p; /* pointer to value */
89 int type; /* type (CSOUNDCFG_DOUBLE) */
90 int flags; /* bitwise OR of flags */
91 unsigned char *shortDesc; /* short description (NULL if none) */
92 unsigned char *longDesc; /* long description (NULL if none) */
93 double min; /* minimum allowed value */
94 double max; /* maximum allowed value */
95 } csCfgVariableDouble_t;
96
97 /* MYFLT (float or double) type */
98
99 typedef struct csCfgVariableMYFLT_s {
100 union csCfgVariable_u *nxt; /* pointer to next structure in chain */
101 unsigned char *name; /* name of the variable */
102 MYFLT *p; /* pointer to value */
103 int type; /* type (CSOUNDCFG_MYFLT) */
104 int flags; /* bitwise OR of flags */
105 unsigned char *shortDesc; /* short description (NULL if none) */
106 unsigned char *longDesc; /* long description (NULL if none) */
107 MYFLT min; /* minimum allowed value */
108 MYFLT max; /* maximum allowed value */
109 } csCfgVariableMYFLT_t;
110
111 /* string type */
112
113 typedef struct csCfgVariableString_s {
114 union csCfgVariable_u *nxt; /* pointer to next structure in chain */
115 unsigned char *name; /* name of the variable */
116 char *p; /* value: array of 'maxlen' chars */
117 int type; /* type (CSOUNDCFG_STRING) */
118 int flags; /* bitwise OR of flags */
119 unsigned char *shortDesc; /* short description (NULL if none) */
120 unsigned char *longDesc; /* long description (NULL if none) */
121 int maxlen; /* maximum length + 1 */
122 } csCfgVariableString_t;
123
124 /* union of all variable types */
125
126 typedef union csCfgVariable_u {
127 csCfgVariableHead_t h;
128 csCfgVariableInt_t i;
129 csCfgVariableBoolean_t b;
130 csCfgVariableFloat_t f;
131 csCfgVariableDouble_t d;
132 csCfgVariableMYFLT_t m;
133 csCfgVariableString_t s;
134 } csCfgVariable_t;
135
136 /* types */
137
138 #define CSOUNDCFG_INTEGER 1
139 #define CSOUNDCFG_BOOLEAN 2
140 #define CSOUNDCFG_FLOAT 3
141 #define CSOUNDCFG_DOUBLE 4
142 #define CSOUNDCFG_MYFLT 5
143 #define CSOUNDCFG_STRING 6
144
145 /* flags */
146
147 #define CSOUNDCFG_POWOFTWO 0x00000001
148
149 /* error codes */
150
151 #define CSOUNDCFG_SUCCESS 0
152 #define CSOUNDCFG_INVALID_NAME -1
153 #define CSOUNDCFG_INVALID_TYPE -2
154 #define CSOUNDCFG_INVALID_FLAG -3
155 #define CSOUNDCFG_NULL_POINTER -4
156 #define CSOUNDCFG_TOO_HIGH -5
157 #define CSOUNDCFG_TOO_LOW -6
158 #define CSOUNDCFG_NOT_POWOFTWO -7
159 #define CSOUNDCFG_INVALID_BOOLEAN -8
160 #define CSOUNDCFG_MEMORY -9
161 #define CSOUNDCFG_STRING_LENGTH -10
162
163 #define CSOUNDCFG_LASTERROR -10
164
165 /* -------- interface functions -------- */
166
167 /* This pragma must come before all public function declarations */
168
169 /**
170 * This function is similar to csoundCreateGlobalConfigurationVariable(),
171 * except it creates a configuration variable specific to Csound instance
172 * 'csound', and is suitable for calling from the Csound library
173 * (in csoundPreCompile()) or plugins (in csoundModuleCreate()).
174 * The other parameters and return value are the same as in the case of
175 * csoundCreateGlobalConfigurationVariable().
176 */
177 PUBLIC int
178 csoundCreateConfigurationVariable(CSOUND *csound, const char *name,
179 void *p, int type, int flags,
180 void *min, void *max,
181 const char *shortDesc,
182 const char *longDesc);
183
184 /**
185 * Set the value of a configuration variable of Csound instance 'csound'.
186 * The 'name' and 'value' parameters, and return value are the same as
187 * in the case of csoundSetGlobalConfigurationVariable().
188 */
189 PUBLIC int csoundSetConfigurationVariable(CSOUND *csound, const char *name,
190 void *value);
191
192 /**
193 * Set the value of a configuration variable of Csound instance 'csound',
194 * by parsing a string.
195 * The 'name' and 'value' parameters, and return value are the same as
196 * in the case of csoundParseGlobalConfigurationVariable().
197 */
198 PUBLIC int csoundParseConfigurationVariable(CSOUND *csound, const char *name,
199 const char *value);
200
201 /**
202 * Return pointer to the configuration variable of Csound instace 'csound'
203 * with the specified name.
204 * The return value may be NULL if the variable is not found in the database.
205 */
206 PUBLIC csCfgVariable_t
207 *csoundQueryConfigurationVariable(CSOUND *csound, const char *name);
208
209 /**
210 * Create an alphabetically sorted list of all configuration variables
211 * of Csound instance 'csound'.
212 * Returns a pointer to a NULL terminated array of configuration variable
213 * pointers, or NULL on error.
214 * The caller is responsible for freeing the returned list with
215 * csoundDeleteCfgVarList(), however, the variable pointers in the list
216 * should not be freed.
217 */
218 PUBLIC csCfgVariable_t **csoundListConfigurationVariables(CSOUND *csound);
219
220 /**
221 * Release a configuration variable list previously returned
222 * by csoundListGlobalConfigurationVariables() or
223 * csoundListConfigurationVariables().
224 */
225 PUBLIC void csoundDeleteCfgVarList(CSOUND* csound, csCfgVariable_t **lst);
226
227 /**
228 * Remove the configuration variable of Csound instance 'csound' with the
229 * specified name from the database. Plugins need not call this, as all
230 * configuration variables are automatically deleted by csoundReset().
231 * Return value is CSOUNDCFG_SUCCESS in case of success, or
232 * CSOUNDCFG_INVALID_NAME if the variable was not found.
233 */
234 PUBLIC int csoundDeleteConfigurationVariable(CSOUND *csound,
235 const char *name);
236 /**
237 * Returns pointer to an error string constant for the specified
238 * CSOUNDCFG error code. The string is not translated.
239 */
240 PUBLIC const char *csoundCfgErrorCodeToString(int errcode);
241
242 /* This pragma must come after all public function declarations */
243
244 #ifdef __cplusplus
245 }
246 #endif
247
248 #endif /* CSOUND_CFGVAR_H */
249