Calling MFL.API Abstractions from within Javascript code

Learn about building and using Max for Live devices.
Post Reply
Gravis
Posts: 104
Joined: Sat Jul 28, 2007 4:47 am

Calling MFL.API Abstractions from within Javascript code

Post by Gravis » Sun May 09, 2010 9:54 pm

How do i do this?

So right now i have code that looks like ...

Code: Select all

selected_scene_observer = new LiveAPI(this.patcher, testCallback, "live_set", "view");
selected_scene_observer.property = "selected_scene";
and a little bit later in the file ...

Code: Select all

function testCallback() {
    post("SCENE CHANGED!\n");

    // Need to work out what scene has now been changed to ... how?
}
So when the function testCallback is called i need to know what scene number im at.

If i was using the patch/object view i'd just use M4L.api.GetSelectedSceneIndex. So my question is, how do i call that from within my javascript file?
iMac G5 2.16 | Echo AudioFire12 | Xone 92 | Live 8 + M4L | Trigger Finger | Monome 256 | Kenton Killamix Mini | Truth 3031A

pukunui
Posts: 405
Joined: Thu Jan 29, 2009 10:26 pm
Location: Los Angeles

Re: Calling MFL.API Abstractions from within Javascript code

Post by pukunui » Sun May 09, 2010 11:35 pm

Just create or move an object to the selected_scene path in your callback. Then you'll have an object which is the selected scene, and if you want, you can get its id.

-A

Gravis
Posts: 104
Joined: Sat Jul 28, 2007 4:47 am

Re: Calling MFL.API Abstractions from within Javascript code

Post by Gravis » Mon May 10, 2010 8:51 am

Actually I'm after the scene INDEX, NOT the scene object itself.
iMac G5 2.16 | Echo AudioFire12 | Xone 92 | Live 8 + M4L | Trigger Finger | Monome 256 | Kenton Killamix Mini | Truth 3031A

pukunui
Posts: 405
Joined: Thu Jan 29, 2009 10:26 pm
Location: Los Angeles

Re: Calling MFL.API Abstractions from within Javascript code

Post by pukunui » Mon May 10, 2010 3:43 pm

Once you have the object won't its path will give you the index?

-A

Gravis
Posts: 104
Joined: Sat Jul 28, 2007 4:47 am

Re: Calling MFL.API Abstractions from within Javascript code

Post by Gravis » Mon May 10, 2010 4:21 pm

from what i can see there's no getIndex method on the Scene object? how would i do this?
iMac G5 2.16 | Echo AudioFire12 | Xone 92 | Live 8 + M4L | Trigger Finger | Monome 256 | Kenton Killamix Mini | Truth 3031A

pukunui
Posts: 405
Joined: Thu Jan 29, 2009 10:26 pm
Location: Los Angeles

Re: Calling MFL.API Abstractions from within Javascript code

Post by pukunui » Mon May 10, 2010 8:53 pm

Parse the path

( try saying that 10 times in a row)

Code: Select all

function set_up()
{
   
    selected_scene_observer = new LiveAPI(this.patcher, testCallback, "live_set", "view");
    selected_scene_observer.property = "selected_scene";
}

function testCallback()
{
	my_new_scene = new LiveAPI(this.patcher, "live_set view selected_scene");
    post(my_new_scene.path,"\n");    
}

-A

Gravis
Posts: 104
Joined: Sat Jul 28, 2007 4:47 am

Re: Calling MFL.API Abstractions from within Javascript code

Post by Gravis » Mon May 10, 2010 9:50 pm

ok so that works ....... i have no idea how, can you please point me to the documentation that says the 'path' is actually the index? cause im not seeing that anywhere :(

Thankyou!!! :D
iMac G5 2.16 | Echo AudioFire12 | Xone 92 | Live 8 + M4L | Trigger Finger | Monome 256 | Kenton Killamix Mini | Truth 3031A

Post Reply