[Media_api] PortMidi for Windows revisions

Roger Dannenberg rbd at cs.cmu.edu
Mon Jan 8 12:15:08 PST 2007


I've just finished major updates to PortMidi for Windows (MME API). 
While trying to figure out why my tests worked, yet others were having 
problems, we discovered a bug in the MIDI Yoke drivers. I added a 
workaround for old drivers, but I see that MIDI Yoke NT driver has 
already been fixed and updated. I also did some experiments and found 
some cases where messages seemed to be dropped when there are few 
buffers (e.g. double buffering may have been a bad idea), so the buffer 
allocation policy has changed. I also discovered that my experiments 
that indicated entire sysex messages must be sent in one buffer were 
flawed -- probably some other bug allowed whole messages to work and 
caused fragmented messages to fail. In any case, it is NOT necessary to 
fit an entire sysex message into a single buffer, which means the 
dynamic buffer reallocation is unnecessary. The new code is smaller and 
simpler in many areas. Because of Fabien Costantini's report on 
real-time problems with sysex, I optimized the sysex routines. 
Previously, sysex was transmitted byte-by-byte in order to simplify the 
complex error checking and parsing, e.g. there might be embedded 
real-time messages among the sysex data, and you need to check for EOX. 
There is now optimized code where the system-dependent layer 
*optionally* passes back a pointer to a buffer to fill, a buffer offset 
address, and a buffer length. The system-independent layer can then copy 
bytes directly to the system-dependent data structure with very little 
overhead. This makes PortMidi sysex code *much* faster, but I didn't 
measure the time spent in the device driver. I also added a "shortcut" 
to optimize copying sysex data from input buffer to the FIFO that 
clients read from. By the way, the new FIFO queue is multi-processor 
safe and non-blocking, even with out-of-order writes, although there are 
still some flags elsewhere in PortMidi that might fail if out-of-order 
writes occur. These are associated with error signalling. Finally, I 
ported my old CMU MIDI Toolkit Midi Monitor program (mm) to PortMidi to 
help with debugging, and it is now in pm_test/mm.c.

I am now checking up on some Mac OS X issues, but if anyone is able to 
test the new Windows code, I'd like to just email you a zip file of the 
current state.

Thanks to Fabien Costantini, Ben Allison, Jamie O'Connell, Oron Cherry, 
Joe Newcomer, and anyone I'm forgetting for help on these Windows issues.

-Roger



More information about the media_api mailing list