I guess a few comments would have helped here. The code receives 4 bytes
of sysex at a time, and it must scan the data one byte at a time until the
end-of-sysex is reached. (Every MIDI API must do something about the fact
that Sysex messages are arbitrarily long.) This particular program is a
test that compares the incoming sysex to the outgoing sysex. If there is a
difference, the location of the error is recorded (and I think it's
reported after the full message is received). -Roger
> 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.
> _______________________________________________
> media_api mailing list
> [email protected]
> http://www.create.ucsb.edu/mailman/listinfo/media_api
>
>
_______________________________________________
media_api mailing list
[email protected]
http://www.create.ucsb.edu/mailman/listinfo/media_api