Add a debugging option for MIDI input (-dm).
This commit is contained in:
parent
1f26194218
commit
eccbb9ce64
|
@ -110,8 +110,15 @@
|
||||||
|
|
||||||
#DEBUG_KEYS
|
#DEBUG_KEYS
|
||||||
|
|
||||||
|
# Finally, the following option prints all MIDI input (with the input port
|
||||||
|
# number in the first, and the actual data value in the last column). This is
|
||||||
|
# useful as a simple MIDI monitor, especially if you want to figure out which
|
||||||
|
# tokens to use in your translations.
|
||||||
|
|
||||||
|
#DEBUG_MIDI
|
||||||
|
|
||||||
# NOTE: The debugging options can also be specified on the command line
|
# NOTE: The debugging options can also be specified on the command line
|
||||||
# using -d in conjunction with any of the letters r, s and k (or the
|
# using -d in conjunction with any of the letters r, s, k and m (or the
|
||||||
# letter j if you also want debugging output from Jack). Just -d
|
# letter j if you also want debugging output from Jack). Just -d
|
||||||
# without any option letter turns on all debugging options.
|
# without any option letter turns on all debugging options.
|
||||||
|
|
||||||
|
|
22
midizap.c
22
midizap.c
|
@ -251,6 +251,21 @@ static char *debug_key(translation *tr, char *name,
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void debug_input(translation *tr, int portno,
|
||||||
|
int status, int chan, int data, int data2)
|
||||||
|
{
|
||||||
|
char name[100];
|
||||||
|
if (status == 0xe0)
|
||||||
|
// translate LSB,MSB to a pitch bend value in the range -8192..8191
|
||||||
|
data2 = ((data2 << 7) | data) - 8192;
|
||||||
|
if (status == 0xc0)
|
||||||
|
printf("[%d] %s\n", portno,
|
||||||
|
debug_key(tr, name, status, chan, data, 0));
|
||||||
|
else
|
||||||
|
printf("[%d] %s value = %d\n", portno,
|
||||||
|
debug_key(tr, name, status, chan, data, 0), data2);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
send_strokes(translation *tr, uint8_t portno, int status, int chan, int data,
|
send_strokes(translation *tr, uint8_t portno, int status, int chan, int data,
|
||||||
int index, int dir)
|
int index, int dir)
|
||||||
|
@ -486,6 +501,7 @@ handle_event(uint8_t *msg, uint8_t portno)
|
||||||
msg[0] = status | chan;
|
msg[0] = status | chan;
|
||||||
msg[2] = 0;
|
msg[2] = 0;
|
||||||
}
|
}
|
||||||
|
if (debug_midi) debug_input(tr, portno, status, chan, msg[1], msg[2]);
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case 0xc0:
|
case 0xc0:
|
||||||
send_strokes(tr, portno, status, chan, msg[1], 0, 0);
|
send_strokes(tr, portno, status, chan, msg[1], 0, 0);
|
||||||
|
@ -647,6 +663,9 @@ main(int argc, char **argv)
|
||||||
case 'k':
|
case 'k':
|
||||||
default_debug_keys = 1;
|
default_debug_keys = 1;
|
||||||
break;
|
break;
|
||||||
|
case 'm':
|
||||||
|
default_debug_midi = 1;
|
||||||
|
break;
|
||||||
case 'j':
|
case 'j':
|
||||||
debug_jack = 1;
|
debug_jack = 1;
|
||||||
break;
|
break;
|
||||||
|
@ -658,7 +677,8 @@ main(int argc, char **argv)
|
||||||
++a;
|
++a;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
default_debug_regex = default_debug_strokes = default_debug_keys = 1;
|
default_debug_regex = default_debug_strokes = default_debug_keys =
|
||||||
|
default_debug_midi = 1;
|
||||||
debug_jack = 1;
|
debug_jack = 1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -89,8 +89,9 @@ extern int read_config_file(void);
|
||||||
extern translation *get_translation(char *win_title, char *win_class);
|
extern translation *get_translation(char *win_title, char *win_class);
|
||||||
extern void print_stroke_sequence(char *name, char *up_or_down, stroke *s);
|
extern void print_stroke_sequence(char *name, char *up_or_down, stroke *s);
|
||||||
extern translation *default_translation, *default_midi_translation[2];
|
extern translation *default_translation, *default_midi_translation[2];
|
||||||
extern int debug_regex, debug_strokes, debug_keys;
|
extern int debug_regex, debug_strokes, debug_keys, debug_midi;
|
||||||
extern int default_debug_regex, default_debug_strokes, default_debug_keys;
|
extern int default_debug_regex, default_debug_strokes, default_debug_keys,
|
||||||
|
default_debug_midi;
|
||||||
extern char *config_file_name;
|
extern char *config_file_name;
|
||||||
extern int enable_jack_output;
|
extern int enable_jack_output;
|
||||||
extern int midi_octave;
|
extern int midi_octave;
|
||||||
|
|
10
readconfig.c
10
readconfig.c
|
@ -190,10 +190,12 @@
|
||||||
int default_debug_regex = 0;
|
int default_debug_regex = 0;
|
||||||
int default_debug_strokes = 0;
|
int default_debug_strokes = 0;
|
||||||
int default_debug_keys = 0;
|
int default_debug_keys = 0;
|
||||||
|
int default_debug_midi = 0;
|
||||||
|
|
||||||
int debug_regex = 0;
|
int debug_regex = 0;
|
||||||
int debug_strokes = 0;
|
int debug_strokes = 0;
|
||||||
int debug_keys = 0;
|
int debug_keys = 0;
|
||||||
|
int debug_midi = 0;
|
||||||
|
|
||||||
int midi_octave = 0;
|
int midi_octave = 0;
|
||||||
|
|
||||||
|
@ -1130,7 +1132,8 @@ read_config_file(void)
|
||||||
}
|
}
|
||||||
if (buf.st_mtime > config_file_modification_time) {
|
if (buf.st_mtime > config_file_modification_time) {
|
||||||
config_file_modification_time = buf.st_mtime;
|
config_file_modification_time = buf.st_mtime;
|
||||||
if (default_debug_regex || default_debug_strokes || default_debug_keys) {
|
if (default_debug_regex || default_debug_strokes || default_debug_keys ||
|
||||||
|
default_debug_midi) {
|
||||||
printf("Loading configuration: %s\n", config_file_name);
|
printf("Loading configuration: %s\n", config_file_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1148,6 +1151,7 @@ read_config_file(void)
|
||||||
debug_regex = default_debug_regex;
|
debug_regex = default_debug_regex;
|
||||||
debug_strokes = default_debug_strokes;
|
debug_strokes = default_debug_strokes;
|
||||||
debug_keys = default_debug_keys;
|
debug_keys = default_debug_keys;
|
||||||
|
debug_midi = default_debug_midi;
|
||||||
midi_octave = 0;
|
midi_octave = 0;
|
||||||
|
|
||||||
while ((line=read_line(f, config_file_name)) != NULL) {
|
while ((line=read_line(f, config_file_name)) != NULL) {
|
||||||
|
@ -1203,6 +1207,10 @@ read_config_file(void)
|
||||||
debug_keys = 1;
|
debug_keys = 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (!strcmp(tok, "DEBUG_MIDI")) {
|
||||||
|
debug_midi = 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (!strncmp(tok, "MIDI_OCTAVE", 11)) {
|
if (!strncmp(tok, "MIDI_OCTAVE", 11)) {
|
||||||
char *a = tok+11;
|
char *a = tok+11;
|
||||||
int k, n;
|
int k, n;
|
||||||
|
|
Loading…
Reference in New Issue