I’m getting my feet wet with the js LiveAPI object but I can’t find a way to observe anything other than through the live.observer Max object.
Yeah you can
var foo = new LiveAPI(callback);
foo.path = "live_set tracks 0 mixer_device volume"
foo.property = "value";
Ah great! I misunderstood the constructor callback function.
Is there a way to use the same callback function to observe the same parameter on different tracks?
For instance, I’d like to observe the ‘volume’ parameter in all tracks without having to define a different callback for each track. Is there a way to retrieve the track reference from the args in the callback function?
You’ll need separate LiveAPI objects for things which have different ids in a live set
Thanks for your reply Andrew. I understand I need different LiveAPI objects to register each observer for each track but my question is whether I can use the same callback function for each observer or do I need to create a different callback for each observer too.
var api1 = new LiveAPI(volumeChanged);
var api2 = new LiveAPI(volumeChanged);
var api3 = new LiveAPI(volumeChanged);
api1.path = "live_set tracks 0 mixer_device volume"
api2.path = "live_set tracks 1 mixer_device volume"
api3.path = "live_set tracks 2 mixer_device volume"
api1.property = "value";
api2.property = "value";
api3.property = "value";
// Right now only one argument is received, the value, thus we don’t know in which track the volume has changed.
// Ideally here the source object (volume in this case) could be passed as an argument so we could go through the canonical_path to find its track…
you can use ‘this’ in the callback to determine which LiveAPI instance you have been called back with, e.g. this.id to find out the id of the callback