LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Tuning Experimental Apparatus with a Midi Mixer / Sending MIDI SysEx Messages

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.
0 Kudos
Message 1 of 9
(5,304 Views)
Attachment missing? Let's try this again.
0 Kudos
Message 2 of 9
(5,301 Views)

Thank you so much for solving this problem with sending sysex commands to a midi device.  Unfortunately, I can not open these VI's because I have LV 8.2 and they were written in LV 8.5.  LV will not allow anyone to open a VI written in a newer version with a lower version even if the VI could run just fine on the lower version.  If anyone who has LV 8.5 will help me by opening these VI's and saving them as a previous version I would be very greatful.  It will save me from having to buy an upgrade just to use these VI's.

Thanks

Ken 

0 Kudos
Message 3 of 9
(5,092 Views)
thanks for taking interest in this. I've saved the .llb for 8.2 and was able to open it using 8.2.1. When opening one of those VIs, LabVIEW will search for mididll.dll which is also included in the zip file.
0 Kudos
Message 4 of 9
(5,063 Views)

WildEnte,

Thank you so much.  They opened just fine.  I will spend some time soon trying to program my midi sound device.  Hopefully it will come together smoothly.

 

Thanks,

Ken

0 Kudos
Message 5 of 9
(5,051 Views)
WildEnte,
 
I was successful at sending sysex commands to my midi device using your VI's.  Thanks! I got the midi in to work for short type messages like note on and off but not for sysex messages, as you said, you didn't write the code to do that.  For my application I do not really need to do a read of sysex messages but I need to send some really complex sysex messages and the manual explaining how to do it is very confusing.  My midi device will transmit most of the sysex messages it can receive.  If I could read sysex messages in I could set the device up manually, transmit the sysex settings and I would have exactly the codes I need, making the problem real easy to solve.  I will figure it all out eventually.
 
Thanks,
Ken
0 Kudos
Message 6 of 9
(5,024 Views)
Hi Ken,

good to know that the stuff I did add works for you.

If it's not necessary for you to read the sysex within LabView, you can read sysex messages from the device using some other programs if that'd help you.

See the links at the bottom of the german wikipedia site http://de.wikipedia.org/wiki/Sysex
0 Kudos
Message 7 of 9
(4,993 Views)

MIDI-OX has an ActiveX interface wich makes it very simple to send/receive SysEx and monitor the MIDI data. You might get a look at this pretty flexible application, when dealing with MIDI in general.

 

Regards

Ebbe

0 Kudos
Message 8 of 9
(4,674 Views)

Seems that the incredibly helpful site I linked to has moved since. Check out http://www.blitter.com/~russtopia/MIDI/~jglatt/tech/lowmidi.htm - I can't seem to edit my original post to change the link right there.

0 Kudos
Message 9 of 9
(4,133 Views)