Forums > Javascript

Translate M4L patch to javascript – retrieve track number

Feb 15 2014 | 12:37 pm

I need to get the value of which track number the device is on in javascript. I found the example below and it works fine but I need to do the same inside javascript. I have tested a few ways but I can’t figure out how to translate on my own. Please advise if you know:)

— Pasted Max Patch, click to expand. —


Feb 16 2014 | 1:01 am

If you have the JavaScript device object it has an attribute "unquotedpath" which you can split to get the track number:

var parts = device.unquotedpath.split (‘ ‘);
var trackNo = Number (parts[2]);

Example to get the device:
var device = new LiveAPI (‘live_set view selected_track view selected_device’);

If you just have a device ID, you can do:

var api = new LiveAPI (); = Number (deviceID);
var parts = apiunquotedpath.split (‘ ‘);

Feb 16 2014 | 2:54 am

Thank you for the advise but I still did not get it to work. How can I retrieve the deviceID?

Feb 17 2014 | 4:15 am

This should do it:

var api = new LiveAPI (‘this_device’);
var parts = api.unquotedpath.split (‘ ‘);
var trackNo = Number (parts[2]);

Feb 17 2014 | 11:39 am

Brillian:) Thanks!

Feb 26 2014 | 2:48 am

Hey Moss,

How did you figure out that "unquotedpath" was even an available attribute? If I could just find documentation on what methods/attributes are available via LiveAPI, I could use it!

Viewing 6 posts - 1 through 6 (of 6 total)

Forums > Javascript