MIDI-OX User Forum (http://www.midiox.com/cgi-bin/yabb/YaBB.pl)
MIDI-OX >> Scripting Questions >> Sysex Processing in VBScript
(Message started by: abhunkin on Feb 9th, 2007, 7:13pm)

Title: Sysex Processing in VBScript
Post by abhunkin on Feb 9th, 2007, 7:13pm
I need to process some 6-byte sysex messages in a vbscript. These messages are scattered in with normal MIDI messages.

A typical sysex message: 240 127 0 6 5 247.

I'm interested only in the fifth byte (here, 5), and will do conditional things based on its value. Is this appropriate code?

dim msg, val(5), switch

Sub Sink_SysExInput(strSysEx)
 msg = strSysEx
 val = Split(msg, ",", 6, vbTestCompare)
 switch = Int(val(5))
 If switch = 5 Then
   etc.

I'd like to stay with the sink method if possible, as my normal MIDI subroutine is also of that type.

All suggestions most appreciated.

Title: Re: Sysex Processing in VBScript
Post by Jerry Jorgenrud on Feb 10th, 2007, 12:00pm
dim A
Sub Sink_SysExInput( strSysEx )
  A = Split(strSysex," ", 6, vbTextCompare)
  select case A(4)
     case "05"
        msgbox "The fifth element is 5"
     case "04"
        msgbox "The fifth element is 4"
     case "03"
        msgbox "The fifth element is 3"
     case Else
        msgbox "Unused number: " & A(4)
  end select
End Sub

Title: Re: Sysex Processing in VBScript
Post by abhunkin on Feb 11th, 2007, 7:55pm
Thanks very much for your revised example, Jerry. It is most helpful.

I've three quick followups:

1) In your example above with Case "05", is the value in hex? In other words, would:
 Case "20"
be looking for 32dec?

2) I notice in MOXScriptPoll.vbs, the separator character in Split is given as "," whereas you list " ". Are both OK, or does the context in our example require " "?

3) I want to sort out 6-byte sysex messages from any others, and only deal with them. Would the best way be:
 If Len(strSysEx) = 17 Then
or would it be better to test:
 If A(5) = 247 Then
or are both methods OK?

I really appreciate the expert advice. Unfortunately, I'm flying blind here, unable to experiment/test myself the code.

Title: Re: Sysex Processing in VBScript
Post by Jerry Jorgenrud on Feb 12th, 2007, 6:45am
1) In your example above with Case "05", is the value in hex?

Yes, that's the way you're going to get it.

2) I notice in MOXScriptPoll.vbs, the separator character in Split is given as "," whereas you list " ". Are both OK, or does the context in our example require " "?

Sysex bytes are separated by spaces. It's the regular MIDI messages that are separated by commas. So you have to use spaces.

3) "are both methods OK?"

I suppose I would probably go with the length, which would protect you from one that was too short as well. If you use the other method, the value to test for won't be in decimal it will be "F7".

Title: Re: Sysex Processing in VBScript
Post by abhunkin on Feb 12th, 2007, 3:32pm
Gotcha.

Thanks so much for the guidance, Jerry. (I'm glad to see I was pretty much on track.)

It shouldn't be too long before I can announce here a package of scripts that convert a range of MIDI controllers to a Mackie Control Universal emulation.

The particular issue under discussion here is some sysex generated by the Tascam TM-D1000 (transport and rec arm messages) that needs to be converted to appropriate MCU output.



MIDI-OX User Forum » Powered by YaBB 1 Gold - SP 1.3.1!
YaBB © 2000-2003. All Rights Reserved.