|
||
Title: Receiving Sysex Post by RickRepsher on Jun 20th, 2005, 7:01am I am trying to receive sysex data from a Nord Lead. So far sending messages is not a problem. This is the vba code I have been working with, but I always get a null back from the midiox instance. ' Global declaration Dim WithEvents MWire As MIDIOXLib.MoxScript Sub GetSysEx Dim strMsg As String Dim vStatus As Variant Dim strData As String MWire.FireMidiInput = 1 ' Sysex to tell Nord to send patch data strMsg = "F0 33 7F 09 30 04 00 F7" MWire.SendSysExString strMsg strMsg = MWire.GetMidiInputRaw() vStatus = strMsg And &HF0 If vStatus = &HF0 Then strData = MWire.GetSysExInput() End If If strData <> "" Then ConvertStringToByteArray strData Else MsgBox "NoData!" End If End Sub |
||
Title: Re: Receiving Sysex Post by Jamie OConnell on Jun 20th, 2005, 11:45am I think with 'FireMidiInput' and 'WithEvents' you need to write a connection point sink routine. In any case for polling, you'll have to implement a Loop: the MIDI input data will not be immediately available, and you'll have to keep checking until it is, and keep checking until you get all of it. This is why the example code has a loop that is only terminated by the user. |
||
Title: Re: Receiving Sysex Post by RickRepsher on Jun 21st, 2005, 7:05am ????? Which example code? I have gone through the documentation looking for just such an example. Personally, I would have thought that this is a question asked all the time, and something that would have been included in the docs. Thanks, Rick |
||
Title: Re: Receiving Sysex Post by Jamie OConnell on Jun 22nd, 2005, 3:03am Installed with MIDI-OX are several Windows Script Host examples. They are in the WSH folder below the MIDIOX install folder (default: C:\Program Files\MIDIOX\WSH). Here is the VB polling example: ' MIDIOX Test option explicit dim mox dim str, strWrk dim n, ii, nInst dim bGo dim chan, stat, dat1, dat2 dim msg, msgstr, strSysEx dim A ' Wsh version Str = Wscript.Name & " ver. " & Wscript.Version MsgBox str ' Create object Set mox = WScript.CreateObject("Midiox.MoxScript.1") str = "MIDI-OX" n = mox.InstanceNumber If n > 0 Then str = str & ":" & CStr( n ) Else MsgBox "No Instances" End If str = str & " " & mox.GetAppVersion str = str & " of " & mox.InstanceCount MsgBox str ' *** Try out our MIDI Input loop mox.FireMidiInput = 0 str = "Enter MIDI Input Loop?" & vbCrLf & "(Exit Script from MIDI-OX)" If vbYes = MsgBox( str, vbYesNo + vbQuestion, "MIDI Notes" ) Then If vbYes = MsgBox( "Divert MIDI Input?", vbYesNo + vbQuestion, "MIDI Notes" ) Then mox.DivertMidiInput = 1 Else mox.DivertMidiInput = 0 End If Do While mox.ShouldExitScript = 0 ' First try raw Input msg = mox.GetMidiInputRaw() If msg <> 0 Then stat = msg And &h000000FF If (stat = &hF0) Then ' SysEx, must ask for SysEx string message strSysEx = mox.GetSysExInput() mox.SendSysExString strSysEx Else msg = msg \ 256 ' pull off stat dat1 = msg And &h0000007F msg = msg \ 256 dat2 = msg And &h0000007F mox.OutputMidiMsg -1, stat, dat1, dat2 End If End If ' Now try the string format msgStr = mox.GetMidiInput() If msgStr <> "" Then A = Split( msgStr, ",", -1, vbTextCompare ) stat = Int(A(2)) If (stat = &hF0) Then ' SysEx, must ask for SysEx string message strSysEx = mox.GetSysExInput() mox.SendSysExString strSysEx Else dat1 = Int(A(3)) dat2 = Int(A(4)) mox.OutputMidiMsg -1, stat, dat1, dat2 End If End If Loop mox.DivertMidiInput = 0 End If MsgBox "End Demo" Set str = nothing Set strWrk = nothing Set mox = nothing ' Exit Point '------------------------------------------ |
||
Title: Re: Receiving Sysex Post by RickRepsher on Jun 22nd, 2005, 6:50am Jamie, Ok, I didn't see the examples, only the documentation. I still have a couple of questions. 1) Where is the loop "terminated by the user"? 2) In the following code: strSysEx = mox.GetSysExInput() mox.SendSysExString strSysEx Is strSysEx the entire message, or just one byte? Are you resending the message and if so, why. Just for the example? Thanks again Rick |
||
Title: Re: Receiving Sysex Post by Jamie OConnell on Jun 22nd, 2005, 5:16pm 1) The loop starts here: . . . str = "Enter MIDI Input Loop?" & vbCrLf & "(Exit Script from MIDI-OX)" If vbYes = MsgBox( str, vbYesNo + vbQuestion, "MIDI Notes" ) Then If vbYes = MsgBox( "Divert MIDI Input?", vbYesNo + vbQuestion, "MIDI Notes" ) Then mox.DivertMidiInput = 1 Else mox.DivertMidiInput = 0 End If Do While mox.ShouldExitScript = 0 ' First try raw Input . . . 2) It is the entire message received so far. It is sent just as an example, although you might want to echo it anyway, especially if it's not something you want to handle. |
||
Title: Re: Receiving Sysex Post by RickRepsher on Jun 23rd, 2005, 8:54am I obviously still don't understand what is supposed to be happening here. If I open MidiOx in the "stand alone mode" and go to the sysex view, and enter the following string in the sysex view command window F0 33 7F 09 31 00 00 F7 and then do a send/receive, I get data back in the display window (data that I would expect to see.) But... If I run the following piece of code (which is pretty much copied from the example), I get the following values as I step through the procedure. strMsg = "0, 240, 0, 0, 0" lngStstus = 0 After multiple loops through, there are only null values in those variables, and we have never seen an &HF0, although the "stand alone" method definitly returns one (in the first byte.) I DO have an &HF0 in arr_strTemp(1) (zero based...) Code:
|
||
Title: Re: Receiving Sysex Post by Jamie OConnell on Jun 25th, 2005, 12:33pm I wouldn't be surprised if single-stepping through would affect the results as you're probably missing input that way. You might try the Connection point sink model, which gets triggered when there is data to collect. Again though, single-stepping through a real-time MIDI program may drop or skip data. Instead, you might want to put in some kind of TRACE or reporting statements to see what's happening. The 'sink' example is in MOXScriptDemo.vbs. |
||
Title: Re: Receiving Sysex Post by RickRepsher on Jun 29th, 2005, 11:52am Jamie, First off, thanks for all the help so far. I have done some VBS and VBA programming, but my issues have been how I need to interact with the MIDIOX com model. With that said... when I looked at the status message and noticed that I had an $HF0 in the second byte, I changed my code to this: lngStatus = Int(arr_strTemp(1)) Being zero based, I got the correct status message, and I was able to grab the incoming sysex data. Everything is smooth as silk... Now I just need to play some more to get the feel of the rest of the model. Thanks again. RR |
||
MIDI-OX User Forum » Powered by YaBB 1 Gold - SP 1.3.1! YaBB © 2000-2003. All Rights Reserved. |