From fa0cb86eec43978054f9db295a77449d6b83ba43 Mon Sep 17 00:00:00 2001 From: erdgeist Date: Mon, 2 Apr 2018 01:37:40 +0200 Subject: Too many changes --- config.c | 88 ++++++++++++++++++++++++++++++++++++++-------------------------- config.h | 10 ++++++-- 2 files changed, 60 insertions(+), 38 deletions(-) diff --git a/config.c b/config.c index e373727..6b00e5b 100644 --- a/config.c +++ b/config.c @@ -22,6 +22,10 @@ StringConfig g_string_conf[MAX_LINECOUNT]; int g_string_count; +ConfigSource g_config_source = source_none; +int g_importing_config; +int g_calibration_running = 0; + void config_reset() { @@ -191,16 +195,16 @@ config_handle_line(char *line) case KEYWORD_STRINGS: g_string_count = atol(line); if (!g_string_count || g_string_count > MAX_LINECOUNT) { - fprintf(stderr, "Incorrect number of strings: %s\n", _line); + harfe_error(stderr, "Incorrect number of strings: %s\n", _line); return -1; } - printf("GLOBAL: Configuring expected lines %d\n", g_string_count); + harfe_debug("GLOBAL: Configuring expected lines %d\n", g_string_count); break; case KEYWORD_STRING: g_current_string = atol(line) - 1; - printf("Switching to string: %d\n", g_current_string + 1); + harfe_debug("Switching to string: %d\n", g_current_string + 1); if (g_current_string < 0 || g_current_string > g_string_count) { - fprintf(stderr, "Incorrect string selected: %s\n", _line); + harfe_error(stderr, "Incorrect string selected: %s\n", _line); return -1; } break; @@ -209,7 +213,7 @@ config_handle_line(char *line) LLine *l = &sc->line; if (sscanf(line, "%d %d %d %d", &l->p0.x, &l->p0.y, &l->p1.x, &l->p1.y) != 4) { - fprintf(stderr, "Incorrect Line statement for string\n"); + harfe_error(stderr, "Incorrect Line statement for string\n"); return -1; } if (l->p0.y > l->p1.y) { @@ -227,26 +231,26 @@ config_handle_line(char *line) switch (config_findkeyword(&line)) { case KEYWORD_MODE_ONE_OCTAVE: sc->mode = midi_one_octave; - printf("String %d is midi_one_octave\n", 1 + g_current_string); + harfe_debug("String %d is midi_one_octave\n", 1 + g_current_string); break; case KEYWORD_MODE_TWO_OCTAVES: sc->mode = midi_two_octaves; - printf("String %d is midi_two_octaves\n", 1 + g_current_string); + harfe_debug("String %d is midi_two_octaves\n", 1 + g_current_string); break; case KEYWORD_MODE_THREE_OCTAVES: sc->mode = midi_three_octaves; - printf("String %d is midi_three_octaves\n", 1 + g_current_string); + harfe_debug("String %d is midi_three_octaves\n", 1 + g_current_string); break; case KEYWORD_MODE_CONTROL: sc->mode = midi_control; - printf("String %d is midi_control\n", 1 + g_current_string); + harfe_debug("String %d is midi_control\n", 1 + g_current_string); break; case KEYWORD_MODE_CONTROL_INVERSE: sc->mode = midi_control_inv; - printf("String %d is midi_control_inverse\n", 1 + g_current_string); + harfe_debug("String %d is midi_control_inverse\n", 1 + g_current_string); break; default: - fprintf(stderr, "Illegal Mode for string: %s\n", _line); + harfe_error(stderr, "Illegal Mode for string: %s\n", _line); return -1; } @@ -254,106 +258,106 @@ config_handle_line(char *line) case KEYWORD_CHANNEL: sc->channel = atol(line); if (sc->channel > 16) { - fprintf(stderr, "Incorrect channel specified: %s.\n", _line); + harfe_error(stderr, "Incorrect channel specified: %s.\n", _line); return -1; } - printf("String %d is on channel %d\n", 1 + g_current_string, sc->channel); + harfe_debug("String %d is on channel %d\n", 1 + g_current_string, sc->channel); break; case KEYWORD_NOTE: sc->note = config_midi_note_from_string(line); if (sc->note == 0xff) { - fprintf(stderr, "Unknown midi note specified: %s.\n", _line); + harfe_error(stderr, "Unknown midi note specified: %s.\n", _line); return -1; } - printf("String %d is midi note %d\n", 1 + g_current_string, sc->note); + harfe_debug("String %d is midi note %d\n", 1 + g_current_string, sc->note); break; case KEYWORD_AFTERTOUCH: switch (config_findkeyword(&line)) { case KEYWORD_NONE: sc->modifier = none; - printf("String %d does not act aftertouch\n", 1 + g_current_string); + harfe_debug("String %d does not act aftertouch\n", 1 + g_current_string); break; case KEYWORD_PITCH_BEND_UP: sc->modifier = pitch_bend_up; - printf("String %d acts aftertouch as pitch_bend_up\n", 1 + g_current_string); + harfe_debug("String %d acts aftertouch as pitch_bend_up\n", 1 + g_current_string); break; case KEYWORD_PITCH_BEND_DOWN: sc->modifier = pitch_bend_down; - printf("String %d acts aftertouch as pitch_bend_down\n", 1 + g_current_string); + harfe_debug("String %d acts aftertouch as pitch_bend_down\n", 1 + g_current_string); break; case KEYWORD_MIDI_CONTROL: sc->modifier = midi_controller; - printf("String %d acts aftertouch as midi_controller\n", 1 + g_current_string); + harfe_debug("String %d acts aftertouch as midi_controller\n", 1 + g_current_string); break; case KEYWORD_MIDI_CONTROL_INVERSE: sc->modifier = midi_controller_inv; - printf("String %d acts aftertouch as midi_controller_inverse\n", 1 + g_current_string); + harfe_debug("String %d acts aftertouch as midi_controller_inverse\n", 1 + g_current_string); break; default: - fprintf(stderr, "Illegal Modifier for string: %s\n", _line); + harfe_error(stderr, "Illegal Modifier for string: %s\n", _line); return -1; } break; case KEYWORD_PITCHFACTOR: sc->pitch_factor = atol(line); - printf("String %d is given a custom pitch factor of %d\n", 1 + g_current_string, sc->pitch_factor); + harfe_debug("String %d is given a custom pitch factor of %d\n", 1 + g_current_string, sc->pitch_factor); break; case KEYWORD_CONTROLLER: sc->controller = atol(line); - printf("String %d is on midi_controller line %d\n", 1 + g_current_string, sc->controller); + harfe_debug("String %d is on midi_controller line %d\n", 1 + g_current_string, sc->controller); break; case KEYWORD_TIMETOSILENCE: sc->timetosilence = atol(line); - printf("String %d has a timetosilence of %d\n", 1 + g_current_string, sc->timetosilence); + harfe_debug("String %d has a timetosilence of %d\n", 1 + g_current_string, sc->timetosilence); break; case KEYWORD_TWOOCTAVESPLIT: g_midi_two_octave_split = atol(line); - printf("Splitting TWO octaves at %d%%\n", g_midi_two_octave_split); + harfe_debug("Splitting TWO octaves at %d%%\n", g_midi_two_octave_split); if (g_midi_two_octave_split < 0 || g_midi_two_octave_split > 100) { - fprintf(stderr, "Invalid percentage in line: %s\n", _line); + harfe_error(stderr, "Invalid percentage in line: %s\n", _line); exit(1); } break; case KEYWORD_THREEOCTAVESPLIT_1: g_midi_three_octave_split_1 = atol(line); - printf("Splitting THREE octaves top above %d%%\n", g_midi_three_octave_split_1); + harfe_debug("Splitting THREE octaves top above %d%%\n", g_midi_three_octave_split_1); if (g_midi_three_octave_split_1 < 0 || g_midi_three_octave_split_1 > 100) { - fprintf(stderr, "Invalid percentage in line: %s\n", _line); + harfe_error(stderr, "Invalid percentage in line: %s\n", _line); exit(1); } split_done = 1; break; case KEYWORD_THREEOCTAVESPLIT_2: g_midi_three_octave_split_2 = atol(line); - printf("Splitting THREE octaves bottom below %d%%\n", g_midi_three_octave_split_2); + harfe_debug("Splitting THREE octaves bottom below %d%%\n", g_midi_three_octave_split_2); if (g_midi_three_octave_split_2 < 0 || g_midi_three_octave_split_2 > 100) { - fprintf(stderr, "Invalid percentage in line: %s\n", _line); + harfe_error(stderr, "Invalid percentage in line: %s\n", _line); return -1; } split_done = 1; break; case KEYWORD_MIDI_MAIN_CONTROL: g_midi_main_control = atol(line); - printf("All Strings modify controller %d\n", g_midi_main_control); + harfe_debug("All Strings modify controller %d\n", g_midi_main_control); if (g_midi_main_control > 127) { - fprintf(stderr, "Invalid controller number %d in line: %s\n", g_midi_main_control, _line); + harfe_error(stderr, "Invalid controller number %d in line: %s\n", g_midi_main_control, _line); return -1; } break; case KEYWORD_MIDI_MAIN_CHANNEL: g_midi_main_channel = atol(line); - printf("All Strings modify controller %d on channel %d\n", g_midi_main_control, g_midi_main_channel); + harfe_debug("All Strings modify controller %d on channel %d\n", g_midi_main_control, g_midi_main_channel); if (g_midi_main_channel < 1 || g_midi_main_channel > 16) { - fprintf(stderr, "Invalid channel number %d in line: %s\n", g_midi_main_channel, _line); + harfe_error(stderr, "Invalid channel number %d in line: %s\n", g_midi_main_channel, _line); return -1; } break; case KEYWORD_SETTLED_DIST: g_settled_dist = atol(line); - printf("All AfterTouch events take place only after movement has slown down to %d points\n", g_settled_dist); + harfe_debug("All AfterTouch events take place only after movement has slown down to %d points\n", g_settled_dist); break; default: - fprintf(stderr, "Unhandled config line: %s\n", _line); + harfe_error(stderr, "Unhandled config line: %s\n", _line); return -1; } @@ -420,3 +424,15 @@ config_dumpstring(int string, char *out, size_t outsize) off += snprintf(out + off, outsize - off, "\n" ); return off; } + +void +config_reverse_strings() +{ + int i; + for (i=0; i +#include #include "geometry.h" #define MAX_LINECOUNT 32 -#define CALIB_DEBUG +//#define CALIB_DEBUG extern int g_min_y, g_max_y; @@ -76,9 +77,14 @@ typedef struct { } StringConfig; extern StringConfig g_string_conf[MAX_LINECOUNT]; -extern int g_string_count; +extern int g_string_count; +extern ConfigSource g_config_source; +extern int g_importing_config; +extern int g_calibration_running; + void config_reset(); int config_handle_line( char *line); size_t config_dumpglobals(char *out, size_t outsize); size_t config_dumpstring(int string, char *out, size_t outsize); char *config_midi_note_to_string(int string); +void config_reverse_strings(); -- cgit v1.2.3