This post is not a question but rather a wrap up of LabVIEW work I have done that I think may be interesting to other people, too. The top half motivates the second half, where I explain how MIDI SysEx messages can be sent through LabVIEW, which up till now has not been a simple feat.
The reason I looked into using LabVIEW with a MIDI device is not motivated by music, but by an experimental physics apparatus that I need to control in our lab. Given that LabVIEW is really good for device control, I think this may be of interest for other users of this forum, too.
--- Tuning an apparatus with a MIDI Mixer
For tuning my apparatus, I have a plentitude of different power supplies to control, which is indeed fairly straightforward with LabVIEW. However, through the front panel of my LabVIEW application I can change values only with mouse and keyboard, and the "finger feeling" that comes with experience of tuning potentiometers is largely gone.
Entrance the MIDI Mixer. The particular device I use (Frontier Design AlphaTrack, and no, I'm in no way related to that company) has three digital endless (!) encoders that I use as potentiometer-replacements, it has a volume fader slider that I use for adjusting how much my device values change when I turn an encoder, and it has plenty of buttons that I use to assign the different encoders to whatever device that I want to control. It is particularly useful when two devices need to be tuned simultaneously, because I can assign any two of the encoders to those two devices and then turn the encoders with both of my hands at the same time. This is simply impossible with mouse/keyboard on a LabVIEW front panel.
--- MIDI SysEx messages through LabVIEW
The Midi Mixer communicates with the computer through MIDI messages, and most of the problems related to that have been solved in the tutorial
Midi Throughput. With the help of the library mididll.dll attached to that tutorial it was straightforward to get the encoders and buttons of the MIDI mixer working with LabVIEW. What was missing was the possibility to write to the Midi Mixer's display, which is done through so-called MIDI SysEx messages. The problem here lies in the fact that the actual dll doing all the MIDI communication on Windows, winmm.dll, wants the SysEx message passed as char pointer within a struct which itself is passed as a pointer to the corresponding DLL functions. As discussed in
another thread, this is next to impossible from LabVIEW.
I have added the function MIDIOutSysEx(HMIDIOUT hmidiout, char *SysEx, unsigned int length) to the Midi Throughput's original mididll.dll, and LabVIEW communicates with this dll instead of Windows' own winmm.dll. In the LabVIEW code I prepare only the Midi SysEx message itself (as a byte array) and pass it to MIDIOutSysEx in the modified mididll.dll. I also pass the byte array's length to avoid any trouble with 0x00 being interpreted as end of the array. Then the MidiOutSysEx function wraps the received byte array into the struct that winmm.dll wants to have and passes it on to winmm.dll. All glory here goes to the author of
this website where I essentially copied the code to do this from.
Changing the dll was fairly easy even without really knowing how to build a DLL that calls a DLL and such because all the required code was already there in the original Midi Throughput Examples. Note that I didn't add anything to RECEIVE SysEx messages, simply because I don't need that for my application. If someone needs to read MIDI SysEx, I advise downloading the fully functional
LabWindows programming environment evaluation version, edit the mididll.prj file in the zip file attached to this post with a text editor to adjust the file paths to your system, and load it with LabWindows. If you do that, you're immediately at the point where I'm leaving this topic now. Please find all relevant files attached to this post, including LabVIEW example code, namely how to communicate with the AlphaTrack Midi Mixer.
I thought some of this might be interesting to somebody out there.