I'm working with Leslie Sanford's excellent C# MIDI library and I'd
really like to get things working in IronPython. Here's the incredibly
simple code (in C#) required to connect to an input device and call a
delegate when a ChannelMessage is received.
InputDevice device = new InputDevice(0);
device.Connect(delegate(ChannelMessage message)
{
Console.WriteLine("Command: " + message.Command.ToString());
});
The InputDevice.Connect method has several overloads, so trying a
straight function doesn't work, as you can see from this output:
>>> from music import *
>>> def fn(msg):
... print 'Command: ' + msg.Command.ToString()
...
>>> i = InputDevice(0)
>>> i.Connect(fn)
Traceback (most recent call last):
File , line 0, in <stdin>##33
TypeError: multiple overloads of Connect could match (InputDevice,
function)
Connect(InputDevice, Sink[ChannelMessage])
Connect(InputDevice, Sink[SysExMessage])
Connect(InputDevice, Sink[SysCommonMessage])
Connect(InputDevice, Sink[SysRealtimeMessage])
Connect(InputDevice, Sink[int])
Connect(InputDevice, Sink[Array[Byte]])
A "Sink" is defined as:
public delegate void Sink<T>(T arg)
So is there any way to make this work? Thanks for any help you can
provide.
james
_______________________________________________
users mailing list
[email protected]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com