1 /* -*- Mode: C ; c-basic-offset: 2 -*- */
2 /*****************************************************************************
4 * Copyright (C) 2006,2007,2008,2009 Nedko Arnaudov <nedko@arnaudov.name>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *****************************************************************************/
21 #ifndef ZYNADD_DYNPARAM_FOREST_MAP_H__3ED30D71_513B_4B84_9A9B_1C9C62EE0A87__INCLUDED
22 #define ZYNADD_DYNPARAM_FOREST_MAP_H__3ED30D71_513B_4B84_9A9B_1C9C62EE0A87__INCLUDED
24 extern const char * g_shape_names
[];
25 extern const char * g_analog_filter_type_names
[];
26 extern const char * g_sv_filter_type_names
[];
27 extern const char * g_filter_type_names
[];
28 extern const char * g_oscillator_base_function_names
[];
29 extern const char * g_oscillator_waveshape_type_names
[];
30 extern const char * g_oscillator_spectrum_adjust_type_names
[];
32 #define ZYN_MAX_HINTS 10
34 #define LV2DYNPARAM_GROUP(group) LV2DYNPARAM_GROUP_ ## group
35 #define LV2DYNPARAM_PARAMETER(parameter) LV2DYNPARAM_PARAMETER_ ## parameter
37 #define LV2DYNPARAM_GROUP_INIT(parent_group, group, name_value, hints...) \
38 groups_map[LV2DYNPARAM_GROUP(group) + 2] = group_index; \
39 lv2dynparam_group_init(map_ptr, groups_map[LV2DYNPARAM_GROUP(parent_group) + 2], group_index, name_value, ## hints); \
42 #define LV2DYNPARAM_PARAMETER_INIT_BOOL(parent_group, lv2parameter, component, zynparameter, name_value, scope_value, hints...) \
43 LOG_DEBUG("Registering %u (\"%s\") bool -> %u", \
44 LV2DYNPARAM_PARAMETER(lv2parameter), \
46 ZYNADD_PARAMETER_BOOL_ ## zynparameter); \
47 params_map[LV2DYNPARAM_PARAMETER(lv2parameter)] = param_index; \
48 map_ptr->parameters[param_index].parent = groups_map[LV2DYNPARAM_GROUP(parent_group) + 2]; \
49 map_ptr->parameters[param_index].name = name_value; \
50 map_ptr->parameters[param_index].type = LV2DYNPARAM_PARAMETER_TYPE_BOOL; \
51 map_ptr->parameters[param_index].scope = LV2DYNPARAM_PARAMETER_SCOPE_TYPE_ ## scope_value; \
52 map_ptr->parameters[param_index].addsynth_component = ZYNADD_COMPONENT_ ## component; \
53 map_ptr->parameters[param_index].addsynth_parameter = ZYNADD_PARAMETER_BOOL_ ## zynparameter; \
56 #define LV2DYNPARAM_PARAMETER_INIT_BOOL_SEMI(parent_group, lv2parameter, component, zynparameter, name_value, scope_value, other_parameter, hints...) \
57 LOG_DEBUG("Registering %u (\"%s\") bool -> %u; with other %u", \
58 LV2DYNPARAM_PARAMETER(lv2parameter), \
60 ZYNADD_PARAMETER_BOOL_ ## zynparameter, \
61 LV2DYNPARAM_PARAMETER(other_parameter)); \
62 params_map[LV2DYNPARAM_PARAMETER(lv2parameter)] = param_index; \
63 map_ptr->parameters[param_index].parent = groups_map[LV2DYNPARAM_GROUP(parent_group) + 2]; \
64 map_ptr->parameters[param_index].name = name_value; \
65 map_ptr->parameters[param_index].type = LV2DYNPARAM_PARAMETER_TYPE_BOOL; \
66 map_ptr->parameters[param_index].scope = LV2DYNPARAM_PARAMETER_SCOPE_TYPE_ ## scope_value ## _OTHER; \
67 map_ptr->parameters[param_index].addsynth_component = ZYNADD_COMPONENT_ ## component; \
68 map_ptr->parameters[param_index].addsynth_parameter = ZYNADD_PARAMETER_BOOL_ ## zynparameter; \
69 map_ptr->parameters[param_index].scope_specific = LV2DYNPARAM_PARAMETER(other_parameter); \
72 #define LV2DYNPARAM_PARAMETER_INIT_FLOAT(parent_group, lv2parameter, component, zynparameter, name_value, min_value, max_value, scope_value, hints...) \
73 LOG_DEBUG("Registering %u (\"%s\") float -> %u:%u", \
74 LV2DYNPARAM_PARAMETER(lv2parameter), \
76 ZYNADD_COMPONENT_ ## component, \
77 ZYNADD_PARAMETER_FLOAT_ ## zynparameter); \
78 params_map[LV2DYNPARAM_PARAMETER(lv2parameter)] = param_index; \
79 map_ptr->parameters[param_index].parent = groups_map[LV2DYNPARAM_GROUP(parent_group) + 2]; \
80 map_ptr->parameters[param_index].name = name_value; \
81 map_ptr->parameters[param_index].type = LV2DYNPARAM_PARAMETER_TYPE_FLOAT; \
82 map_ptr->parameters[param_index].scope = LV2DYNPARAM_PARAMETER_SCOPE_TYPE_ ## scope_value; \
83 map_ptr->parameters[param_index].min.fpoint = min_value; \
84 map_ptr->parameters[param_index].max.fpoint = max_value; \
85 map_ptr->parameters[param_index].addsynth_component = ZYNADD_COMPONENT_ ## component; \
86 map_ptr->parameters[param_index].addsynth_parameter = ZYNADD_PARAMETER_FLOAT_ ## zynparameter; \
89 #define LV2DYNPARAM_PARAMETER_INIT_INT(parent_group, lv2parameter, component, zynparameter, name_value, min_value, max_value, scope_value, hints...) \
90 LOG_DEBUG("Registering %u (\"%s\") int -> %u:%u", \
91 LV2DYNPARAM_PARAMETER(lv2parameter), \
93 ZYNADD_COMPONENT_ ## component, \
94 ZYNADD_PARAMETER_INT_ ## zynparameter); \
95 params_map[LV2DYNPARAM_PARAMETER(lv2parameter)] = param_index; \
96 map_ptr->parameters[param_index].parent = groups_map[LV2DYNPARAM_GROUP(parent_group) + 2]; \
97 map_ptr->parameters[param_index].name = name_value; \
98 map_ptr->parameters[param_index].type = LV2DYNPARAM_PARAMETER_TYPE_INT; \
99 map_ptr->parameters[param_index].scope = LV2DYNPARAM_PARAMETER_SCOPE_TYPE_ ## scope_value; \
100 map_ptr->parameters[param_index].min.integer = min_value; \
101 map_ptr->parameters[param_index].max.integer = max_value; \
102 map_ptr->parameters[param_index].addsynth_component = ZYNADD_COMPONENT_ ## component; \
103 map_ptr->parameters[param_index].addsynth_parameter = ZYNADD_PARAMETER_INT_ ## zynparameter; \
106 #define LV2DYNPARAM_PARAMETER_INIT_ENUM(parent_group, lv2parameter, component, zynparameter, name_value, values, count, scope_value, hints...) \
107 LOG_DEBUG("Registering %u (\"%s\") enum -> %u", \
108 LV2DYNPARAM_PARAMETER(lv2parameter), \
110 params_map[LV2DYNPARAM_PARAMETER(lv2parameter)] = param_index; \
111 map_ptr->parameters[param_index].parent = groups_map[LV2DYNPARAM_GROUP(parent_group) + 2]; \
112 map_ptr->parameters[param_index].name = name_value; \
113 map_ptr->parameters[param_index].type = LV2DYNPARAM_PARAMETER_TYPE_ENUM; \
114 map_ptr->parameters[param_index].scope = LV2DYNPARAM_PARAMETER_SCOPE_TYPE_ ## scope_value; \
115 map_ptr->parameters[param_index].min.enum_values = values; \
116 map_ptr->parameters[param_index].max.enum_values_count = count; \
117 map_ptr->parameters[param_index].addsynth_component = ZYNADD_COMPONENT_ ## component; \
118 map_ptr->parameters[param_index].addsynth_parameter = ZYNADD_PARAMETER_ENUM_ ## zynparameter; \
121 #define LV2DYNPARAM_FOREST_MAP_BEGIN(_groups_count, _params_count, _groups, _params) \
125 int groups_map[_groups_count + 2]; \
126 int params_map[_params_count]; \
128 map_ptr->groups_count = _groups_count; \
129 map_ptr->parameters_count = _params_count; \
131 map_ptr->groups = _groups; \
132 map_ptr->parameters = _params; \
134 groups_map[0] = LV2DYNPARAM_GROUP_INVALID; \
135 groups_map[1] = LV2DYNPARAM_GROUP_ROOT; \
139 for (i = 0 ; i < LV2DYNPARAM_GROUPS_COUNT ; i++) \
141 map_ptr->groups[i].parent = LV2DYNPARAM_GROUP_INVALID; \
142 groups_map[i + 2] = LV2DYNPARAM_GROUP_INVALID; \
145 for (i = 0 ; i < LV2DYNPARAM_PARAMETERS_COUNT ; i++) \
147 map_ptr->parameters[i].parent = LV2DYNPARAM_GROUP_INVALID; \
148 params_map[i] = -1; \
151 #define LV2DYNPARAM_FOREST_MAP_END \
152 /* updated scope_specific when needed */ \
153 for (i = 0 ; i < map_ptr->parameters_count ; i++) \
155 if (map_ptr->parameters[i].scope == LV2DYNPARAM_PARAMETER_SCOPE_TYPE_HIDE_OTHER || \
156 map_ptr->parameters[i].scope == LV2DYNPARAM_PARAMETER_SCOPE_TYPE_SHOW_OTHER) \
158 map_ptr->parameters[i].scope_specific = params_map[map_ptr->parameters[i].scope_specific]; \
162 LV2DYNPARAM_FOREST_MAP_ASSERT_VALID;
164 #define LV2DYNPARAM_FOREST_MAP_ASSERT_VALID \
165 /* santity check that we have filled all values */ \
167 assert(group_index == LV2DYNPARAM_GROUPS_COUNT); \
169 assert(param_index == LV2DYNPARAM_PARAMETERS_COUNT); \
171 for (i = 0 ; i < LV2DYNPARAM_PARAMETERS_COUNT ; i++) \
173 LOG_DEBUG("parameter %d with parent %d", i, map_ptr->parameters[i].parent); \
174 assert(map_ptr->parameters[i].parent != LV2DYNPARAM_GROUP_INVALID); \
175 assert(map_ptr->parameters[i].parent < LV2DYNPARAM_GROUPS_COUNT); \
178 for (i = 0 ; i < LV2DYNPARAM_GROUPS_COUNT ; i++) \
180 LOG_DEBUG("group %d with parent %d", i, map_ptr->groups[i].parent); \
181 assert(map_ptr->groups[i].parent != LV2DYNPARAM_GROUP_INVALID); \
183 assert(map_ptr->groups[i].name != NULL); \
185 /* check that parents are with smaller indexes than children */ \
186 /* this checks for loops too */ \
187 assert(map_ptr->groups[i].parent < i); \
190 struct group_descriptor
192 int parent
; /* index of parent, LV2DYNPARAM_GROUP_ROOT for root children */
194 const char * name
; /* group name */
196 struct lv2dynparam_hints hints
;
197 const char * hint_names
[ZYN_MAX_HINTS
];
198 const char * hint_values
[ZYN_MAX_HINTS
];
201 struct parameter_descriptor
203 int parent
; /* index of parent, LV2DYNPARAM_GROUP_ROOT for root children */
204 const char * name
; /* parameter name */
206 struct lv2dynparam_hints hints
;
207 const char * hint_names
[ZYN_MAX_HINTS
];
208 const char * hint_values
[ZYN_MAX_HINTS
];
210 unsigned int type
; /* one of LV2DYNPARAM_PARAMETER_TYPE_XXX */
212 unsigned int addsynth_component
; /* one of ZYNADD_COMPONENT_XXX */
213 unsigned int addsynth_parameter
; /* one of ZYNADD_PARAMETER_XXX */
215 unsigned int scope
; /* one of LV2DYNPARAM_PARAMETER_SCOPE_TYPE_XXX */
216 unsigned int scope_specific
;
222 const char ** enum_values
;
229 unsigned int enum_values_count
;
233 struct zyn_forest_map
236 size_t parameters_count
;
238 struct group_descriptor
* groups
;
239 struct parameter_descriptor
* parameters
;
243 lv2dynparam_group_init(
244 struct zyn_forest_map
* map_ptr
,
250 #endif /* #ifndef ZYNADD_DYNPARAM_FOREST_MAP_H__3ED30D71_513B_4B84_9A9B_1C9C62EE0A87__INCLUDED */