Wednesday, December 29, 2010

multi-platform MIDI library

I tried RtMidi on Windows and OS X 10.6.5 (Snow Leopard). Unfortunately, SysEx messages sent via RtMidi on OS X would only be sent after starting another application that also uses Midi (SysEx Librarian or MIDI Monitor, both from snoize.com). Otherwise, SysEx messages would simply not be sent, while RtMidi would fail reporting any errors. It seems, RtMidi is skipping some CoreMidi initialization.

I followed this advice how to build portmidi using MinGW on WinXP, and it worked:
http://cratel.wichita.edu/cratel/cratel pyportmidi#build_portmidi_.28MinGW.29
It's unfortunate that this Makefile is not distributed with portmidi.

Sending SysEx with portmidi worked on both OS X and WinXP.

As a side note, one of RtMidi's objectives: "object oriented C++ design" fails to really hold. RtMidi defines a abstract root class RtMidi and extends it by RtMidiIn and RtMidiOut. Defining a common super interface for both sending and receiving midi doesn't hold up very well, as the sample program sysextest.cpp exemplifies:

bool chooseMidiPort( RtMidi *rtmidi )
{
bool isInput = false;
if ( typeid( *rtmidi ) == typeid( RtMidiIn ) )
isInput = true;

What good is the RtMidi abstraction if just a few lines further down you break it again?

Furthermore I'd consider it both from an ethical and an engineering point of view a cleaner design to openly use portmidi instead of cannibalizing some of its code (see RtMidi.cpp):

// This function was submitted by Douglas Casey Tucker and apparently
// derived largely from PortMidi.
CFStringRef EndpointName( MIDIEndpointRef endpoint, bool isExternal )

...

// This function was submitted by Douglas Casey Tucker and apparently
// derived largely from PortMidi.
static CFStringRef ConnectedEndpointName( MIDIEndpointRef endpoint )

No comments:

Post a Comment