summaryrefslogtreecommitdiff
path: root/config.c
diff options
context:
space:
mode:
Diffstat (limited to 'config.c')
-rw-r--r--config.c69
1 files changed, 37 insertions, 32 deletions
diff --git a/config.c b/config.c
index fb8a6fa..e373727 100644
--- a/config.c
+++ b/config.c
@@ -8,9 +8,9 @@
8 8
9int g_midi_main_control = -1; 9int g_midi_main_control = -1;
10int g_midi_main_channel = 0; 10int g_midi_main_channel = 0;
11int g_midi_two_octave_split = 256 / 2; 11int g_midi_two_octave_split = 50;
12int g_midi_three_octave_split_1 = 256 / 3; 12int g_midi_three_octave_split_1 = 33;
13int g_midi_three_octave_split_2 = 512 / 3; 13int g_midi_three_octave_split_2 = 66;
14int g_midi_three_octave_split_inverse = 0; 14int g_midi_three_octave_split_inverse = 0;
15int g_settled_dist = 5; 15int g_settled_dist = 5;
16int g_timetosilence = 30; 16int g_timetosilence = 30;
@@ -33,12 +33,14 @@ config_reset()
33 33
34 g_midi_main_control = -1; 34 g_midi_main_control = -1;
35 g_midi_main_channel = 0; 35 g_midi_main_channel = 0;
36 g_midi_two_octave_split = 256 / 2; 36 g_midi_two_octave_split = 50;
37 g_midi_three_octave_split_1 = 256 / 3; 37 g_midi_three_octave_split_1 = 33;
38 g_midi_three_octave_split_2 = 512 / 3; 38 g_midi_three_octave_split_2 = 66;
39 g_midi_three_octave_split_inverse = 0; 39 g_midi_three_octave_split_inverse = 0;
40 g_settled_dist = 5; 40 g_settled_dist = 5;
41 g_timetosilence = 30; 41 g_timetosilence = 30;
42
43 g_config_source = source_none;
42} 44}
43 45
44 46
@@ -206,23 +208,19 @@ config_handle_line(char *line)
206 { 208 {
207 LLine *l = &sc->line; 209 LLine *l = &sc->line;
208 210
209 if (sscanf(line, "%d %d %d %d", &l->x0, &l->y0, &l->x1, &l->y1) != 4) { 211 if (sscanf(line, "%d %d %d %d", &l->p0.x, &l->p0.y, &l->p1.x, &l->p1.y) != 4) {
210 fprintf(stderr, "Incorrect Line statement for string\n"); 212 fprintf(stderr, "Incorrect Line statement for string\n");
211 return -1; 213 return -1;
212 } 214 }
213 if (l->y0 > l->y1) { 215 if (l->p0.y > l->p1.y) {
214 l->y0 ^= l->y1; 216 LPoint tmp = l->p0;
215 l->y1 ^= l->y0; 217 l->p0 = l->p1;
216 l->y0 ^= l->y1; 218 l->p1 = tmp;
217 l->x0 ^= l->x1;
218 l->x1 ^= l->x0;
219 l->x0 ^= l->x1;
220
221 } 219 }
222 if (l->y0 > g_min_y) 220 if (l->p0.y > g_min_y)
223 g_min_y = l->y0; 221 g_min_y = l->p0.y;
224 if (l->y1 < g_max_y) 222 if (l->p0.y < g_max_y)
225 g_max_y = l->y1; 223 g_max_y = l->p1.y;
226 break; 224 break;
227 } 225 }
228 case KEYWORD_MODE: 226 case KEYWORD_MODE:
@@ -259,7 +257,7 @@ config_handle_line(char *line)
259 fprintf(stderr, "Incorrect channel specified: %s.\n", _line); 257 fprintf(stderr, "Incorrect channel specified: %s.\n", _line);
260 return -1; 258 return -1;
261 } 259 }
262 printf("String %d is on channel %d\n", g_current_string, sc->channel); 260 printf("String %d is on channel %d\n", 1 + g_current_string, sc->channel);
263 break; 261 break;
264 case KEYWORD_NOTE: 262 case KEYWORD_NOTE:
265 sc->note = config_midi_note_from_string(line); 263 sc->note = config_midi_note_from_string(line);
@@ -267,7 +265,7 @@ config_handle_line(char *line)
267 fprintf(stderr, "Unknown midi note specified: %s.\n", _line); 265 fprintf(stderr, "Unknown midi note specified: %s.\n", _line);
268 return -1; 266 return -1;
269 } 267 }
270 printf("String %d is midi note %d\n", g_current_string, sc->note); 268 printf("String %d is midi note %d\n", 1 + g_current_string, sc->note);
271 break; 269 break;
272 case KEYWORD_AFTERTOUCH: 270 case KEYWORD_AFTERTOUCH:
273 switch (config_findkeyword(&line)) { 271 switch (config_findkeyword(&line)) {
@@ -315,7 +313,6 @@ config_handle_line(char *line)
315 fprintf(stderr, "Invalid percentage in line: %s\n", _line); 313 fprintf(stderr, "Invalid percentage in line: %s\n", _line);
316 exit(1); 314 exit(1);
317 } 315 }
318 g_midi_two_octave_split = (256 * g_midi_two_octave_split) / 100;
319 break; 316 break;
320 case KEYWORD_THREEOCTAVESPLIT_1: 317 case KEYWORD_THREEOCTAVESPLIT_1:
321 g_midi_three_octave_split_1 = atol(line); 318 g_midi_three_octave_split_1 = atol(line);
@@ -324,7 +321,6 @@ config_handle_line(char *line)
324 fprintf(stderr, "Invalid percentage in line: %s\n", _line); 321 fprintf(stderr, "Invalid percentage in line: %s\n", _line);
325 exit(1); 322 exit(1);
326 } 323 }
327 g_midi_three_octave_split_1 = (256 * g_midi_three_octave_split_1) / 100;
328 split_done = 1; 324 split_done = 1;
329 break; 325 break;
330 case KEYWORD_THREEOCTAVESPLIT_2: 326 case KEYWORD_THREEOCTAVESPLIT_2:
@@ -334,7 +330,6 @@ config_handle_line(char *line)
334 fprintf(stderr, "Invalid percentage in line: %s\n", _line); 330 fprintf(stderr, "Invalid percentage in line: %s\n", _line);
335 return -1; 331 return -1;
336 } 332 }
337 g_midi_three_octave_split_2 = (256 * g_midi_three_octave_split_2) / 100;
338 split_done = 1; 333 split_done = 1;
339 break; 334 break;
340 case KEYWORD_MIDI_MAIN_CONTROL: 335 case KEYWORD_MIDI_MAIN_CONTROL:
@@ -377,34 +372,43 @@ config_handle_line(char *line)
377 return 0; 372 return 0;
378} 373}
379 374
380void 375size_t
381config_dumpglobals(char *out, size_t outsize) 376config_dumpglobals(char *out, size_t outsize)
382{ 377{
383 int tos1 = g_midi_three_octave_split_inverse ? g_midi_three_octave_split_2 : g_midi_three_octave_split_1; 378 int tos1 = g_midi_three_octave_split_inverse ? g_midi_three_octave_split_2 : g_midi_three_octave_split_1;
384 int tos2 = g_midi_three_octave_split_inverse ? g_midi_three_octave_split_1 : g_midi_three_octave_split_2; 379 int tos2 = g_midi_three_octave_split_inverse ? g_midi_three_octave_split_1 : g_midi_three_octave_split_2;
385 380
386 size_t off = snprintf(out, outsize, 381 size_t off = snprintf(out, outsize,
387 "Strings %d\n\nmidi_two_octave_split %d\nmidi_three_octave_split_1 %d\nmidi_three_octave_split_2 %d\nmidi_main_control %d\nmidi_main_channel %d\n", 382 "Strings %d\n\nmidi_two_octave_split %d\nmidi_three_octave_split_1 %d\nmidi_three_octave_split_2 %d\n",
388 g_string_count, g_midi_two_octave_split, tos1, tos2, g_midi_main_control, g_midi_main_channel ); 383 g_string_count, g_midi_two_octave_split, tos1, tos2 );
384
385 if (g_midi_main_control >= 0)
386 off += snprintf(out + off, outsize - off,
387 "midi_main_control %d\n\n", g_midi_main_control);
388
389 if (g_midi_main_channel > 0)
390 off += snprintf(out + off, outsize - off,
391 "midi_main_channel %d\n\n", g_midi_main_channel);
389 392
390 if (g_settled_dist != 5) 393 if (g_settled_dist != 5)
391 off += snprintf(out + off, outsize - off, 394 off += snprintf(out + off, outsize - off,
392 "SettledDist %d\n\n", g_settled_dist); 395 "SettledDist %d\n\n", g_settled_dist);
393 snprintf(out + off, outsize - off, "\n" ); 396 off += snprintf(out + off, outsize - off, "\n" );
397 return off;
394} 398}
395 399
396void 400size_t
397config_dumpstring(int string, char *out, size_t outsize) 401config_dumpstring(int string, char *out, size_t outsize)
398{ 402{
399 StringConfig *s = g_string_conf + string; 403 StringConfig *s = g_string_conf + string;
400 404
401 if (string < 0 || string > g_string_count || !out) { 405 if (string < 0 || string > g_string_count || !out) {
402 if (out && outsize) *out = 0; 406 if (out && outsize) *out = 0;
403 return; 407 return 0;
404 } 408 }
405 size_t off = snprintf(out, outsize, 409 size_t off = snprintf(out, outsize,
406 "String %d\n Line %d %d %d %d\n Mode %s\n Channel %d\n Note %s\n AfterTouch %s\n Controller %d\n", 410 "String %d\n Line %d %d %d %d\n Mode %s\n Channel %d\n Note %s\n AfterTouch %s\n Controller %d\n",
407 string + 1, s->line.x0, s->line.y0, s->line.x1, s->line.y1, 411 string + 1, s->line.p0.x, s->line.p0.y, s->line.p1.x, s->line.p1.y,
408 mode_names[s->mode], s->channel, midi_note[s->note], modifier_names[s->modifier], s->controller ); 412 mode_names[s->mode], s->channel, midi_note[s->note], modifier_names[s->modifier], s->controller );
409 413
410 if (s->timetosilence) 414 if (s->timetosilence)
@@ -413,5 +417,6 @@ config_dumpstring(int string, char *out, size_t outsize)
413 if (s->pitch_factor) 417 if (s->pitch_factor)
414 off += snprintf(out + off, outsize - off, 418 off += snprintf(out + off, outsize - off,
415 " PitchFactor %d\n", s->pitch_factor); 419 " PitchFactor %d\n", s->pitch_factor);
416 snprintf(out + off, outsize - off, "\n" ); 420 off += snprintf(out + off, outsize - off, "\n" );
421 return off;
417} 422}