How should my program collect MIDI messages?
October 13, 2007 6:11 PM Subscribe
Where can I find enough info on Windows' MIDI API to start using it?
I have a Behringer controller with a "USB MIDI" interface (a USB cable goes straight from the box to the computer). I want to catch the messages sent from this unit in a Matlab program. There should be built-in support for this in Windows, but I don't find much documentation about it. Can someone please explain to me what DLL or ActiveX element to load, how to create a session, what functions to call and all the other details needed to see some MIDI messages on the screen?
I have a Behringer controller with a "USB MIDI" interface (a USB cable goes straight from the box to the computer). I want to catch the messages sent from this unit in a Matlab program. There should be built-in support for this in Windows, but I don't find much documentation about it. Can someone please explain to me what DLL or ActiveX element to load, how to create a session, what functions to call and all the other details needed to see some MIDI messages on the screen?
Response by poster: teraflop: With the basic DLL support, a native Matlab callback would likely be at least very hard to implement. The easiest thing for me would be a dll function that returns with the message as soon as it has arrived. Any recommendations for a wrapper that can do something like this?
posted by springload at 4:21 AM on October 14, 2007
posted by springload at 4:21 AM on October 14, 2007
Do you need to do this in realtime? If not, you could use any freeware midi-recording software to capture a .mid file. Then you can either parse the file in Matlab, or use a utility like MIDICSV or MIDI-Perl to convert the data to something easier for Matlab to read.
posted by moonmilk at 7:07 AM on October 14, 2007
posted by moonmilk at 7:07 AM on October 14, 2007
A quick googling for matlab midi brough up the Matlab Midi Toolbox .. might be worth looking into.
I'm not too familiar with matlab and what it supports, but C#/.NET is probably the easiest way to get started. seems fairly robust.
If you are ever working with MIDI, jglatt's resource center should be your #1 bookmark.
posted by cmicali at 7:08 AM on October 14, 2007
I'm not too familiar with matlab and what it supports, but C#/.NET is probably the easiest way to get started. seems fairly robust.
If you are ever working with MIDI, jglatt's resource center should be your #1 bookmark.
posted by cmicali at 7:08 AM on October 14, 2007
Response by poster: moonmilk: Unfortunately, this has to be done in realtime, message by message.
cmicali: I've snoped around jglatt's site, and it contains some nice information. .NET components can be accessed from Matlab, though I'm not sure how to go about it. A solution like that is one option, accessing winmm.dll from a MEX file (Matlab's C interface) is another one. Again, details and alternatives are most welcome - I'm very inexperienced with API interfacing.
posted by springload at 8:13 AM on October 14, 2007
cmicali: I've snoped around jglatt's site, and it contains some nice information. .NET components can be accessed from Matlab, though I'm not sure how to go about it. A solution like that is one option, accessing winmm.dll from a MEX file (Matlab's C interface) is another one. Again, details and alternatives are most welcome - I'm very inexperienced with API interfacing.
posted by springload at 8:13 AM on October 14, 2007
Response by poster: Another possibility: Matlab can quite easily use Java classes. JavaSound seems to have useful MIDI functions, but I don't know where to find it. I tried to install a recent Java SDK, but I still can't find it. Should I look for a jar file with a different name?
posted by springload at 2:32 PM on October 14, 2007
posted by springload at 2:32 PM on October 14, 2007
I wrote some code 8 years ago to made the MIDI APIs available to Java on the PC. If you want, I'll dig out the source code for you. I never did any code for input, but if I recall correctly, the input routines are in the same family/region as the output routines.
posted by plinth at 6:32 AM on October 15, 2007
posted by plinth at 6:32 AM on October 15, 2007
Response by poster: For the record: I ended up using the COM interface of MIXI-OX. Thanks for the advice, everybody.
posted by springload at 2:31 PM on October 16, 2007
posted by springload at 2:31 PM on October 16, 2007
This thread is closed to new comments.
I don't know how easy that will be to interface with Matlab, though; does it even support event-driven programming?
posted by teraflop at 6:38 PM on October 13, 2007