On Thu, Dec 27, 2012 at 08:15:32PM -0800, I wrote:
> hfmanson wrote
> > > I've developed a ipMidi plugin for csound, so you can use it as a
> > > network synth.
> I'll have to check that it compiles in Haiku and see if I can do anything with it.
Well, I built it in Haiku without trouble, and tested to the point of
actually sending any MIDI to it. (I have no available transmitter, though
I'll see what I can do with netcat later.) Everything works so far, but
there are a couple of points arising:
To compile it at all in Haiku, I had to remove the check for Linux/Windows
in SConstruct's "useIpMidi" test. It seems to me that those checks are
unnecessary anyway. Just don't include the option if your OS can't handle it.
If it's not compatible and you do include it, the module probably won't compile,
so you'd know pretty quickly.
With the library compiled and installed, I ran a simple test
(where the data files are minimal test ones I was using for Haiku):
csound -+rtmidi=ipmidi midi.orc midi.sco
On exit there was always a segfault! I soon realized that, even
though ipmidi has no choice of device, you have to specify a '-M'
option, otherwise the open-device function is never called; the
close function always *is*, though, and gets a null pointer. (Haiku
is fussy about trying to use a null pointer -- maybe it slips through
on other systems?)
It does seem that it might be confusing to a user to have to use '-M',
but I don't see that much can be done about that. It shouldn't segfault
though, so I put in a check for a null pointer at that point.
The diff of the changes I made is below, as it's so short.
-- Pete --
--- csound5/SConstruct 2012-12-07 16:12:21.000000000 -0800
+++ csound_ipmidi/SConstruct 2012-12-28 17:52:15.367788032 -0800
@@ -1980,7 +1980,7 @@
print 'CONFIGURATION DECISION: Not building with PortMIDI.'
-if commonEnvironment['useIpMIDI'] == '1' and (getPlatform() == 'linux' or getPlatform() == 'win32'):
+if commonEnvironment['useIpMIDI'] == '1':
print 'CONFIGURATION DECISION: Building with ipMIDI.'
ipMidiEnvironment = pluginEnvironment.Clone()
if getPlatform() == 'win32':
--- csound5/InOut/ipmidi.c 2012-12-07 16:12:10.127401984 -0800
+++ csound_ipmidi/InOut/ipmidi.c 2012-12-28 12:49:20.150732800 -0800
@@ -140,7 +140,9 @@
static int CloseMidiInDevice_(CSOUND *csound, void *userData)
- int sock = *((int *) userData);
+ int sock;
+ if (!userData) return 0; /*never opened */
+ sock = *((int *) userData);