Forums > Javascript

Launch Ableton scene from Javascript

April 15, 2014 | 3:03 am

Can anyone please advise what call I can make in javascript to launch a scene in Ableton Live. The path using the API i believe is e.g "live_set scenes 0" and then the function to call is "fire" but I am not sure how to put this in javascript syntax and it would be very good if anyone can advise.

  • This topic was modified 5 months by  kmll.


Lee
April 15, 2014 | 6:10 am

Hi, try this:

var lom_api = new LiveAPI( callback, ‘path live_set scenes 0′ );
lom_api.call( ‘fire’ );


April 15, 2014 | 11:53 am

Thanks for the advise but I get the following error:
js: testapi.js: Javascript ReferenceError: callback is not defined, line 2



Lee
April 16, 2014 | 1:03 am

Hi, you need to supply a callback function also. in this case, it doesn’t need to do anything (unless you want to start doing things when the scene is launched)

function callback() {
}


April 16, 2014 | 3:11 pm

Thanks again but I still do not get it to work.. Now I get:
jsliveapi: set path: invalid path
jsliveapi: call fire: no valid object set

This is my code:


function bang(){
	var lom_api = new LiveAPI( callback, 'path live_set scenes 3' );
	lom_api.call( 'fire' );
}
	
	
function callback() {
}
  • This reply was modified 5 months by  kmll.


Lee
April 17, 2014 | 1:42 am

sorry, my bad, you don’t need to ‘path’ in the string for js, just the ‘live_set scenes 3′) – get confused sometimes switching between the 2 :)


April 17, 2014 | 4:56 am

Ah thanks – it works fine now? Just a quick quick question regarding the callback. I have seen in some other examples that "this.patcher" has been used instead of "callback". Do you know the difference?



Lee
April 17, 2014 | 5:52 am

maybe that’s a way of not having to specify a callback if you’re not interested in it… that would be my guess



Lee
April 17, 2014 | 6:35 am

Looking at the docs:

Legacy note: previous versions of the LiveAPI object required the jsthis object’s this.patcher property as the first argument. For backward-compatibility, this first argument is still supported, but is no longer necessary.

So if you don’t need a callback you can omit that parameter – I’ve just tested this and it works, but at one point this didn’t work and you needed to pass 2 parameters in (maybe something broke and is now fixed)


April 17, 2014 | 11:21 am

Ok great:) Good to get this verified. Thanks again Lee for very good help with this post!


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