1 /* FluidSynth - A Software Synthesizer
2  *
3  * Copyright (C) 2003  Peter Hanappe and others.
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public License
7  * as published by the Free Software Foundation; either version 2.1 of
8  * the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free
17  * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18  * 02110-1301, USA
19  */
20 
21 #ifndef _FLUIDSYNTH_SETTINGS_H
22 #define _FLUIDSYNTH_SETTINGS_H
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 /**
29  * @defgroup settings Settings
30  *
31  * Functions for settings management
32  *
33  * To create a synthesizer object you will have to specify its
34  * settings. These settings are stored in a fluid_settings_t object.
35  * @code
36  *     void
37  *     my_synthesizer ()
38  *     {
39  *       fluid_settings_t *settings;
40  *       fluid_synth_t *synth;
41  *       fluid_audio_driver_t *adriver;
42  *
43  *       settings = new_fluid_settings ();
44  *       fluid_settings_setstr(settings, "audio.driver", "alsa");
45  *       // ... change settings ...
46  *       synth = new_fluid_synth (settings);
47  *       adriver = new_fluid_audio_driver (settings, synth);
48  *       // ...
49  *     }
50  * @endcode
51  * @sa @ref CreatingSettings
52  *
53  * @{
54  */
55 
56 /**
57  * Hint FLUID_HINT_BOUNDED_BELOW indicates that the LowerBound field
58  * of the FLUID_PortRangeHint should be considered meaningful. The
59  * value in this field should be considered the (inclusive) lower
60  * bound of the valid range. If FLUID_HINT_SAMPLE_RATE is also
61  * specified then the value of LowerBound should be multiplied by the
62  * sample rate.
63  */
64 #define FLUID_HINT_BOUNDED_BELOW   0x1
65 
66 /** Hint FLUID_HINT_BOUNDED_ABOVE indicates that the UpperBound field
67    of the FLUID_PortRangeHint should be considered meaningful. The
68    value in this field should be considered the (inclusive) upper
69    bound of the valid range. If FLUID_HINT_SAMPLE_RATE is also
70    specified then the value of UpperBound should be multiplied by the
71    sample rate. */
72 #define FLUID_HINT_BOUNDED_ABOVE   0x2
73 
74 /**
75  * Hint FLUID_HINT_TOGGLED indicates that the data item should be
76  * considered a Boolean toggle. Data less than or equal to zero should
77  * be considered `off' or `false,' and data above zero should be
78  * considered `on' or `true.' FLUID_HINT_TOGGLED may not be used in
79  * conjunction with any other hint.
80  */
81 #define FLUID_HINT_TOGGLED         0x4
82 
83 #define FLUID_HINT_OPTIONLIST      0x02         /**< Setting is a list of string options */
84 
85 
86 /**
87  * Settings type
88  *
89  * Each setting has a defined type: numeric (double), integer, string or a
90  * set of values. The type of each setting can be retrieved using the
91  * function fluid_settings_get_type()
92  */
93 enum fluid_types_enum
94 {
95     FLUID_NO_TYPE = -1, /**< Undefined type */
96     FLUID_NUM_TYPE,     /**< Numeric (double) */
97     FLUID_INT_TYPE,     /**< Integer */
98     FLUID_STR_TYPE,     /**< String */
99     FLUID_SET_TYPE      /**< Set of values */
100 };
101 
102 /** @startlifecycle{Settings} */
103 FLUIDSYNTH_API fluid_settings_t *new_fluid_settings(void);
104 FLUIDSYNTH_API void delete_fluid_settings(fluid_settings_t *settings);
105 /** @endlifecycle */
106 
107 FLUIDSYNTH_API
108 int fluid_settings_get_type(fluid_settings_t *settings, const char *name);
109 
110 FLUIDSYNTH_API
111 int fluid_settings_get_hints(fluid_settings_t *settings, const char *name, int *val);
112 
113 FLUIDSYNTH_API
114 int fluid_settings_is_realtime(fluid_settings_t *settings, const char *name);
115 
116 FLUIDSYNTH_API
117 int fluid_settings_setstr(fluid_settings_t *settings, const char *name, const char *str);
118 
119 FLUIDSYNTH_API
120 int fluid_settings_copystr(fluid_settings_t *settings, const char *name, char *str, int len);
121 
122 FLUIDSYNTH_API
123 int fluid_settings_dupstr(fluid_settings_t *settings, const char *name, char **str);
124 
125 FLUIDSYNTH_API
126 int fluid_settings_getstr_default(fluid_settings_t *settings, const char *name, char **def);
127 
128 FLUIDSYNTH_API
129 int fluid_settings_str_equal(fluid_settings_t *settings, const char *name, const char *value);
130 
131 FLUIDSYNTH_API
132 int fluid_settings_setnum(fluid_settings_t *settings, const char *name, double val);
133 
134 FLUIDSYNTH_API
135 int fluid_settings_getnum(fluid_settings_t *settings, const char *name, double *val);
136 
137 FLUIDSYNTH_API
138 int fluid_settings_getnum_default(fluid_settings_t *settings, const char *name, double *val);
139 
140 FLUIDSYNTH_API
141 int fluid_settings_getnum_range(fluid_settings_t *settings, const char *name,
142                                 double *min, double *max);
143 
144 FLUIDSYNTH_API
145 int fluid_settings_setint(fluid_settings_t *settings, const char *name, int val);
146 
147 FLUIDSYNTH_API
148 int fluid_settings_getint(fluid_settings_t *settings, const char *name, int *val);
149 
150 FLUIDSYNTH_API
151 int fluid_settings_getint_default(fluid_settings_t *settings, const char *name, int *val);
152 
153 FLUIDSYNTH_API
154 int fluid_settings_getint_range(fluid_settings_t *settings, const char *name,
155                                 int *min, int *max);
156 
157 /**
158  * Callback function type used with fluid_settings_foreach_option()
159  *
160  * @param data User defined data pointer
161  * @param name Setting name
162  * @param option A string option for this setting (iterates through the list)
163  */
164 typedef void (*fluid_settings_foreach_option_t)(void *data, const char *name, const char *option);
165 
166 FLUIDSYNTH_API
167 void fluid_settings_foreach_option(fluid_settings_t *settings,
168                                    const char *name, void *data,
169                                    fluid_settings_foreach_option_t func);
170 FLUIDSYNTH_API
171 int fluid_settings_option_count(fluid_settings_t *settings, const char *name);
172 FLUIDSYNTH_API char *fluid_settings_option_concat(fluid_settings_t *settings,
173         const char *name,
174         const char *separator);
175 
176 /**
177  * Callback function type used with fluid_settings_foreach()
178  *
179  * @param data User defined data pointer
180  * @param name Setting name
181  * @param type Setting type (#fluid_types_enum)
182  */
183 typedef void (*fluid_settings_foreach_t)(void *data, const char *name, int type);
184 
185 FLUIDSYNTH_API
186 void fluid_settings_foreach(fluid_settings_t *settings, void *data,
187                             fluid_settings_foreach_t func);
188 /* @} */
189 
190 #ifdef __cplusplus
191 }
192 #endif
193 
194 #endif /* _FLUIDSYNTH_SETTINGS_H */
195