MIDI-OX User Forum (http://www.midiox.com/cgi-bin/yabb/YaBB.pl)
MIDI-OX >> Scripting Questions >> Windows Scripting Host on win2000?
(Message started by: Dimitri on Aug 13th, 2002, 9:57pm)

Title: Windows Scripting Host on win2000?
Post by Dimitri on Aug 13th, 2002, 9:57pm
First of all I would like to thank you for your super app MidiOX. I use it as a midipatcher/filter to control my synths and secuencers from internal and external midi sources. And it works great, even for live performances.

But, as a programmer, I am also very interested in the MidiOX COM interface. I would like to write my own arpeggiator using WSH/Javascript. But in all the scripts I tested I couldn't receive any midi data from the COM object. I could send midi data, query devices, etc, but the functions GetMidiInput() and GetMidiInputRaw() never return any receiving data I see in the Input Monitor and Port Activity Window.

I run Windows 2000-SP3, with a Unitor 8, WHS 5.6. I use the following JS-script for testing:


function Mox_OnMidiInput( t, s, c, d1, d2 ) {
     WScript.Echo( t+","+s+","+c+","+d1+","+d2);
}

var Mox = WScript.CreateObject("MIDIOX.MOXScript.1","Mox_On");

Mox.ShutdownAtEnd = 1;

var msg = "";

var dev = Mox.GetFirstOpenMidiInDev();
while( dev ) {
     msg += "Input "+Mox.GetInPortID(dev)+": "+dev+"\n";
     dev = Mox.GetNextOpenMidiInDev();
}

dev = Mox.GetFirstOpenMidiOutDev();
while( dev ) {
     msg += "Output "+Mox.GetOutPortID(dev)+": "+dev+"\n";
     dev = Mox.GetNextOpenMidiOutDev();
}

WScript.Echo(msg);

Mox.FireMidiInput = 1;
Mox.DivertMidiInput = 1;


while( !Mox.ShouldExitScript ) {

     msg = Mox.GetMidiInputRaw();

     if( msg ) {
           WScript.Echo(msg);
     } else {
           Mox.sleep(100);
           Mox.OutputMidiMsg( -1, 146, 78, 127);
     }
}

WScript.Quit();


It gives the following output:


Input 3: Un In 03 (From MC 505)
Input 4: Un In 04 (From AN1X)
....
Output 2: Un Out 01 (To Elect-R)
Output 3: Un Out 02 (To Rs7000)
...


So that part works fine. But I never receive any Midi Data. Do you have a clue? Maybe some functions are known not to work on win2000? Maybe WSH/Javascript is the problem?

Title: Re: Windows Scripting Host on win2000?
Post by Jamie OConnell on Aug 14th, 2002, 1:22am
I was able to run your script under Windows XP, and I got the Mox_OnMidiInput() routine to fire, but I had to comment out the "msg = Mox.GetMidiInputRaw();", because it was masking the MidiInput() messages:


 ...
 while( !Mox.ShouldExitScript ) {

  msg = 0; // Mox.GetMidiInputRaw();

  if( msg ) {
    WScript.Echo(msg);
  } else {
  Mox.sleep(100);
  // Mox.OutputMidiMsg( -1, 146, 78, 127);
 }
 ...


If you're not getting any MIDI input, try re-registering the app.  Go to the MIDI-OX folder and type:

MIDIOX.EXE /RegServer

You have to change to the app folder because of a command line processing bug (fixed in next release).

Title: Re: Windows Scripting Host on win2000?
Post by Dimitri on Aug 20th, 2002, 6:43pm
Thanx for you help, it works now :) But I noticed something strange using filters in the filter dialog. When I place a checkmark on a channel and do not place any checkmark on a filter type (note on/off, etc) all midi data on that channel will be received in the input-screen as expected, but will not be send to the listening WSH script. (That is also a reason why I didn't receive any data)

This means that I can not use any realtime filtering in combination with an active WSH script, doesn't it? :'( Is there a work around or maybe I do something wrong. I think a WSH script will not be fast enough to do all the filtering on 8 ports itself using 'DivertMidiInput'. I didn't check if data-mapping has the same 'blocking effect' for WSH scripts.

Dimitri

Title: Re: Windows Scripting Host on win2000?
Post by Jamie OConnell on Aug 20th, 2002, 8:01pm
When you place a checkmark on a Channel in the filter, you are specifying that ALL data on the channel be filtered, and no data is passed to the Script or the Output.  You CAN use real-time filtering of input data before it is passed to the script. Only check channels that you want Filtered not the ones that you want passed.



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