diff options
-rw-r--r-- | config.c | 435 |
1 files changed, 219 insertions, 216 deletions
@@ -137,292 +137,290 @@ static keyword keywords[] = { | |||
137 | static int | 137 | static int |
138 | config_findkeyword(char **line) | 138 | config_findkeyword(char **line) |
139 | { | 139 | { |
140 | char *_l = *line; | 140 | char *_l = *line; |
141 | int i; | 141 | int i; |
142 | 142 | ||
143 | while (isspace(*_l)) | 143 | while (isspace(*_l)) |
144 | ++_l; | 144 | ++_l; |
145 | 145 | ||
146 | for (i = 0; keywords[i].name; ++i) { | 146 | for (i = 0; keywords[i].name; ++i) { |
147 | size_t kl = strlen(keywords[i].name); | 147 | size_t kl = strlen(keywords[i].name); |
148 | 148 | ||
149 | if (!strncasecmp(_l, keywords[i].name, kl)) { | 149 | if (!strncasecmp(_l, keywords[i].name, kl)) { |
150 | if (!isspace(_l[kl]) && _l[kl]) | 150 | if (!isspace(_l[kl]) && _l[kl]) |
151 | continue; | 151 | continue; |
152 | _l += strlen(keywords[i].name); | 152 | _l += strlen(keywords[i].name); |
153 | 153 | ||
154 | /* Skip rest of white spaces */ | 154 | /* Skip rest of white spaces */ |
155 | while (isspace(*_l)) | 155 | while (isspace(*_l)) |
156 | ++_l; | 156 | ++_l; |
157 | *line = _l; | 157 | *line = _l; |
158 | return keywords[i].id; | 158 | return keywords[i].id; |
159 | } | ||
160 | } | 159 | } |
161 | return -1; | 160 | } |
161 | return -1; | ||
162 | } | 162 | } |
163 | 163 | ||
164 | static uint8_t | 164 | static uint8_t |
165 | config_midi_note_from_string(char *string) | 165 | config_midi_note_from_string(char *string) |
166 | { | 166 | { |
167 | int i; | 167 | int i; |
168 | 168 | ||
169 | for (i = 0; i < sizeof(midi_note) / sizeof(*midi_note); ++i) | 169 | for (i = 0; i < sizeof(midi_note) / sizeof(*midi_note); ++i) |
170 | if (!strncasecmp(string, midi_note[i], strlen(midi_note[i]))) | 170 | if (!strncasecmp(string, midi_note[i], strlen(midi_note[i]))) |
171 | return i; | 171 | return i; |
172 | return 0xff; | 172 | return 0xff; |
173 | } | 173 | } |
174 | 174 | ||
175 | char * | 175 | char * |
176 | config_midi_note_to_string(int string) | 176 | config_midi_note_to_string(int string) |
177 | { | 177 | { |
178 | return midi_note[string]; | 178 | return midi_note[string]; |
179 | } | 179 | } |
180 | 180 | ||
181 | int | 181 | int |
182 | config_handle_line(char *line) | 182 | config_handle_line(char *line) |
183 | { | 183 | { |
184 | StringConfig *sc = g_string_conf + g_current_string; | 184 | StringConfig *sc = g_string_conf + g_current_string; |
185 | int split_done = 0; | 185 | int split_done = 0; |
186 | char *_line = line; | 186 | char *_line = line; |
187 | 187 | ||
188 | /* Skip leading spaces */ | 188 | /* Skip leading spaces */ |
189 | while (isspace(*line)) | 189 | while (isspace(*line)) |
190 | ++line; | 190 | ++line; |
191 | if (*line == 0 || *line == '#' || *line == '\n') | 191 | if (*line == 0 || *line == '#' || *line == '\n') |
192 | return 0; | 192 | return 0; |
193 | 193 | ||
194 | switch (config_findkeyword(&line)) { | 194 | switch (config_findkeyword(&line)) { |
195 | case KEYWORD_STRINGS: | 195 | case KEYWORD_STRINGS: |
196 | g_string_count = atol(line); | 196 | g_string_count = atol(line); |
197 | if (!g_string_count || g_string_count > MAX_LINECOUNT) { | 197 | if (!g_string_count || g_string_count > MAX_LINECOUNT) { |
198 | harfe_error(stderr, "Incorrect number of strings: %s\n", _line); | 198 | harfe_error(stderr, "Incorrect number of strings: %s\n", _line); |
199 | return -1; | 199 | return -1; |
200 | } | 200 | } |
201 | harfe_debug("GLOBAL: Configuring expected lines %d\n", g_string_count); | 201 | harfe_debug("GLOBAL: Configuring expected lines %d\n", g_string_count); |
202 | break; | 202 | break; |
203 | case KEYWORD_STRING: | 203 | case KEYWORD_STRING: |
204 | g_current_string = atol(line) - 1; | 204 | g_current_string = atol(line) - 1; |
205 | harfe_debug("Switching to string: %d\n", g_current_string + 1); | 205 | harfe_debug("Switching to string: %d\n", g_current_string + 1); |
206 | if (g_current_string < 0 || g_current_string > g_string_count) { | 206 | if (g_current_string < 0 || g_current_string > g_string_count) { |
207 | harfe_error(stderr, "Incorrect string selected: %s\n", _line); | 207 | harfe_error(stderr, "Incorrect string selected: %s\n", _line); |
208 | return -1; | 208 | return -1; |
209 | } | 209 | } |
210 | break; | 210 | break; |
211 | case KEYWORD_LINE: | 211 | case KEYWORD_LINE: |
212 | { | 212 | { |
213 | LLine *l = &sc->line; | 213 | LLine *l = &sc->line; |
214 | 214 | ||
215 | if (sscanf(line, "%d %d %d %d", &l->p0.x, &l->p0.y, &l->p1.x, &l->p1.y) != 4) { | 215 | if (sscanf(line, "%d %d %d %d", &l->p0.x, &l->p0.y, &l->p1.x, &l->p1.y) != 4) { |
216 | harfe_error(stderr, "Incorrect Line statement for string\n"); | 216 | harfe_error(stderr, "Incorrect Line statement for string\n"); |
217 | return -1; | 217 | return -1; |
218 | } | 218 | } |
219 | if (l->p0.y > l->p1.y) { | 219 | if (l->p0.y > l->p1.y) { |
220 | LPoint tmp = l->p0; | 220 | LPoint tmp = l->p0; |
221 | l->p0 = l->p1; | 221 | l->p0 = l->p1; |
222 | l->p1 = tmp; | 222 | l->p1 = tmp; |
223 | } | ||
224 | if (l->p0.y > g_min_y) | ||
225 | g_min_y = l->p0.y; | ||
226 | if (l->p0.y < g_max_y) | ||
227 | g_max_y = l->p1.y; | ||
228 | break; | ||
229 | } | 223 | } |
224 | if (l->p0.y > g_min_y) | ||
225 | g_min_y = l->p0.y; | ||
226 | if (l->p0.y < g_max_y) | ||
227 | g_max_y = l->p1.y; | ||
228 | break; | ||
229 | } | ||
230 | case KEYWORD_MODE: | 230 | case KEYWORD_MODE: |
231 | switch (config_findkeyword(&line)) { | 231 | switch (config_findkeyword(&line)) { |
232 | case KEYWORD_MODE_ONE_OCTAVE: | 232 | case KEYWORD_MODE_ONE_OCTAVE: |
233 | sc->mode = midi_one_octave; | 233 | sc->mode = midi_one_octave; |
234 | harfe_debug("String %d is midi_one_octave\n", 1 + g_current_string); | 234 | harfe_debug("String %d is midi_one_octave\n", 1 + g_current_string); |
235 | break; | 235 | break; |
236 | case KEYWORD_MODE_TWO_OCTAVES: | 236 | case KEYWORD_MODE_TWO_OCTAVES: |
237 | sc->mode = midi_two_octaves; | 237 | sc->mode = midi_two_octaves; |
238 | harfe_debug("String %d is midi_two_octaves\n", 1 + g_current_string); | 238 | harfe_debug("String %d is midi_two_octaves\n", 1 + g_current_string); |
239 | break; | 239 | break; |
240 | case KEYWORD_MODE_THREE_OCTAVES: | 240 | case KEYWORD_MODE_THREE_OCTAVES: |
241 | sc->mode = midi_three_octaves; | 241 | sc->mode = midi_three_octaves; |
242 | harfe_debug("String %d is midi_three_octaves\n", 1 + g_current_string); | 242 | harfe_debug("String %d is midi_three_octaves\n", 1 + g_current_string); |
243 | break; | 243 | break; |
244 | case KEYWORD_MODE_CONTROL: | 244 | case KEYWORD_MODE_CONTROL: |
245 | sc->mode = midi_control; | 245 | sc->mode = midi_control; |
246 | harfe_debug("String %d is midi_control\n", 1 + g_current_string); | 246 | harfe_debug("String %d is midi_control\n", 1 + g_current_string); |
247 | break; | 247 | break; |
248 | case KEYWORD_MODE_CONTROL_INVERSE: | 248 | case KEYWORD_MODE_CONTROL_INVERSE: |
249 | sc->mode = midi_control_inv; | 249 | sc->mode = midi_control_inv; |
250 | harfe_debug("String %d is midi_control_inverse\n", 1 + g_current_string); | 250 | harfe_debug("String %d is midi_control_inverse\n", 1 + g_current_string); |
251 | break; | 251 | break; |
252 | default: | 252 | default: |
253 | harfe_error(stderr, "Illegal Mode for string: %s\n", _line); | 253 | harfe_error(stderr, "Illegal Mode for string: %s\n", _line); |
254 | return -1; | 254 | return -1; |
255 | 255 | ||
256 | } | 256 | } |
257 | break; | 257 | break; |
258 | case KEYWORD_CHANNEL: | 258 | case KEYWORD_CHANNEL: |
259 | sc->channel = atol(line); | 259 | sc->channel = atol(line); |
260 | if (sc->channel > 16) { | 260 | if (sc->channel > 16) { |
261 | harfe_error(stderr, "Incorrect channel specified: %s.\n", _line); | 261 | harfe_error(stderr, "Incorrect channel specified: %s.\n", _line); |
262 | return -1; | 262 | return -1; |
263 | } | 263 | } |
264 | harfe_debug("String %d is on channel %d\n", 1 + g_current_string, sc->channel); | 264 | harfe_debug("String %d is on channel %d\n", 1 + g_current_string, sc->channel); |
265 | break; | 265 | break; |
266 | case KEYWORD_NOTE: | 266 | case KEYWORD_NOTE: |
267 | sc->note = config_midi_note_from_string(line); | 267 | sc->note = config_midi_note_from_string(line); |
268 | if (sc->note == 0xff) { | 268 | if (sc->note == 0xff) { |
269 | harfe_error(stderr, "Unknown midi note specified: %s.\n", _line); | 269 | harfe_error(stderr, "Unknown midi note specified: %s.\n", _line); |
270 | return -1; | 270 | return -1; |
271 | } | 271 | } |
272 | harfe_debug("String %d is midi note %d\n", 1 + g_current_string, sc->note); | 272 | harfe_debug("String %d is midi note %d\n", 1 + g_current_string, sc->note); |
273 | break; | 273 | break; |
274 | case KEYWORD_AFTERTOUCH: | 274 | case KEYWORD_AFTERTOUCH: |
275 | switch (config_findkeyword(&line)) { | 275 | switch (config_findkeyword(&line)) { |
276 | case KEYWORD_NONE: | 276 | case KEYWORD_NONE: |
277 | sc->modifier = none; | 277 | sc->modifier = none; |
278 | harfe_debug("String %d does not act aftertouch\n", 1 + g_current_string); | 278 | harfe_debug("String %d does not act aftertouch\n", 1 + g_current_string); |
279 | break; | 279 | break; |
280 | case KEYWORD_PITCH_BEND_UP: | 280 | case KEYWORD_PITCH_BEND_UP: |
281 | sc->modifier = pitch_bend_up; | 281 | sc->modifier = pitch_bend_up; |
282 | harfe_debug("String %d acts aftertouch as pitch_bend_up\n", 1 + g_current_string); | 282 | harfe_debug("String %d acts aftertouch as pitch_bend_up\n", 1 + g_current_string); |
283 | break; | 283 | break; |
284 | case KEYWORD_PITCH_BEND_DOWN: | 284 | case KEYWORD_PITCH_BEND_DOWN: |
285 | sc->modifier = pitch_bend_down; | 285 | sc->modifier = pitch_bend_down; |
286 | harfe_debug("String %d acts aftertouch as pitch_bend_down\n", 1 + g_current_string); | 286 | harfe_debug("String %d acts aftertouch as pitch_bend_down\n", 1 + g_current_string); |
287 | break; | 287 | break; |
288 | case KEYWORD_MIDI_CONTROL: | 288 | case KEYWORD_MIDI_CONTROL: |
289 | sc->modifier = midi_controller; | 289 | sc->modifier = midi_controller; |
290 | harfe_debug("String %d acts aftertouch as midi_controller\n", 1 + g_current_string); | 290 | harfe_debug("String %d acts aftertouch as midi_controller\n", 1 + g_current_string); |
291 | break; | 291 | break; |
292 | case KEYWORD_MIDI_CONTROL_INVERSE: | 292 | case KEYWORD_MIDI_CONTROL_INVERSE: |
293 | sc->modifier = midi_controller_inv; | 293 | sc->modifier = midi_controller_inv; |
294 | harfe_debug("String %d acts aftertouch as midi_controller_inverse\n", 1 + g_current_string); | 294 | harfe_debug("String %d acts aftertouch as midi_controller_inverse\n", 1 + g_current_string); |
295 | break; | 295 | break; |
296 | default: | 296 | default: |
297 | harfe_error(stderr, "Illegal Modifier for string: %s\n", _line); | 297 | harfe_error(stderr, "Illegal Modifier for string: %s\n", _line); |
298 | return -1; | 298 | return -1; |
299 | } | 299 | } |
300 | break; | 300 | break; |
301 | case KEYWORD_PITCHFACTOR: | 301 | case KEYWORD_PITCHFACTOR: |
302 | sc->pitch_factor = atol(line); | 302 | sc->pitch_factor = atol(line); |
303 | harfe_debug("String %d is given a custom pitch factor of %d\n", 1 + g_current_string, sc->pitch_factor); | 303 | harfe_debug("String %d is given a custom pitch factor of %d\n", 1 + g_current_string, sc->pitch_factor); |
304 | break; | 304 | break; |
305 | case KEYWORD_CONTROLLER: | 305 | case KEYWORD_CONTROLLER: |
306 | sc->controller = atol(line); | 306 | sc->controller = atol(line); |
307 | harfe_debug("String %d is on midi_controller line %d\n", 1 + g_current_string, sc->controller); | 307 | harfe_debug("String %d is on midi_controller line %d\n", 1 + g_current_string, sc->controller); |
308 | break; | 308 | break; |
309 | case KEYWORD_TIMETOSILENCE: | 309 | case KEYWORD_TIMETOSILENCE: |
310 | sc->timetosilence = atol(line); | 310 | sc->timetosilence = atol(line); |
311 | harfe_debug("String %d has a timetosilence of %d\n", 1 + g_current_string, sc->timetosilence); | 311 | harfe_debug("String %d has a timetosilence of %d\n", 1 + g_current_string, sc->timetosilence); |
312 | break; | 312 | break; |
313 | case KEYWORD_TWOOCTAVESPLIT: | 313 | case KEYWORD_TWOOCTAVESPLIT: |
314 | g_midi_two_octave_split = atol(line); | 314 | g_midi_two_octave_split = atol(line); |
315 | harfe_debug("Splitting TWO octaves at %d%%\n", g_midi_two_octave_split); | 315 | harfe_debug("Splitting TWO octaves at %d%%\n", g_midi_two_octave_split); |
316 | if (g_midi_two_octave_split < 0 || g_midi_two_octave_split > 100) { | 316 | if (g_midi_two_octave_split < 0 || g_midi_two_octave_split > 100) { |
317 | harfe_error(stderr, "Invalid percentage in line: %s\n", _line); | 317 | harfe_error(stderr, "Invalid percentage in line: %s\n", _line); |
318 | exit(1); | 318 | exit(1); |
319 | } | 319 | } |
320 | break; | 320 | break; |
321 | case KEYWORD_THREEOCTAVESPLIT_1: | 321 | case KEYWORD_THREEOCTAVESPLIT_1: |
322 | g_midi_three_octave_split_1 = atol(line); | 322 | g_midi_three_octave_split_1 = atol(line); |
323 | harfe_debug("Splitting THREE octaves top above %d%%\n", g_midi_three_octave_split_1); | 323 | harfe_debug("Splitting THREE octaves top above %d%%\n", g_midi_three_octave_split_1); |
324 | if (g_midi_three_octave_split_1 < 0 || g_midi_three_octave_split_1 > 100) { | 324 | if (g_midi_three_octave_split_1 < 0 || g_midi_three_octave_split_1 > 100) { |
325 | harfe_error(stderr, "Invalid percentage in line: %s\n", _line); | 325 | harfe_error(stderr, "Invalid percentage in line: %s\n", _line); |
326 | exit(1); | 326 | exit(1); |
327 | } | 327 | } |
328 | split_done = 1; | 328 | split_done = 1; |
329 | break; | 329 | break; |
330 | case KEYWORD_THREEOCTAVESPLIT_2: | 330 | case KEYWORD_THREEOCTAVESPLIT_2: |
331 | g_midi_three_octave_split_2 = atol(line); | 331 | g_midi_three_octave_split_2 = atol(line); |
332 | harfe_debug("Splitting THREE octaves bottom below %d%%\n", g_midi_three_octave_split_2); | 332 | harfe_debug("Splitting THREE octaves bottom below %d%%\n", g_midi_three_octave_split_2); |
333 | if (g_midi_three_octave_split_2 < 0 || g_midi_three_octave_split_2 > 100) { | 333 | if (g_midi_three_octave_split_2 < 0 || g_midi_three_octave_split_2 > 100) { |
334 | harfe_error(stderr, "Invalid percentage in line: %s\n", _line); | 334 | harfe_error(stderr, "Invalid percentage in line: %s\n", _line); |
335 | return -1; | 335 | return -1; |
336 | } | 336 | } |
337 | split_done = 1; | 337 | split_done = 1; |
338 | break; | 338 | break; |
339 | case KEYWORD_MIDI_MAIN_CONTROL: | 339 | case KEYWORD_MIDI_MAIN_CONTROL: |
340 | g_midi_main_control = atol(line); | 340 | g_midi_main_control = atol(line); |
341 | harfe_debug("All Strings modify controller %d\n", g_midi_main_control); | 341 | harfe_debug("All Strings modify controller %d\n", g_midi_main_control); |
342 | if (g_midi_main_control > 127) { | 342 | if (g_midi_main_control > 127) { |
343 | harfe_error(stderr, "Invalid controller number %d in line: %s\n", g_midi_main_control, _line); | 343 | harfe_error(stderr, "Invalid controller number %d in line: %s\n", g_midi_main_control, _line); |
344 | return -1; | 344 | return -1; |
345 | } | 345 | } |
346 | break; | 346 | break; |
347 | case KEYWORD_MIDI_MAIN_CHANNEL: | 347 | case KEYWORD_MIDI_MAIN_CHANNEL: |
348 | g_midi_main_channel = atol(line); | 348 | g_midi_main_channel = atol(line); |
349 | harfe_debug("All Strings modify controller %d on channel %d\n", g_midi_main_control, g_midi_main_channel); | 349 | harfe_debug("All Strings modify controller %d on channel %d\n", g_midi_main_control, g_midi_main_channel); |
350 | if (g_midi_main_channel < 1 || g_midi_main_channel > 16) { | 350 | if (g_midi_main_channel < 1 || g_midi_main_channel > 16) { |
351 | harfe_error(stderr, "Invalid channel number %d in line: %s\n", g_midi_main_channel, _line); | 351 | harfe_error(stderr, "Invalid channel number %d in line: %s\n", g_midi_main_channel, _line); |
352 | return -1; | 352 | return -1; |
353 | } | 353 | } |
354 | break; | 354 | break; |
355 | case KEYWORD_SETTLED_DIST: | 355 | case KEYWORD_SETTLED_DIST: |
356 | g_settled_dist = atol(line); | 356 | g_settled_dist = atol(line); |
357 | harfe_debug("All AfterTouch events take place only after movement has slown down to %d points\n", g_settled_dist); | 357 | harfe_debug("All AfterTouch events take place only after movement has slown down to %d points\n", g_settled_dist); |
358 | break; | 358 | break; |
359 | default: | 359 | default: |
360 | harfe_error(stderr, "Unhandled config line: %s\n", _line); | 360 | harfe_error(stderr, "Unhandled config line: %s\n", _line); |
361 | return -1; | 361 | return -1; |
362 | |||
363 | } | ||
364 | if (!split_done) | ||
365 | return 0; | ||
366 | |||
367 | /* split also true for two octaves */ | ||
368 | if (g_midi_three_octave_split_2 < g_midi_three_octave_split_1) { | ||
369 | g_midi_three_octave_split_inverse = g_midi_three_octave_split_1; | ||
370 | g_midi_three_octave_split_1 = g_midi_three_octave_split_2; | ||
371 | g_midi_three_octave_split_2 = g_midi_three_octave_split_inverse; | ||
372 | g_midi_three_octave_split_inverse = 1; | ||
373 | } else | ||
374 | g_midi_three_octave_split_inverse = 0; | ||
375 | 362 | ||
363 | } | ||
364 | if (!split_done) | ||
376 | return 0; | 365 | return 0; |
366 | |||
367 | /* split also true for two octaves */ | ||
368 | if (g_midi_three_octave_split_2 < g_midi_three_octave_split_1) { | ||
369 | g_midi_three_octave_split_inverse = g_midi_three_octave_split_1; | ||
370 | g_midi_three_octave_split_1 = g_midi_three_octave_split_2; | ||
371 | g_midi_three_octave_split_2 = g_midi_three_octave_split_inverse; | ||
372 | g_midi_three_octave_split_inverse = 1; | ||
373 | } else | ||
374 | g_midi_three_octave_split_inverse = 0; | ||
375 | |||
376 | return 0; | ||
377 | } | 377 | } |
378 | 378 | ||
379 | size_t | 379 | size_t |
380 | config_dumpglobals(char *out, size_t outsize) | 380 | config_dumpglobals(char *out, size_t outsize) |
381 | { | 381 | { |
382 | int tos1 = g_midi_three_octave_split_inverse ? g_midi_three_octave_split_2 : g_midi_three_octave_split_1; | 382 | int tos1 = g_midi_three_octave_split_inverse ? g_midi_three_octave_split_2 : g_midi_three_octave_split_1; |
383 | int tos2 = g_midi_three_octave_split_inverse ? g_midi_three_octave_split_1 : g_midi_three_octave_split_2; | 383 | int tos2 = g_midi_three_octave_split_inverse ? g_midi_three_octave_split_1 : g_midi_three_octave_split_2; |
384 | 384 | ||
385 | size_t off = snprintf(out, outsize, | 385 | size_t off = snprintf(out, outsize, |
386 | "Strings %d\n\nmidi_two_octave_split %d\nmidi_three_octave_split_1 %d\nmidi_three_octave_split_2 %d\n", | 386 | "Strings %d\n\nmidi_two_octave_split %d\nmidi_three_octave_split_1 %d\nmidi_three_octave_split_2 %d\n", |
387 | g_string_count, g_midi_two_octave_split, tos1, tos2 ); | 387 | g_string_count, g_midi_two_octave_split, tos1, tos2 ); |
388 | 388 | ||
389 | if (g_midi_main_control >= 0) | 389 | if (g_midi_main_control >= 0) |
390 | off += snprintf(out + off, outsize - off, | 390 | off += snprintf(out + off, outsize - off, |
391 | "midi_main_control %d\n\n", g_midi_main_control); | 391 | "midi_main_control %d\n\n", g_midi_main_control); |
392 | 392 | ||
393 | if (g_midi_main_channel > 0) | 393 | if (g_midi_main_channel > 0) |
394 | off += snprintf(out + off, outsize - off, | 394 | off += snprintf(out + off, outsize - off, |
395 | "midi_main_channel %d\n\n", g_midi_main_channel); | 395 | "midi_main_channel %d\n\n", g_midi_main_channel); |
396 | 396 | ||
397 | if (g_settled_dist != 5) | 397 | if (g_settled_dist != 5) |
398 | off += snprintf(out + off, outsize - off, | 398 | off += snprintf(out + off, outsize - off, |
399 | "SettledDist %d\n\n", g_settled_dist); | 399 | "SettledDist %d\n\n", g_settled_dist); |
400 | off += snprintf(out + off, outsize - off, "\n" ); | 400 | off += snprintf(out + off, outsize - off, "\n" ); |
401 | return off; | 401 | return off; |
402 | } | 402 | } |
403 | 403 | ||
404 | size_t | 404 | size_t |
405 | config_dumpstring(int string, char *out, size_t outsize) | 405 | config_dumpstring(int string, char *out, size_t outsize) |
406 | { | 406 | { |
407 | StringConfig *s = g_string_conf + string; | 407 | StringConfig *s = g_string_conf + string; |
408 | 408 | ||
409 | if (string < 0 || string > g_string_count || !out) { | 409 | if (string < 0 || string > g_string_count || !out) { |
410 | if (out && outsize) *out = 0; | 410 | if (out && outsize) *out = 0; |
411 | return 0; | 411 | return 0; |
412 | } | 412 | } |
413 | size_t off = snprintf(out, outsize, | 413 | size_t off = snprintf(out, outsize, |
414 | "String %d\n Line %d %d %d %d\n Mode %s\n Channel %d\n Note %s\n AfterTouch %s\n Controller %d\n", | 414 | "String %d\n Line %d %d %d %d\n Mode %s\n Channel %d\n Note %s\n AfterTouch %s\n Controller %d\n", |
415 | string + 1, s->line.p0.x, s->line.p0.y, s->line.p1.x, s->line.p1.y, | 415 | string + 1, s->line.p0.x, s->line.p0.y, s->line.p1.x, s->line.p1.y, |
416 | mode_names[s->mode], s->channel, midi_note[s->note], modifier_names[s->modifier], s->controller ); | 416 | mode_names[s->mode], s->channel, midi_note[s->note], modifier_names[s->modifier], s->controller ); |
417 | 417 | ||
418 | if (s->timetosilence) | 418 | if (s->timetosilence) |
419 | off += snprintf(out + off, outsize - off, | 419 | off += snprintf(out + off, outsize - off, " TimeToSilence %d\n", s->timetosilence); |
420 | " TimeToSilence %d\n", s->timetosilence); | 420 | if (s->pitch_factor) |
421 | if (s->pitch_factor) | 421 | off += snprintf(out + off, outsize - off, " PitchFactor %d\n", s->pitch_factor); |
422 | off += snprintf(out + off, outsize - off, | 422 | off += snprintf(out + off, outsize - off, "\n" ); |
423 | " PitchFactor %d\n", s->pitch_factor); | 423 | return off; |
424 | off += snprintf(out + off, outsize - off, "\n" ); | ||
425 | return off; | ||
426 | } | 424 | } |
427 | 425 | ||
428 | void | 426 | void |
@@ -440,7 +438,12 @@ config_reverse_strings() | |||
440 | void | 438 | void |
441 | config_flip_y() | 439 | config_flip_y() |
442 | { | 440 | { |
441 | int i; | ||
443 | g_midi_three_octave_split_inverse ^= 1; | 442 | g_midi_three_octave_split_inverse ^= 1; |
444 | g_config_source = source_edit; | 443 | g_config_source = source_edit; |
445 | /* TODO: flip pit bend */ | 444 | for (i=0; i<g_string_count; ++i) |
445 | if (g_string_conf[i].modifier == pitch_bend_up) | ||
446 | g_string_conf[i].modifier = pitch_bend_down; | ||
447 | else if (g_string_conf[i].modifier == pitch_bend_down) | ||
448 | g_string_conf[i].modifier = pitch_bend_up; | ||
446 | } | 449 | } |