mirror of
git://projects.qi-hardware.com/wernermisc.git
synced 2024-12-19 05:04:59 +02:00
midi2osc: new option -d (debug) to print MIDI messages we receive
This commit is contained in:
parent
448e02f771
commit
571af6d11f
@ -21,6 +21,9 @@
|
||||
#define NAME "midi2osc"
|
||||
|
||||
|
||||
static int debug = 0;
|
||||
|
||||
|
||||
static void forward(snd_seq_t *midi, lo_address osc)
|
||||
{
|
||||
snd_seq_event_t *ev;
|
||||
@ -37,6 +40,9 @@ static void forward(snd_seq_t *midi, lo_address osc)
|
||||
msg[1] = 0xb0 | ev->data.control.channel;
|
||||
msg[2] = ev->data.control.param;
|
||||
msg[3] = ev->data.control.value;
|
||||
if (debug)
|
||||
fprintf(stderr, "CC(%u) %u %u\n",
|
||||
ev->data.control.channel, msg[2], msg[3]);
|
||||
break;
|
||||
case SND_SEQ_EVENT_PITCHBEND:
|
||||
msg[1] = 0xe0 | ev->data.control.channel;
|
||||
@ -57,7 +63,10 @@ static void forward(snd_seq_t *midi, lo_address osc)
|
||||
|
||||
static void usage(const char *name)
|
||||
{
|
||||
fprintf(stderr, "usage: %s hostname [port]\n", name);
|
||||
fprintf(stderr,
|
||||
"usage: %s hostname [-d] [port]\n\n"
|
||||
" -d debug mode: print all MIDI messages\n",
|
||||
name);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@ -67,20 +76,31 @@ int main(int argc, char **argv)
|
||||
const char *port = "4444"; /* Milkymist One OSC port */
|
||||
lo_address osc;
|
||||
snd_seq_t *midi;
|
||||
int c;
|
||||
|
||||
switch (argc) {
|
||||
case 2:
|
||||
|
||||
while ((c = getopt(argc, argv, "d")) != EOF)
|
||||
switch (c) {
|
||||
case 'd':
|
||||
debug = 1;
|
||||
break;
|
||||
default:
|
||||
usage(*argv);
|
||||
}
|
||||
|
||||
switch (argc-optind) {
|
||||
case 1:
|
||||
break;
|
||||
case 3:
|
||||
port = argv[2];
|
||||
case 2:
|
||||
port = argv[optind+1];
|
||||
break;
|
||||
default:
|
||||
usage(*argv);
|
||||
}
|
||||
|
||||
osc = lo_address_new(argv[1], port);
|
||||
osc = lo_address_new(argv[optind], port);
|
||||
if (!osc) {
|
||||
fprintf(stderr, "invalid address %s %s\n", argv[1], port);
|
||||
fprintf(stderr, "invalid address %s %s\n", argv[optind], port);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user