MIDI-OX User Forum (http://www.midiox.com/cgi-bin/yabb/YaBB.pl)
MIDI-OX >> Scripting Questions >> Getting Started in Midi-OX and JScript
(Message started by: audell on May 25th, 2003, 4:25pm)

Title: Getting Started in Midi-OX and JScript
Post by audell on May 25th, 2003, 4:25pm
Hello...

I'm looking to use Midi-OX to a fascilitate the connection of external midi divices with a multimedia authoring package I'm currnently using called Anark Studio (http://www.anark.com).  Anark's scripting environment is completely based on Jscript, so based on what I'm reading, I believe that Midi-OX is the right tool for the Job.

I've been reading through the Midi-OX documentation and also learning JScript at the same time.

I understand that, based on the Midi-OX docs, it may be very easy to translate the concepts from VBscript to Jscript.  However, it has conceptually not been an easy task for me as of yet.

Does anyone here have any background in jscript and Midi-Ox to help baby step me in the right direction?

Thanks....

Alex

Title: Re: Getting Started in Midi-OX and JScript
Post by audell on May 26th, 2003, 6:39pm
Hello again...

okay...so I've made some progress...between the documentation of Midi-OX and the microsoft website refrence on Jscript and the book I've been studying: "JavaScript Your Visual Blueprint for building dynamic web pages"

I was able to come up with the following code frag:

<Script language="JavaScript">

MOX = new ActiveXObject("MIDIOX.MOXScript.1");
version = MOX.GetAppVersion();
middev = MOX.GetFirstSysMidiInDev();

document.write(version+"<br>"+middev);

The Above code  creates a few variables.

MOX - by assgining the 'ActiveXObject' to this variable, it actually creates the new running instance of Midi-Ox.

version - this variable is assigned to return the value of the current running version of Midi-Ox using Midi-Ox's 'built-in' GetAppVersion() method.

middev - this variable returns the value of the first midi input device connected to the system via Midi-Ox's built in GetFirstSysMidiInDev();

the document.write code basically writes the output of the variables to the current browser window.

WOO HOO....okay....so I have a brain...

But still sketchy on interacting with the Midi stream.
My very first idea is to simply write the incoming midi events as strings to the browser window.  I figure if I can make that connection happen...then I can fiure out how to manipulate it after that.

So I understand that the 'GetMidiInput()' is the specific method used to look at the incoming midi stream, however, I'm still not clear as to the supportive or backgournd elements necessary to get to this step.

For example:

The Mid-Ox documentation makes refrence to the VB frag  of:
-----------------------------------------------------
' Create object
Set mox = WScript.CreateObject("MIDIOX.MOXScript.1", "OnTrigger_")


This statement creates an object and tells WScript to generate calls to a method named OnTrigger_MidiInput(). System Exclusive data will trigger an OnTrigger_SysExInput(). You create a subroutine in your script with that name to receive MIDI data. "

------------------------------------------
But I'm just not sure how this translates to Jscript.
Sure I could assign the OnTrigger_MidiInput() to a variable...but what would I do with it?  I'm thinking that this is going to be a function in jscript but I don't understand how to define it in relation to my original Midi-OX object...


Also the following:

----------------------------

"Data will not actually start flowing until you set the FireMidiInput property."

------------------
So I assume I need a statement in the script that sets this value to 1 like:

MOX.FireMidiInput = 1

I know I'm very close here....I see all these small pieces...I just am not quite clear on how they go together in Jscript to make this happen.....

If anyone has any insight it would be much appreciated.

Thanks again,

Alex

Title: Re: Getting Started in Midi-OX and JScript
Post by Jamie OConnell on May 28th, 2003, 11:35am
There is a JavaScript (Windows Script Host) sample that is installed with MIDI-OX.  Look in the WSH folder under MIDIOX for Breath2NRPN.js.  It demonstrates using connection point sinks, and should work right out of the box.

Title: Re: Getting Started in Midi-OX and JScript
Post by audell on May 28th, 2003, 11:42am
Jamie...

of course it would be right in front of my face. ::)

I'll take a look!

Thanks...

Alex

Title: Re: Getting Started in Midi-OX and JScript
Post by audell on Jun 19th, 2003, 11:28am
Hi Jamie and all...

OK, I'm guessing I need to be a bit more clear.

I'll need to access Midi-OX from Internet Explorer.

According to other sources WSH and Internet Explorer treat Jscript a bit differently.  By default Wscript is 'Undefined' when accessed from IE.

Can you help me with some fundamental ground work to launch Midi-OX from IE so I can gather the incoming midi stream and parse the data?

I'll assume it's better to keep the actual Midi OX script as an external document so I can resue it from different HTML docs in a modular 'Object' fashion.

Thanks....sorry for being such a newbie to all of this.  But only thru this am I getting a much clearer picture of the direction I need to go.

Alex Udell

Title: Re: Getting Started in Midi-OX and JScript
Post by audell on Jun 22nd, 2003, 12:22pm
OK....Shifting basic concept here....

The structure as I've been thinking about it is that I have wanted to centralize the structure of the code around the HTML document.

However, the more I think about it, in my scenario the HTML document is really only an Output window.

So perhaps I should structure this as a standard jscript document which is responsible for laubnching MIDI OX, parsing the stream and sending it out to the HTML doc....

Does this sound right?

Thanks,

Alex

Title: Re: Getting Started in Midi-OX and JScript
Post by Jamie OConnell on Jun 22nd, 2003, 4:02pm
Truthfully, I have no experience trying to use MIDI-OX scripting with I.E. or any other browser.  Assuming that they have methods for creating objects, there should be a similar mechanism available as there is in WSH.  It could be that connection point sinks are not available, in which case you'd have to use the polling method to obtain input.

Your last message sounded correct from a theoretical soundpoint.

Title: Re: Getting Started in Midi-OX and JScript
Post by Peter L Jones on Jun 23rd, 2003, 6:00pm
I think (I dabbled with WSH/IE/JScript ages ago, so I may misremember) that there's an OCX control for WSH that you need to embed in an HTML document (<OBJECT> tag?).  I never got it to work but I didn't try very hard.

You should always treat the web page as no more (and no less) than a fancy dumb terminal.  Your core program structure should merely expose methods on objects that any consumer of that service might like to invoke.  Easier said than done, though... :-)

