live objects in javascript

Learn about building and using Max for Live devices.
Post Reply
ST8
Posts: 259
Joined: Mon Jan 26, 2009 12:55 pm

live objects in javascript

Post by ST8 » Wed Sep 23, 2009 3:17 pm

I posted this in another thread but it was a bit of a hijack.

How exactly do we access the live objects from javascript? I'm wanting to make a clip launcher and some monome framework using javascript as this should be slightlier simpler than graphically patching it.

Ive tried for example:

path = new LiveAPI('live.path')

which just results in max crashing.

Are these features implemented and not documented or just not quite there yet?

hoffman2k
Posts: 14718
Joined: Tue Jun 15, 2004 6:40 pm
Location: Belgium
Contact:

Re: live objects in javascript

Post by hoffman2k » Wed Sep 23, 2009 3:29 pm

Try this shared by Jeremy from Cycling:

http://pastie.org/627540
var api = new LiveAPI(this.patcher /*required */, callback_fun /*optional*/, "initial_path to some live_thing" /*optional*/);

functions:
getcount [some_child]
goto [some_path]
get [some_property]
getstring [some_property]
set [some_property]
call [some_function]

properties:
id: r/o, int
path:
set: string or array (only 1 path, though)
get: string (current path)
children: r/o, array
mode: [ignore for now]
type: r/o, string (type of current path)
info: r/o, string (info of current path)
property:
set: string
get: string (observed property)
proptype: r/o, string (observed property type)

The callback argument in the constructor function can be used to specify a JS function which will be called when the object's id changes (when setting a new path, or in 'object follows path' mode (currently broken, don't worry about it yet)) or when an observed property changes. See the attached .js for a usage example.

Please let me know how it goes. The object appears to be nice and stable at this point, so it would be worth spending some time with it.

New builds should be out soon, so keep an eye out!

Jeremy

ST8
Posts: 259
Joined: Mon Jan 26, 2009 12:55 pm

Re: live objects in javascript

Post by ST8 » Wed Sep 23, 2009 5:11 pm

cheers, just what i was looking for!

Post Reply