Observing Push controls with JS

Learn about building and using Max for Live devices.
Post Reply
peeddrroo
Posts: 4774
Joined: Fri Mar 26, 2004 10:25 pm
Location: France

Observing Push controls with JS

Post by peeddrroo » Wed Sep 13, 2023 9:51 am

Hi

I am trying to observe Push buttons inside a JS script.
For instance if I try to observe the Shift button, I would go

Code: Select all

  var api = new LiveAPI(sample_callback, "control_surfaces 1");
  shift_button_id = api.call("get_control_by_name", "Shift_Button");
which returns a string with a (negative) id number.
But when I try to assign this id number to a new object like that :

Code: Select all

var shift_button_api = new LiveAPI();
shift_button_api.id = shift_button_id;
I get the following error :
jsliveapi: get path: error calculating the path

it seems that jsliveapi is trying to transform the id for the control into a path, but it can't.

I tried to use the technique in this thread (using a path such as

Code: Select all

control_surfaces 0 controls 92
)
but it doesn't work.

Anybody got an idea of how I could achieve this ?

Trevor being Trevor
Posts: 8
Joined: Thu Apr 21, 2022 2:51 pm

Re: Observing Push controls with JS

Post by Trevor being Trevor » Thu Sep 21, 2023 8:49 pm

Briefly looking over your post I am not sure, but when I run into that sort of problem I usually go back to the live.path, live.object and live.observer objects inside of Max. I set those up with print objects and send messages like getinfo and getchildren etc. Usually, between that and Live Object Model documentation I can get a good idea of what I need to do to get it working in JavaScript. Hope you get to the bottom of it!

[jur]
Site Admin
Posts: 5406
Joined: Mon Jun 01, 2015 3:04 pm
Location: Ableton

Re: Observing Push controls with JS

Post by [jur] » Thu Sep 21, 2023 10:31 pm

Hey Peeddrroo

Which Push firmware are you running? Because there's a problem with the current release version, at least with M4L where you can't observe a parameter WITHOUT first grabbing it.
No idea how JS works but maybe that's related?
That issue is solved in the current Push beta v1.1.20b1, though.
Ableton Forum Moderator

Post Reply