Title: Re: Getting Started in Midi-OX and JScript
Post by pete on Oct 25th, 2003, 8:26am
I want to try and do a similar thing, using IE as a terminal for a sript associated with MIDI OX.
I've been thinking that it might be a good solution to instantiate IE through its automation interface, using the WS.  I'm only just looking into it, but heres a basic script to get IE up and running:


var sProgID = "InternetExplorer.Application";
var objIE = WScript.CreateObject(sProgID, "IE_");
var objDoc;


function IE_DocumentComplete()
{
 with (objIE) {
   AddressBar = false;
   ToolBar = false;
   MenuBar = false;
   StatusBar = false;
   Width = 400;
   Height = 450;
 }

 objIE.Visible = true;

 
 objDoc = objIE.Document;
 objDoc.title = "hello";

 objDoc.open();
 objDoc.write("output info...");
 objDoc.close();
}

objIE.Navigate("about:blank");


// evil hack: prevent race condition.  Must be a better way.
WScript.Sleep(100);




p.s. Thanks for a brilliant App, Jamie


Title: Re: Getting Started in Midi-OX and JScript
Post by pete on Oct 26th, 2003, 10:14am
I've had a go at doing something a little more complicated...

ZoneControl.zip (http://www.bannister25.plus.com/upload/ZoneControl.zip)

Title: Re: Getting Started in Midi-OX and JScript
Post by Jamie OConnell on Oct 26th, 2003, 7:53pm
Thanks for providing a sample.  That may help some folks get going.

Title: Re: Getting Started in Midi-OX and JScript
Post by pete on Nov 2nd, 2003, 2:42pm
:)

Ive updated it a bit, so you can save presets and transpose zones independently.  It's a bit more efficient at communicating from IE to the script running with WSH...

ZoneControl2 (http://www.bannister25.plus.com/upload/ZoneControl2.zip)


Title: Re: Getting Started in Midi-OX and JScript
Post by sveex on Jun 29th, 2005, 1:49am
Found this thread by searching Google for the ability to map keyboard zones in software.  MIDI-OX + Pete's ZoneControl script is pretty much exactly what I was looking for, and the only thing I could find other than a Cakewalk plugin called JamBuddy.  It would be nice if ZoneControl could layer/overlap channels, but this can be accomplished by running multiple instances.

I wish these features existed on more controllers and sequencers.  Does anyone know of any dedicated hardware or software that can zone/layer channels?

Thanks to Pete for the wonderful script.  Looks like it took some time to make.

-Sveex 8)

Title: Re: Getting Started in Midi-OX and JScript
Post by initself on Jan 6th, 2009, 2:01pm
I am having trouble running certain methods shown in the MOXScript API.  Here is my sample code:


Code:
// Jscript MIDI-OX Test

var sMox_ID = "Midiox.MoxScript.1";
var objMOX = WScript.CreateObject(sMox_ID, "OnMOX_");

objMOX_Start();

function objMOX_Start() {
 objMOX.DivertMidiInput = 1;
 objMOX.FireMidiInput = 1;
 var test = objMOX.InstanceNumber;        // works
 var test = objMOX.SysMidiInCount;        // works
 var test = objMOX.GetFirstSysMidiInDev;  // Object doesn't support this property or method
 WScript.Echo(test);
}

function objMOX_Cleanup() {
 objMOX.FireMidiInput = 0;
 objMOX.DivertMidiInput = 0;
 objMOX = null;
}


Why doesn't the GetFirstSysMidiInDev method work in JScript?

Thanks,

mb

Title: Re: Getting Started in Midi-OX and JScript
Post by Jerry Jorgenrud on Jan 7th, 2009, 8:59am
objMOX.GetFirstSysMidiInDev()

Note brackets, used when calling methods ...

Title: Re: Getting Started in Midi-OX and JScript
Post by monkeyboi on Mar 16th, 2010, 3:35pm
Using MSIE as a terminal for WSH scripts doesn't circumvent browser security. I still get nagged to install OCX controls. Windows HTML Application (HTA) Host solves this problem by putting MSIE into a special mode that has the same access to your system as any other Windows app. Simply add the <HTA:APPLICATION> tag to an HTML page and save it as an .hta file.

http://msdn.microsoft.com/en-us/library/ms536496%28VS.85%29.aspx



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