Date:2011-11-24 04:25:16 (7 years 7 months ago)
Author:Werner Almesberger
Commit:571af6d11fd3d91f1ac2125a1004ebcd4945c1bc
Message:midi2osc: new option -d (debug) to print MIDI messages we receive

Files: midi2osc/midi2osc.c (4 diffs)

Change Details

midi2osc/midi2osc.c
2121#define NAME "midi2osc"
2222
2323
24static int debug = 0;
25
26
2427static void forward(snd_seq_t *midi, lo_address osc)
2528{
2629    snd_seq_event_t *ev;
...... 
3740            msg[1] = 0xb0 | ev->data.control.channel;
3841            msg[2] = ev->data.control.param;
3942            msg[3] = ev->data.control.value;
43            if (debug)
44                fprintf(stderr, "CC(%u) %u %u\n",
45                    ev->data.control.channel, msg[2], msg[3]);
4046            break;
4147        case SND_SEQ_EVENT_PITCHBEND:
4248            msg[1] = 0xe0 | ev->data.control.channel;
...... 
5763
5864static void usage(const char *name)
5965{
60    fprintf(stderr, "usage: %s hostname [port]\n", name);
66    fprintf(stderr,
67"usage: %s hostname [-d] [port]\n\n"
68" -d debug mode: print all MIDI messages\n",
69    name);
6170    exit(1);
6271}
6372
...... 
6776    const char *port = "4444"; /* Milkymist One OSC port */
6877    lo_address osc;
6978    snd_seq_t *midi;
79    int c;
7080
71    switch (argc) {
72    case 2:
81
82    while ((c = getopt(argc, argv, "d")) != EOF)
83        switch (c) {
84        case 'd':
85            debug = 1;
86            break;
87        default:
88            usage(*argv);
89        }
90
91    switch (argc-optind) {
92    case 1:
7393        break;
74    case 3:
75        port = argv[2];
94    case 2:
95        port = argv[optind+1];
7696        break;
7797    default:
7898        usage(*argv);
7999    }
80100
81    osc = lo_address_new(argv[1], port);
101    osc = lo_address_new(argv[optind], port);
82102    if (!osc) {
83        fprintf(stderr, "invalid address %s %s\n", argv[1], port);
103        fprintf(stderr, "invalid address %s %s\n", argv[optind], port);
84104        exit(1);
85105    }
86106

Archive Download the corresponding diff file

Branches:
master



interactive