[Media_api] Receiving sysex using Python port of Portmidi (pyPortmidi)

Tony Cappellini cappy2112 at gmail.com
Mon Sep 3 23:59:12 PDT 2007


Does anyone here use the Python port of Portmidi?

I'm trying to translate the loop for receiving sysex from the sysex.c
file into Python-
but I'm stuck

        while (data != MIDI_EOX && start_time + 2000 > Pt_Time()) {
            count = Pm_Read(midi_in, &event, 1);
            if (count == 0) {
                Sleep(1); /* be nice: give some CPU time to the system */
                continue; /* continue polling for input */
            }

            /* printf("read %lx ", event.message);
               fflush(stdout); */

            /* compare 4 bytes of data until you reach an eox */
            for (shift = 0; shift < 32 && (data != MIDI_EOX); shift += 8) {
                data = (event.message >> shift) & 0xFF;
                if (data != msg[i] && error_position < 0) {
                    error_position = i;
                    expected = msg[i];
                    actual = data;
                }
                i++;
            }
        }

I don't understand why all the shifting is going on, and the part
about error_position.

The developer of pyportmidi hasn't maintained it since 2005.


More information about the media_api mailing list